Lhumpal commited on
Commit
873eb03
·
verified ·
1 Parent(s): e412a0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -21,7 +21,7 @@ class ChatRequest(BaseModel):
21
 
22
  class ChatResponse(BaseModel):
23
  model_status: str
24
- response: dict
25
  response_time: float
26
 
27
  @app.post("/chat", response_model=ChatResponse)
@@ -34,16 +34,13 @@ async def chat(request: ChatRequest):
34
  {'role': 'user', 'content': request.message}
35
  ]
36
 
37
- # Simulate getting the response from the model
38
  response = ollama.chat(model=model_name, messages=messages)
39
- response_dict = vars(response)
40
- assistant_response = response_dict["message"]["content"]
41
- # response = "pending"
42
 
43
  end_time = time.time()
44
  response_time = end_time - start_time
45
 
46
- return {"model_status": model.status, "response_time": response_time, "response": assistant_response}
47
 
48
  except Exception as e:
49
  raise HTTPException(status_code=500, detail=str(e))
 
21
 
22
  class ChatResponse(BaseModel):
23
  model_status: str
24
+ response: str
25
  response_time: float
26
 
27
  @app.post("/chat", response_model=ChatResponse)
 
34
  {'role': 'user', 'content': request.message}
35
  ]
36
 
 
37
  response = ollama.chat(model=model_name, messages=messages)
38
+ response = str(response)
 
 
39
 
40
  end_time = time.time()
41
  response_time = end_time - start_time
42
 
43
+ return {"model_status": model.status, "response_time": response_time, "response": response}
44
 
45
  except Exception as e:
46
  raise HTTPException(status_code=500, detail=str(e))