Spaces:
Running
Running
kendrickfff
commited on
Commit
•
08cc93e
1
Parent(s):
39690f6
Update app.py
Browse files
app.py
CHANGED
@@ -6,14 +6,12 @@ from langchain_google_genai.chat_models import ChatGoogleGenerativeAI
|
|
6 |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "./firm-catalyst-437006-s4-407500537db5.json"
|
7 |
|
8 |
# Initialize the language model with required parameters
|
9 |
-
# Replace 'your-model-name' with the actual model you intend to use
|
10 |
llm = ChatGoogleGenerativeAI(model='gemini-1.5-pro')
|
11 |
|
12 |
def chat_with_gemini(message, chat_history):
|
13 |
-
#
|
14 |
-
bot_response =
|
15 |
-
chat_history.append(
|
16 |
-
chat_history.append({"role": "bot", "content": bot_response})
|
17 |
return chat_history, chat_history
|
18 |
|
19 |
# Create a Gradio interface
|
@@ -21,7 +19,7 @@ with gr.Blocks() as iface:
|
|
21 |
gr.Markdown("# Ken Chatbot")
|
22 |
gr.Markdown("Ask me anything!")
|
23 |
|
24 |
-
chatbot = gr.Chatbot(
|
25 |
msg = gr.Textbox(label="Type your message here...", placeholder="Enter your message and press enter to send your message...")
|
26 |
state = gr.State([]) # Store chat history
|
27 |
|
@@ -52,4 +50,4 @@ with gr.Blocks() as iface:
|
|
52 |
""")
|
53 |
|
54 |
# Launch the interface with debugging enabled
|
55 |
-
iface.launch(debug=True)
|
|
|
6 |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "./firm-catalyst-437006-s4-407500537db5.json"
|
7 |
|
8 |
# Initialize the language model with required parameters
|
|
|
9 |
llm = ChatGoogleGenerativeAI(model='gemini-1.5-pro')
|
10 |
|
11 |
def chat_with_gemini(message, chat_history):
|
12 |
+
# Generate a response using the language model
|
13 |
+
bot_response = llm.predict(message) # Get the bot's response from the model
|
14 |
+
chat_history.append((message, bot_response)) # Append the user and bot messages as a tuple
|
|
|
15 |
return chat_history, chat_history
|
16 |
|
17 |
# Create a Gradio interface
|
|
|
19 |
gr.Markdown("# Ken Chatbot")
|
20 |
gr.Markdown("Ask me anything!")
|
21 |
|
22 |
+
chatbot = gr.Chatbot(elem_id="chatbot") # Initialize the chatbot with an element ID for styling
|
23 |
msg = gr.Textbox(label="Type your message here...", placeholder="Enter your message and press enter to send your message...")
|
24 |
state = gr.State([]) # Store chat history
|
25 |
|
|
|
50 |
""")
|
51 |
|
52 |
# Launch the interface with debugging enabled
|
53 |
+
iface.launch(debug=True)
|