Spaces:
Runtime error
Runtime error
Commit
·
5b0a6ee
1
Parent(s):
547c0e6
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,13 @@
|
|
1 |
import os
|
2 |
import streamlit as st
|
3 |
-
|
4 |
|
5 |
# API key
|
6 |
api_key = "AIzaSyC70u1sN87IkoxOoIj4XCAPw97ae2LZwNM"
|
7 |
|
|
|
|
|
|
|
8 |
# Create chatbot interface
|
9 |
st.title("Gemini API Chatbot")
|
10 |
|
@@ -23,7 +26,7 @@ if user_input:
|
|
23 |
st.markdown(f"**You:** {user_input}")
|
24 |
|
25 |
# Create model object
|
26 |
-
model = GenerativeModel(model_name="gemini-pro"
|
27 |
|
28 |
# Get model response with generate_content method
|
29 |
with st.spinner("Thinking..."):
|
@@ -39,4 +42,4 @@ if user_input:
|
|
39 |
st.markdown(f"**Gemini Bot:** {response_text}")
|
40 |
|
41 |
# Update session state with chat history
|
42 |
-
st.session_state["chat_history"] = chat_history
|
|
|
1 |
import os
|
2 |
import streamlit as st
|
3 |
+
import google.generativeai as genai
|
4 |
|
5 |
# API key
|
6 |
api_key = "AIzaSyC70u1sN87IkoxOoIj4XCAPw97ae2LZwNM"
|
7 |
|
8 |
+
# Configure the API key
|
9 |
+
genai.configure(api_key=api_key)
|
10 |
+
|
11 |
# Create chatbot interface
|
12 |
st.title("Gemini API Chatbot")
|
13 |
|
|
|
26 |
st.markdown(f"**You:** {user_input}")
|
27 |
|
28 |
# Create model object
|
29 |
+
model = genai.GenerativeModel(model_name="gemini-pro")
|
30 |
|
31 |
# Get model response with generate_content method
|
32 |
with st.spinner("Thinking..."):
|
|
|
42 |
st.markdown(f"**Gemini Bot:** {response_text}")
|
43 |
|
44 |
# Update session state with chat history
|
45 |
+
st.session_state["chat_history"] = chat_history
|