Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from groq import Groq | |
| import os | |
| groq_key = os.getenv('groq_key') | |
| client = Groq( | |
| api_key= groq_key #os.environ.get("GROQ_API_KEY"), | |
| ) | |
| def chat(message, history): | |
| chat_completion = client.chat.completions.create( | |
| messages=[ | |
| { | |
| "role": "system", | |
| "content": "you are an MLOPs expert and AI Engineer", | |
| }, | |
| { | |
| "role": "user", | |
| "content": message, | |
| } | |
| ], | |
| model="llama-3.1-8b-instant", | |
| temperature = 0.5, | |
| max_tokens = 256, | |
| stop = None, | |
| stream = False, | |
| top_p = 1, | |
| ) | |
| return chat_completion.choices[0].message.content | |
| demo = gr.ChatInterface(fn=chat, title="Open Source chatbot") | |
| demo.launch(debug = True) |