File size: 895 Bytes
8c9f9bc ec7f071 3c16aa4 ec7f071 e726c41 ec7f071 f5a71c5 |
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 35 36 37 38 39 40 41 42 43 |
import gradio as gr
from groq import Groq
import os
key=os.getenv("groq")
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-groq-70b-8192-tool-use-preview",
temperature=0.5,
max_tokens=256,
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,share=True) |