dorogan commited on
Commit
c4dc20f
1 Parent(s): 676808b

Update: async methods were added to api

Browse files
Files changed (2) hide show
  1. app.py +3 -3
  2. model.py +1 -1
app.py CHANGED
@@ -4,7 +4,7 @@ from pydantic import BaseModel
4
  from model import get_answer_from_llm
5
 
6
 
7
- class Prompt(BaseModel):
8
  prompt: str = ''
9
 
10
 
@@ -14,8 +14,8 @@ app = FastAPI(
14
 
15
 
16
  @app.post("/completion/")
17
- def get_answer(question: Prompt.prompt):
18
- answer = get_answer_from_llm(question)
19
  return answer
20
 
21
 
 
4
  from model import get_answer_from_llm
5
 
6
 
7
+ class PromptType(BaseModel):
8
  prompt: str = ''
9
 
10
 
 
14
 
15
 
16
  @app.post("/completion/")
17
+ async def get_answer(question: PromptType = None):
18
+ answer = await get_answer_from_llm(question=question.prompt)
19
  return answer
20
 
21
 
model.py CHANGED
@@ -24,5 +24,5 @@ async def get_answer_from_llm(question: str = None):
24
  temperature=0.3,
25
  )
26
 
27
- gen_text = await tokenizer.decode(gen_tokens[0])
28
  return gen_text
 
24
  temperature=0.3,
25
  )
26
 
27
+ gen_text = tokenizer.decode(gen_tokens[0])
28
  return gen_text