Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,13 +4,11 @@ import google.generativeai as genai
|
|
4 |
from dotenv import load_dotenv
|
5 |
from prompts import system_prompt
|
6 |
|
7 |
-
# Load environment variables and configure API
|
8 |
load_dotenv()
|
9 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
10 |
|
11 |
-
# Configure model
|
12 |
model = genai.GenerativeModel(
|
13 |
-
model_name="gemini-2.0-flash",
|
14 |
generation_config={
|
15 |
"temperature": 0.9,
|
16 |
"top_p": 1,
|
@@ -19,18 +17,14 @@ model = genai.GenerativeModel(
|
|
19 |
)
|
20 |
|
21 |
def chat(message, history):
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
return response.text
|
30 |
-
except Exception as e:
|
31 |
-
return f"Error: {e}"
|
32 |
|
33 |
-
# Create Gradio interface
|
34 |
demo = gr.ChatInterface(
|
35 |
fn=chat,
|
36 |
examples=[
|
@@ -45,6 +39,5 @@ demo = gr.ChatInterface(
|
|
45 |
description="隆Hola! Soy Chucho Bot, tu asistente personal para el curso CopyXpert. 驴C贸mo puedo ayudarte hoy?"
|
46 |
)
|
47 |
|
48 |
-
|
49 |
-
demo.launch(share=True) # Added share=True for better accessibility
|
50 |
|
|
|
4 |
from dotenv import load_dotenv
|
5 |
from prompts import system_prompt
|
6 |
|
|
|
7 |
load_dotenv()
|
8 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
9 |
|
|
|
10 |
model = genai.GenerativeModel(
|
11 |
+
model_name="gemini-2.0-flash",
|
12 |
generation_config={
|
13 |
"temperature": 0.9,
|
14 |
"top_p": 1,
|
|
|
17 |
)
|
18 |
|
19 |
def chat(message, history):
|
20 |
+
return (
|
21 |
+
f"{system_prompt}\n\n"
|
22 |
+
f"User Message: {message}\n"
|
23 |
+
f"Previous Context: {history if history else 'No previous context'}\n"
|
24 |
+
f"Remember to maintain the friendly and helpful tone of Chucho Bot, "
|
25 |
+
f"focusing only on CopyXpert course information and benefits."
|
26 |
+
)
|
|
|
|
|
|
|
27 |
|
|
|
28 |
demo = gr.ChatInterface(
|
29 |
fn=chat,
|
30 |
examples=[
|
|
|
39 |
description="隆Hola! Soy Chucho Bot, tu asistente personal para el curso CopyXpert. 驴C贸mo puedo ayudarte hoy?"
|
40 |
)
|
41 |
|
42 |
+
demo.launch()
|
|
|
43 |
|