Update app.py
Browse files
app.py
CHANGED
@@ -28,6 +28,7 @@ class ChatRequest(BaseModel):
|
|
28 |
using terrain, wind, and thermals. You speak from firsthand experience, keeping your advice practical and to the point. Provide detailed
|
29 |
yet concise responses, with a maximum of 150 words"""
|
30 |
temperature: float = 0.7
|
|
|
31 |
model_choice: str = "google"
|
32 |
|
33 |
@app.post("/chat")
|
@@ -35,16 +36,16 @@ async def chat(request: ChatRequest):
|
|
35 |
try:
|
36 |
if request.model_choice == "google":
|
37 |
client = genai.Client(api_key=google_api_key)
|
38 |
-
|
39 |
-
messages = [
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
]
|
44 |
|
45 |
response = client.models.generate_content(
|
46 |
model="gemini-2.0-flash",
|
47 |
-
contents=
|
48 |
config=GenerateContentConfig(
|
49 |
system_instruction=[request.system_message]
|
50 |
),
|
|
|
28 |
using terrain, wind, and thermals. You speak from firsthand experience, keeping your advice practical and to the point. Provide detailed
|
29 |
yet concise responses, with a maximum of 150 words"""
|
30 |
temperature: float = 0.7
|
31 |
+
chat_history: List[Dict[str, Any]] = []
|
32 |
model_choice: str = "google"
|
33 |
|
34 |
@app.post("/chat")
|
|
|
36 |
try:
|
37 |
if request.model_choice == "google":
|
38 |
client = genai.Client(api_key=google_api_key)
|
39 |
+
|
40 |
+
# messages = [
|
41 |
+
# {"role": "user", "parts": [{"text": request.message}]},
|
42 |
+
# # {"role": "model", "parts": [{"text": "Great! Dogs are fun pets."}]},
|
43 |
+
# # {"role": "user", "parts": [{"text": "How many dogs do I have?"}]},
|
44 |
+
# ]
|
45 |
|
46 |
response = client.models.generate_content(
|
47 |
model="gemini-2.0-flash",
|
48 |
+
contents=chat_history,
|
49 |
config=GenerateContentConfig(
|
50 |
system_instruction=[request.system_message]
|
51 |
),
|