Anmol3263 commited on
Commit
4a90e83
·
verified ·
1 Parent(s): 03b53e4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import google.generativeai as genai
3
+ import os
4
+
5
+ # Secure API key
6
+ genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
7
+
8
+ # Model
9
+ model = genai.GenerativeModel("gemini-1.5-flash")
10
+
11
+ # Chat memory
12
+ chat_session = model.start_chat(history=[])
13
+
14
+ # Chat function
15
+ def chat(user_input, history):
16
+ try:
17
+ response = chat_session.send_message(user_input)
18
+ reply = response.text
19
+ history.append((user_input, reply))
20
+ return history, history
21
+ except Exception as e:
22
+ return str(e), history
23
+
24
+ # UI (customized)
25
+ iface = gr.ChatInterface(
26
+ fn=chat,
27
+ title="Jarvis AI 🤖",
28
+ description="Internal AI Assistant for Team",
29
+ theme="soft"
30
+ )
31
+
32
+ iface.launch()