diff --git a/apis.py b/apis.py
index e626f38..e29be7d 100644
--- a/apis.py
+++ b/apis.py
@@ -45,6 +45,14 @@ class Response(BaseModel):
"""
path: str = Query("", description="Style and sentiments of text")
model : str = Query("whisper", description="Style and sentiments of text")
+class Response4(BaseModel):
+ path: str = Query("", description="path file")
+ system: str = Query("", description="prompt system LLM model with ocr and image claude")
+ content: str = Query("%s", description="prompt content LLM model with ocr")
+ max_tokens: int = Query(1024, description="maxtoken LLM OCR model")
+ model: str = Query("Claude-sonnet", description="model")
+
+
class Response1(BaseModel):
path: str = Query("", description="path file")
task_prompt: str = Query("", description="task of model")
@@ -66,7 +74,14 @@ class Response3(BaseModel):
"""
path: str = Query("", description="Style and sentiments of text")
Trusted: str = Query("", description="Style and sentiments of text")
- mode : str = Query("whisper", description="Style and sentiments of text")
+ mode : str = Query("", description="Style and sentiments of text")
+
+class Response5(BaseModel):
+ """Structure of data to querry of make post from X or article blog
+ """
+ prompt: str = Query("", description="Style and sentiments of text")
+ mode : str = Query("", description="Style and sentiments of text")
+
#Funcionales
@app.get("/addTrusted")
@@ -99,11 +114,11 @@ def addTrusted(response:Response3):
content={"content": "file no found" }
)
if mode_list[mode]=="texto":
- hash1 = hashlib.sha256(path.encode()).hexdigest()+".txt"
- f = open("example/texto/"+hash1, "w")
- f.write(path)
- f.close()
- path=pwd+"/"+pathText+hash1
+ info=str({"path":path,"trusted":Trusted,"mode":mode})
+ hash1 = hashlib.sha256(info.encode()).hexdigest()
+ # with open("example/texto/"+hash1, 'w') as f:
+ # json.dump(info, f)
+ # path=pwd+"/"+pathText+hash1
length=len(Trusted)
size=0
duration=0
@@ -112,22 +127,63 @@ def addTrusted(response:Response3):
size=file_stats.st_size / (1024 * 1024)
length=0
duration=0
+ hash1=""
elif mode_list[mode]=="audio":
with audioread.audio_open(path) as f:
duration = f.duration
length=0
size=0
-
+ hash1=""
if db((db.trusted.path == path)&(db.trusted.mode == mode)).count()==0:
- db.trusted.insert(path=path,trusted=Trusted,mode=mode,size=size,duration=duration,last_modified=last_modified,length=length )
+ db.trusted.insert(path=path,trusted=Trusted,mode=mode,size=size,duration=duration,last_modified=last_modified,length=length,hash=hash1 )
db.commit()
return "Add %s in mode %s"%(path,mode)
else:
item=db((db.trusted.path == path)&(db.trusted.mode == mode)).select().last()
modification_count=item.modification_count + 1
- db((db.trusted.path == path)&(db.trusted.mode == mode)).update(trusted=Trusted,size=size,duration =duration,length=length,last_modified=last_modified,modification_count= modification_count)
+ db((db.trusted.path == path)&(db.trusted.mode == mode)).update(trusted=Trusted,size=size,duration =duration,length=length,last_modified=last_modified,modification_count= modification_count,hash=hash1)
db.commit()
return "Update %s in mode %s"%(path,mode)
+
+
+@app.get("/addPrompt")
+@app.post("/addPrompt")
+def addPrompt(response:Response5):
+ """Api to add information of Trusted data
+
+ Args:
+ response (Response3): 3 params:
+ path : path of archive on system if is a file OR text if is text.
+ Trusted : information Trusted or better information in a process.
+ mode: llm_compra,llm_factura,llm_generaciontexto,llm_rag,ocr,voice,
+
+ Returns:
+ _type_: _description_
+ """
+ prompt=response.prompt
+ mode=response.mode
+ last_modified=datetime.now()
+ if mode not in mode_list.keys():
+ return JSONResponse(
+ status_code=404,
+ content={"content": "mode no found" }
+ )
+ if mode == "llm_compra":
+ hash1 = str(hashlib.sha256(prompt.encode()).hexdigest())
+ # with open("example/texto/"+hash1, 'w') as f:
+ # json.dump(info, f)
+ # path=pwd+"/"+pathText+hash1
+ length=len(prompt)
+ if db((db.prompt.hash == hash1)&(db.prompt.mode == mode)).count()==0:
+ db.prompt.insert(prompt=prompt,mode=mode,last_modified=last_modified,length=length,hash=hash1 )
+ db.commit()
+ return "Add %s in mode %s"%(prompt,mode)
+ else:
+ A=db((db.prompt.hash == hash1)&(db.prompt.mode == mode)).update(prompt=prompt,mode=mode,last_modified=last_modified,length=length+1,hash=hash1)
+ db.commit()
+ print(A,last_modified)
+ return "Update %s in mode %s"%(prompt,mode)
+
@app.get("/EvalVoice")
@app.post("/EvalVoice")
@@ -141,17 +197,18 @@ def EvalVoice(response:Response):
)
Trusted=db((db.trusted.path == path ) & ( db.trusted.mode == "voice")).select().last().trusted
- print(Trusted)
if model=="whisper":
Sal=main.EvalWhisper(path,Trusted)
else:
Sal=main.EvalVosk(path,Trusted)
Sal["last_modified"]=datetime.now()
- if db(db.analitic_voice.path == Sal["path"] and db.analitic_voice.model == Sal["model"]).count()==0:
+ if db((db.analitic_voice.path == Sal["path"]) & (db.analitic_voice.model == Sal["model"])).count()==0:
+ print(1,Sal)
db.analitic_voice.insert(**Sal)
db.commit()
else:
- db(db.analitic_voice.path == Sal["path"] and db.analitic_voice.model == Sal["model"]).update(similarity= Sal["similarity"],similaritypartial= Sal["similaritypartial"],last_modified=Sal["last_modified"])
+ print(2,Sal)
+ db((db.analitic_voice.path == Sal["path"]) & (db.analitic_voice.model == Sal["model"])).update(similarity= Sal["similarity"],similaritypartial= Sal["similaritypartial"],last_modified=Sal["last_modified"])
db.commit()
return Sal
@@ -192,7 +249,7 @@ def EvalVoicehtml():
- Petición POST a API
+ Petición Evaluar modelo de voz comtra datos curados