Spaces:
Sleeping
Sleeping
| import gradio | |
| from groq import Groq | |
| client = Groq( | |
| api_key="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", | |
| ) | |
| def initialize_messages(): | |
| return [{"role": "system", | |
| "content": """You are a IELTS examiner, Reply to all queries regarding IELTS. | |
| Do not reply to queries regarding anything else other than IELTS except hi,hello or any other casual messages. | |
| if the user wants you to grade his essay grade it properly according to the IELTS grading criteria. | |
| round off the score to the nearest integer. | |
| if the User prompt is a greeting or a casual message make the reply short. | |
| If you dont know thw answer reply that you dont know it"""}] | |
| 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=500), | |
| textbox=gradio.Textbox(placeholder="Ask me a question related to IELTS"), | |
| title="IELTS Coach", | |
| description="Chat bot for IELTS Coaching", | |
| theme="soft", | |
| examples=["hi","What is IELTS", "how to Apply for IELTS"], | |
| submit_btn=True | |
| ) | |
| iface.launch(share=True) |