chatbot / app.py
mervp's picture
Update app.py
1bc9f1d verified
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)