alessandroptsn commited on
Commit
3409bf7
·
verified ·
1 Parent(s): da76acd

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +35 -6
main.py CHANGED
@@ -1,7 +1,10 @@
1
  from fastapi import FastAPI, HTTPException
2
  from fastapi.responses import PlainTextResponse
3
  from pydantic import BaseModel
4
- from llm_func import mdl
 
 
 
5
 
6
  app = FastAPI()
7
 
@@ -9,10 +12,36 @@ class TextInput(BaseModel):
9
  text: str
10
 
11
 
12
- @app.post("/llm/", response_class=PlainTextResponse)
13
- async def convert_to_llm(input_data: TextInput):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  if not input_data.text:
15
- raise HTTPException(status_code=400, detail="O texto não pode estar vazio.")
16
-
17
- output_data = mdl(input_data.text)
18
  return output_data
 
 
 
 
1
  from fastapi import FastAPI, HTTPException
2
  from fastapi.responses import PlainTextResponse
3
  from pydantic import BaseModel
4
+ from llm_func import llm_normal,llm_agent,name_age,llm_functioncalling,search,llm_search
5
+ from llama_cpp import Llama
6
+
7
+ llm = Llama.from_pretrained(repo_id="HuggingFaceTB/SmolLM2-360M-Instruct-GGUF",filename="*smollm2-360m-instruct-q8_0.gguf",verbose=False,n_ctx=500)
8
 
9
  app = FastAPI()
10
 
 
12
  text: str
13
 
14
 
15
+ @app.post("/llm_normal/", response_class=PlainTextResponse)
16
+ async def to_llm_normal(input_data: TextInput):
17
+ if not input_data.text:
18
+ raise HTTPException(status_code=400, detail="The text can't be empty.")
19
+ output_data = llm_normal(input_data.text,llm)
20
+ return output_data
21
+
22
+
23
+ @app.post("/llm_agent/", response_class=PlainTextResponse)
24
+ async def to_llm_agent(input_data: TextInput):
25
+ if not input_data.text:
26
+ raise HTTPException(status_code=400, detail="The text can't be empty.")
27
+ output_data = llm_agent(input_data.text,llm)
28
+ return output_data
29
+
30
+
31
+ @app.post("/llm_functioncalling/", response_class=PlainTextResponse)
32
+ async def to_llm_functioncalling(input_data: TextInput):
33
+ if not input_data.text:
34
+ raise HTTPException(status_code=400, detail="The text can't be empty.")
35
+ output_data = llm_functioncalling(input_data.text,llm)
36
+ return output_data
37
+
38
+
39
+ @app.post("/llm_search/", response_class=PlainTextResponse)
40
+ async def to_llm_search(input_data: TextInput):
41
  if not input_data.text:
42
+ raise HTTPException(status_code=400, detail="The text can't be empty.")
43
+ output_data = llm_search(input_data.text,llm)
 
44
  return output_data
45
+
46
+
47
+