samuel-moreira commited on
Commit
23bb044
1 Parent(s): f84ab3e

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -3
main.py CHANGED
@@ -1,7 +1,7 @@
1
  from ctransformers import AutoModelForCausalLM
2
- from fastapi import FastAPI, Request
 
3
  from pydantic import BaseModel
4
- import asyncio
5
 
6
  # Carregar o modelo
7
  llm = AutoModelForCausalLM.from_pretrained(
@@ -40,4 +40,4 @@ Caso não encontre alguma informação, retorne o campo com Null."""
40
  @app.post("/llm_on_cpu")
41
  async def stream(item: Validation):
42
  print("Start")
43
- return generate_response(item.prompt)
 
1
  from ctransformers import AutoModelForCausalLM
2
+ from fastapi import FastAPI
3
+ from fastapi.responses import StreamingResponse
4
  from pydantic import BaseModel
 
5
 
6
  # Carregar o modelo
7
  llm = AutoModelForCausalLM.from_pretrained(
 
40
  @app.post("/llm_on_cpu")
41
  async def stream(item: Validation):
42
  print("Start")
43
+ return StreamingResponse(generate_response(item.prompt), media_type="text/plain")