Spaces:
Sleeping
Sleeping
import gradio as gr | |
from groq import Groq | |
import os | |
key = os.getenv('groq') | |
client = Groq(api_key = key) | |
def echo(message, history): | |
stream = client.chat.completions.create( | |
messages=[ | |
{ | |
"role": "system", | |
"content": "you are a helpful assistant." | |
}, | |
# Set a user message for the assistant to respond to. | |
{ | |
"role": "user", | |
"content": message, | |
} | |
], | |
model="llama3-8b-8192", | |
temperature=0.5, | |
max_tokens=1024, | |
top_p=1, | |
stop=None, | |
stream=False, | |
) | |
return stream.choices[0].message.content | |
demo = gr.ChatInterface(fn=echo, title="First Bot") | |
demo.launch() |