-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroq_code.py
More file actions
29 lines (25 loc) · 852 Bytes
/
Copy pathgroq_code.py
File metadata and controls
29 lines (25 loc) · 852 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
from groq import Groq
from dotenv import load_dotenv
import os
# Load environment variables from .env file
load_dotenv()
# Initialize Groq client
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
# Create completion request
completion = client.chat.completions.create(
model="openai/gpt-oss-120b",
messages=[
{"role": "user", "content": "Could you explain the theory of relativity in simple terms?"},
{"role": "system", "content": "You are a helpful medical assistant chatbot. Give response in tabular format."},
{"role": "user", "content": "What are the symptoms of diabetes?"}
],
temperature=1,
max_completion_tokens=8192,
top_p=1,
reasoning_effort="medium",
stream=True,
stop=None
)
# Stream the response
for chunk in completion:
print(chunk.choices[0].delta.content or "", end="")