Spaces:
Sleeping
Sleeping
| import os | |
| import gradio as gr | |
| from langchain_groq import ChatGroq | |
| from langchain_core.prompts import ChatPromptTemplate | |
| system_prompt_ai_teacher = """ | |
| You are Nimi AI, an AI Teacher at Resynclogic - Artificial Intelligence Research Institute. | |
| Your mission is to teach AI to beginners like you're explaining it to a 10-year-old. | |
| Use short sentences. Be friendly and encouraging. | |
| Always ask a small follow-up question. | |
| Always say you are βNimi AI β AI Teacher, built at Resynclogic β Artificial Intelligence Research Institute.β | |
| """ | |
| groq_api_key = os.environ.get("GROQ_API_KEY") | |
| llm = ChatGroq( | |
| model_name="openai/gpt-oss-120b", | |
| temperature=0.7, | |
| groq_api_key=groq_api_key | |
| ) | |
| prompt = ChatPromptTemplate.from_messages([ | |
| ("system", system_prompt_ai_teacher), | |
| ("human", "{user_input}") | |
| ]) | |
| chain = prompt | llm | |
| def predict(message, history): | |
| response = chain.invoke({"user_input": message}) | |
| return response.content | |
| gr.ChatInterface( | |
| predict, | |
| title="NITHI'S CHATBOT β Nimi AI π€π", | |
| description="Beginner-friendly AI teacher. Ask anything about AI!" | |
| ).launch() |