Spaces:
Sleeping
Sleeping
File size: 1,371 Bytes
95c6a2a d2e205a 605e6e6 95c6a2a 605e6e6 d2e205a 605e6e6 2f7a583 605e6e6 95c6a2a d2e205a 605e6e6 199de05 2f7a583 605e6e6 2f7a583 605e6e6 d2e205a 605e6e6 | 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 44 | import gradio
from groq import Groq
client = Groq(
api_key="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"
)
def initialize_messages():
return [{
"role": "system",
"content": """You are an expert software assistant with a strong focus on troubleshooting and resolving technical issues. Your goal is to assist users by offering precise, clear, and professional advice on software-related problems, including installation issues, bug fixes, updates, and coding best practices. """
}]
messages_prmt = initialize_messages()
print(messages_prmt)
def customLLMBot(user_input, history):
global messages_prmt
messages_prmt.append({"role": "user", "content": user_input})
response = client.chat.completions.create(
messages=messages_prmt,
model="llama3-8b-8192",
)
print(response)
LLM_reply = response.choices[0].message.content
messages_prmt.append({"role": "assistant", "content": LLM_reply})
return LLM_reply
iface = gradio.ChatInterface(
customLLMBot,
chatbot=gradio.Chatbot(height=300),
textbox=gradio.Textbox(placeholder="Ask me a question related to software field"),
title="MindMesh ",
description="Chat bot as an AI Tutor",
theme="soft",
examples=["hi", "What is supervised learning ?"],
submit_btn=True
)
iface.launch(share=True)
|