-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_chatbot.py
46 lines (33 loc) · 1.2 KB
/
simple_chatbot.py
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
39
40
41
42
43
44
45
46
###################
# Simple Chat Bot #
###################
from langchain_google_genai import ChatGoogleGenerativeAI
from dotenv import load_dotenv
import streamlit as st
import os
import warnings
warnings.simplefilter(action="ignore", category=FutureWarning)
warnings.filterwarnings(action="ignore", category=DeprecationWarning)
load_dotenv()
os.environ["GOOGLE_API_KEY"] = os.environ.get("GENAI_API_KEY")
# Function to load the Google AI model and get responses
class GetGoogleAI():
def __init__(self):
self.llm = ChatGoogleGenerativeAI(
model="gemini-1.5-pro",
temperature=0,
max_retries=2,
)
def get_response(self, question):
return self.llm.predict(question)
def main():
chatAI = GetGoogleAI()
st.set_page_config(page_title="Simply Q&A ChatBot")
st.header("LangChain ChatBot")
if "messages" not in st.session_state:
st.session_state.messages = []
input = st.text_input("Input: ", key="input")
if st.button("Ask Question"):
st.write(chatAI.get_response(input))
if __name__ == "__main__":
main()