groq-chatbot / app.py
mathpal123's picture
Create app.py
4f6ebb0 verified
Raw
History Blame Contribute Delete
881 Bytes
import gradio as gr
from groq import Groq
import os
key = os.getenv('GROQ_API_KEY')
client = Groq(api_key = key)
def chat(message, history):
chat_completion = client.chat.completions.create(
#
# Required parameters
#
messages=[
{
"role": "system",
"content": "you are a helpful assistant."
},
# Set a user message for the assistant to respond to.
{
"role": "user",
"content": message,
}
],
# The language model which will generate the completion.
model = "llama3-8b-8192",
temperature = 0.5,
max_tokens = 1024,
top_p = 1,
stop = None,
stream = False,
)
return chat_completion.choices[0].message.content
demo = gr.ChatInterface(fn=chat, title="Open Source chatbot")
demo.launch(debug=True)