DasariHarshitha commited on
Commit
c3fe798
Β·
verified Β·
1 Parent(s): fc65e68

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -1,23 +1,23 @@
1
  import streamlit as st
2
- from langchain_openai import ChatOpenAI
3
  from langchain.chains import ConversationChain
4
  from langchain.memory import ConversationBufferMemory
5
 
6
- # Sidebar for OpenAI key
7
  st.sidebar.title("βš™οΈ Settings")
8
- api_key = st.sidebar.text_input("Enter your OpenAI API Key", type="password")
9
 
10
  st.title("πŸ€– AI Conversational Data Science Tutor")
11
 
12
  if api_key:
13
- # Initialize model
14
- llm = ChatOpenAI(
15
- model="gpt-4o-mini",
 
16
  temperature=0.5,
17
- openai_api_key=api_key
18
  )
19
 
20
- # Memory for conversation awareness
21
  if "memory" not in st.session_state:
22
  st.session_state.memory = ConversationBufferMemory(return_messages=True)
23
 
@@ -28,15 +28,17 @@ if api_key:
28
  verbose=False
29
  )
30
 
31
- # User input
32
  user_input = st.chat_input("Ask a Data Science question...")
33
  if user_input:
34
  with st.chat_message("user"):
35
  st.write(user_input)
36
 
37
  with st.chat_message("assistant"):
38
- response = conversation.predict(input=f"You are a Data Science Tutor. Only answer Data Science questions. User asked: {user_input}")
 
 
39
  st.write(response)
40
 
41
  else:
42
- st.warning("πŸ”‘ Please enter your OpenAI API key in the sidebar to start.")
 
1
  import streamlit as st
2
+ from langchain_google_genai import ChatGoogleGenerativeAI
3
  from langchain.chains import ConversationChain
4
  from langchain.memory import ConversationBufferMemory
5
 
6
+ # Sidebar for Google API key
7
  st.sidebar.title("βš™οΈ Settings")
8
+ api_key = st.sidebar.text_input("Enter your Google API Key", type="password")
9
 
10
  st.title("πŸ€– AI Conversational Data Science Tutor")
11
 
12
  if api_key:
13
+ # Initialize Gemini model
14
+ llm = ChatGoogleGenerativeAI(
15
+ model="gemini-1.5-pro",
16
+ google_api_key=api_key,
17
  temperature=0.5,
 
18
  )
19
 
20
+ # Memory for conversation
21
  if "memory" not in st.session_state:
22
  st.session_state.memory = ConversationBufferMemory(return_messages=True)
23
 
 
28
  verbose=False
29
  )
30
 
31
+ # Chat input
32
  user_input = st.chat_input("Ask a Data Science question...")
33
  if user_input:
34
  with st.chat_message("user"):
35
  st.write(user_input)
36
 
37
  with st.chat_message("assistant"):
38
+ response = conversation.predict(
39
+ input=f"You are a Data Science Tutor. Only answer Data Science questions. User asked: {user_input}"
40
+ )
41
  st.write(response)
42
 
43
  else:
44
+ st.warning("πŸ”‘ Please enter your Google API key in the sidebar to start.")