File size: 1,306 Bytes
ae29f6a
 
5482c3b
ae29f6a
 
5482c3b
 
ae29f6a
 
5482c3b
 
 
ae29f6a
 
 
 
 
5482c3b
ae29f6a
 
1bc9f1d
 
 
ae29f6a
 
 
 
 
 
 
5482c3b
 
 
 
 
 
 
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
import streamlit as st
import os
from langchain_core.prompts import ChatPromptTemplate
from langchain_groq import ChatGroq

groq_api_key = os.environ["GROQ_API_KEY"]
groq_model = os.environ["MODEL_NAME"]

prompt = ChatPromptTemplate.from_messages([
    ("system", "You are an intelligent AI bot that loves chatting with people. Answer in a friendly tone and do your best to help. Avoid sensitive content."),
    ("system", "If user asks your purpose, say you're a friendly bot happy to talk."),
    ("system", "If user asks who made you: you were made by Merwin Pinto, A talented student of Vishwakarma University."),
    ("human", "{question}")
])

model = ChatGroq(
    groq_api_key=groq_api_key,
    model_name=groq_model
)

st.set_page_config(page_title="Merwin AI", layout="centered")
st.title("🤖 Merwin's AI — Your AI Friend")
st.subheader("Lets Talk about something Interesting")

st.markdown("Type your question below:")

user_input = st.chat_input("Ask something...")

if user_input:
    with st.spinner("Processing... Please wait."):
        chain = prompt | model
        response = chain.invoke({"question": user_input})
        
        with st.chat_message("user"):
            st.markdown(user_input)
        with st.chat_message("assistant"):
            st.markdown(response.content)