Update app.py
Browse files
app.py
CHANGED
@@ -22,12 +22,7 @@ class ChatRequest(BaseModel):
|
|
22 |
top_p: float = 0.95
|
23 |
model_choice: str = "HF"
|
24 |
|
25 |
-
|
26 |
-
response: str
|
27 |
-
|
28 |
-
prompt_template = f""""""
|
29 |
-
|
30 |
-
@app.post("/chat", response_model=ChatResponse)
|
31 |
async def chat(request: ChatRequest):
|
32 |
try:
|
33 |
if request.model_choice == "HF":
|
@@ -53,13 +48,8 @@ async def chat(request: ChatRequest):
|
|
53 |
if request.model_choice == "google":
|
54 |
client = genai.Client(api_key=google_api_key)
|
55 |
|
56 |
-
messages = [
|
57 |
-
{"role": "system", "parts": [request.system_message]},
|
58 |
-
{"role": "user", "parts": [request.message]},
|
59 |
-
]
|
60 |
-
|
61 |
response = client.models.generate_content(model="gemini-2.0-flash", contents=request.message)
|
62 |
-
return response
|
63 |
|
64 |
except Exception as e:
|
65 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
22 |
top_p: float = 0.95
|
23 |
model_choice: str = "HF"
|
24 |
|
25 |
+
@app.post("/chat")
|
|
|
|
|
|
|
|
|
|
|
26 |
async def chat(request: ChatRequest):
|
27 |
try:
|
28 |
if request.model_choice == "HF":
|
|
|
48 |
if request.model_choice == "google":
|
49 |
client = genai.Client(api_key=google_api_key)
|
50 |
|
|
|
|
|
|
|
|
|
|
|
51 |
response = client.models.generate_content(model="gemini-2.0-flash", contents=request.message)
|
52 |
+
return {"response": google_api_key}
|
53 |
|
54 |
except Exception as e:
|
55 |
raise HTTPException(status_code=500, detail=str(e))
|