| 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( |
| |
| |
| |
| messages=[ |
| { |
| "role": "system", |
| "content": "you are a helpful assistant." |
| }, |
| |
| { |
| "role": "user", |
| "content": message, |
| } |
| ], |
|
|
| |
| 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) |