File size: 1,113 Bytes
485f344
 
 
cc9edca
 
 
 
 
 
 
 
 
485f344
 
 
 
 
cc9edca
485f344
 
 
cc9edca
 
 
 
485f344
cc9edca
485f344
cc9edca
 
 
485f344
cc9edca
 
 
 
 
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
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()