tambah chat
Browse files
app.py
CHANGED
|
@@ -45,9 +45,14 @@ def root():
|
|
| 45 |
@app.post("/chat", response_model=ChatResponse)
|
| 46 |
def chat_endpoint(req: ChatRequest):
|
| 47 |
try:
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
return ChatResponse(
|
| 53 |
response=response_text,
|
|
@@ -55,7 +60,7 @@ def chat_endpoint(req: ChatRequest):
|
|
| 55 |
)
|
| 56 |
except Exception as e:
|
| 57 |
return ChatResponse(
|
| 58 |
-
response=f"
|
| 59 |
status="error"
|
| 60 |
)
|
| 61 |
|
|
|
|
| 45 |
@app.post("/chat", response_model=ChatResponse)
|
| 46 |
def chat_endpoint(req: ChatRequest):
|
| 47 |
try:
|
| 48 |
+
response_text = chat_indonesian(
|
| 49 |
+
message=req.message,
|
| 50 |
+
history=req.history,
|
| 51 |
+
system_message=req.system_message,
|
| 52 |
+
max_tokens=req.max_tokens,
|
| 53 |
+
temperature=req.temperature,
|
| 54 |
+
model_type=req.model
|
| 55 |
+
)
|
| 56 |
|
| 57 |
return ChatResponse(
|
| 58 |
response=response_text,
|
|
|
|
| 60 |
)
|
| 61 |
except Exception as e:
|
| 62 |
return ChatResponse(
|
| 63 |
+
response=f"Maaf, terjadi kesalahan: {str(e)}",
|
| 64 |
status="error"
|
| 65 |
)
|
| 66 |
|