-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllm.py
More file actions
34 lines (25 loc) · 645 Bytes
/
llm.py
File metadata and controls
34 lines (25 loc) · 645 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from groq import Groq
import os
client = Groq(
api_key=os.getenv("GROQ_API_KEY")
)
def generate_instagram_captions(description):
prompt = f"""
You are a social media caption generator.
Based on this image description:
{description}
Generate 7 short, cool Instagram captions.
Rules:
- Max 8 words
- Stylish and aesthetic
- No numbering
- Each caption on a new line
"""
chat_completion = client.chat.completions.create(
messages=[
{"role": "user", "content": prompt}
],
model="llama3-70b-8192",
)
captions = chat_completion.choices[0].message.content
return captions.split("\n")