Compare commits
2 Commits
7a9a9f7de1
...
8b2f69103e
Author | SHA1 | Date |
---|---|---|
|
8b2f69103e | |
|
e7113e3537 |
|
@ -1,48 +1,7 @@
|
||||||
env/*
|
env/*
|
||||||
databases/storage.db
|
databases/storage.db
|
||||||
4b751a4425c2884286a92fde2de6427f_trusted.table
|
*.table
|
||||||
4b751a4425c2884286a92fde2de6427f_analitic.table
|
|
||||||
4b751a4425c2884286a92fde2de6427f_analitic_voice.table
|
|
||||||
4b751a4425c2884286a92fde2de6427f_analitic_llm.table
|
|
||||||
4b751a4425c2884286a92fde2de6427f_analitic_ocr.table
|
|
||||||
.vscode/*
|
.vscode/*
|
||||||
__pycache__/*
|
__pycache__/*
|
||||||
|
|
||||||
conf/experiment_config.json
|
conf/experiment_config.json
|
||||||
example/Gmail.zip
|
example/*
|
||||||
example/Gmail/20240530_112812.jpg
|
|
||||||
example/Gmail/20240530_112825.jpg
|
|
||||||
example/Gmail/20240530_112925.jpg
|
|
||||||
example/Gmail/20240530_113110.jpg
|
|
||||||
example/Gmail/20240530_113114.jpg
|
|
||||||
example/Gmail/20240530_113531.jpg
|
|
||||||
example/Gmail/20240530_113555.jpg
|
|
||||||
example/Gmail/20240530_113614.jpg
|
|
||||||
example/Gmail/20240530_113650.jpg
|
|
||||||
example/Gmail/20240530_113731.jpg
|
|
||||||
example/audio/audio-file.flac
|
|
||||||
example/audio/audio-file2.flac
|
|
||||||
example/audio/AwACAgEAAxkBAAIBw2YX8o2vGGCNtZCXk7mY1Bm5w__lAAJmBAACxe7ARI1fUWAGcz_RNAQ.ogg
|
|
||||||
example/audio/AwACAgEAAxkBAAIBxWYX8z-FgaOqQ5wJ4588Oa4wKNbsAAJnBAACxe7AREtzfoE98xYHNAQ.ogg
|
|
||||||
example/audio/AwACAgEAAxkBAAIByGYX-NDzOEo-RH2YjEgG081ujEd-AAIQBAACS5vARIG7Bw8TVGr2NAQ.ogg
|
|
||||||
example/audio/AwACAgEAAxkBAANfZg2OE9Zvvn_7jJl7DaoD0j4kQQwAAqkEAAI-a3FEcjssrLJQjM00BA.ogg
|
|
||||||
example/audio/AwACAgEAAxkBAANhZg2U46T2Q6UYZ9gl3fHJsmJx2XcAAtgEAAI5ImlETOJIxvExjdg0BA.ogg
|
|
||||||
example/audio/AwACAgEAAxkBAANjZg2VEKqY04rTspcLw7trMmKPw58AAtkEAAI5ImlEZ18o0TpHffc0BA.ogg
|
|
||||||
example/audio/AwACAgEAAxkBAANlZg2WB8W9V-L0qkNENZrH1M1FZ5oAAtoEAAI5ImlEq70kYsaMeAs0BA.ogg
|
|
||||||
example/audio/AwACAgEAAxkBAANmZg2WDkyaygSa1QJvcSfYs6mNspcAAtsEAAI5ImlEfDhlNAY1KXs0BA.ogg
|
|
||||||
example/audio/AwACAgEAAxkBAANpZhcNbIqGT8cK3erus_8QoSBqkaMAAiEEAAIpsrhELqtOLaMMSf40BA.ogg
|
|
||||||
example/audio/AwACAgEAAxkBAANtZhcOLk3GkB7sTJ8HYUqjsmwjrNwAAiQEAAIpsrhEGvkyIIq7LKc0BA.ogg
|
|
||||||
example/audio/file_96.oga
|
|
||||||
example/audio/Prueba3.wav
|
|
||||||
example/audio/sin nombre.ogg
|
|
||||||
example/factura/Factura1.jpg
|
|
||||||
example/factura/Factura2.jpg
|
|
||||||
example/factura/Factura3.jpeg
|
|
||||||
example/factura/Factura4.jpg
|
|
||||||
example/factura/Factura5.jpg
|
|
||||||
example/factura/Factura6.jpg
|
|
||||||
example/texto/7fad5a297eb94ff9dbb3eff8e889a1c7dd87fe0f7c6bb6130f268acbfd828736.txt
|
|
||||||
4b751a4425c2884286a92fde2de6427f_analitic_llm_rag.table
|
|
||||||
4b751a4425c2884286a92fde2de6427f_analitic_llm_generaciontexto.table
|
|
||||||
4b751a4425c2884286a92fde2de6427f_analitic_llm_factura.table
|
|
||||||
4b751a4425c2884286a92fde2de6427f_analitic_llm_compra.table
|
|
100
apis.py
100
apis.py
|
@ -16,6 +16,8 @@ import statistics
|
||||||
import hashlib
|
import hashlib
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import json
|
import json
|
||||||
|
import uuid
|
||||||
|
import shutil
|
||||||
pwd = os.getcwd()
|
pwd = os.getcwd()
|
||||||
pathAud="example/audio"
|
pathAud="example/audio"
|
||||||
pathFact="example/factura"
|
pathFact="example/factura"
|
||||||
|
@ -28,10 +30,12 @@ def extractConfig(nameModel="SystemData",relPath=os.path.join(pwd,"conf/experime
|
||||||
Output= config[dataOut]
|
Output= config[dataOut]
|
||||||
return Output
|
return Output
|
||||||
mode_list=extractConfig(nameModel="SystemData",dataOut="mode_list")
|
mode_list=extractConfig(nameModel="SystemData",dataOut="mode_list")
|
||||||
|
from fastapi.templating import Jinja2Templates
|
||||||
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
#app.mount("/statics", StaticFiles(directory="statics"), name="statics")
|
#app.mount("/statics", StaticFiles(directory="statics"), name="statics")
|
||||||
|
templates = Jinja2Templates(directory="templates")
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
allow_origins=["*"],
|
allow_origins=["*"],
|
||||||
|
@ -82,8 +86,83 @@ class Response5(BaseModel):
|
||||||
prompt: str = Query("", description="Style and sentiments of text")
|
prompt: str = Query("", description="Style and sentiments of text")
|
||||||
mode : str = Query("", description="Style and sentiments of text")
|
mode : str = Query("", description="Style and sentiments of text")
|
||||||
|
|
||||||
|
menuaudtext="""<option value="whisper">whisper</option>
|
||||||
|
<option value="vosk">vosk</option>"""
|
||||||
|
|
||||||
|
menuLLM=""" <option value="meta-llama/Meta-Llama-3.1-70B-Instruct">meta-llama/Meta-Llama-3.1-70B-Instruct</option>
|
||||||
|
<option value="meta-llama/Meta-Llama-3.1-8B-Instruct">meta-llama/Meta-Llama-3.1-8B-Instruct</option>
|
||||||
|
<option value="Mistral">Mistral</option>
|
||||||
|
"""
|
||||||
#Funcionales
|
#Funcionales
|
||||||
|
|
||||||
|
@app.post("/uploadimg")
|
||||||
|
def upload_image(image: UploadFile = File(...),type="factura"):
|
||||||
|
endfile=".jpg"
|
||||||
|
t=time.time()
|
||||||
|
print(image.headers)
|
||||||
|
try:
|
||||||
|
# Create a temporary file to store the uploaded audio
|
||||||
|
headfilename=uuid.uuid4()
|
||||||
|
filename="example/%s/"%(type)+str(headfilename)+endfile
|
||||||
|
with open(f"{filename}", "wb") as buffer:
|
||||||
|
shutil.copyfileobj(image.file, buffer)
|
||||||
|
return JSONResponse(content={
|
||||||
|
"message": filename,
|
||||||
|
"time":time.time()-t
|
||||||
|
}, status_code=200)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return JSONResponse(content={
|
||||||
|
"message": f"There was an error uploading the file: {str(e)}"
|
||||||
|
}, status_code=500)
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/uploadaud")
|
||||||
|
def upload_audio(audio: UploadFile = File(...)):
|
||||||
|
if audio.headers['content-type']=="audio/wav":
|
||||||
|
endfile=".wav"
|
||||||
|
if audio.headers['content-type']=="audio/ogg":
|
||||||
|
endfile=".ogg"
|
||||||
|
if audio.headers['content-type']=="video/webm":
|
||||||
|
endfile=".webm"
|
||||||
|
type="audio"
|
||||||
|
try:
|
||||||
|
# Create a temporary file to store the uploaded audio
|
||||||
|
headfilename=uuid.uuid4()
|
||||||
|
filename="example/%s/"%(type)+str(headfilename)+endfile
|
||||||
|
|
||||||
|
with open(f"{filename}", "wb") as buffer:
|
||||||
|
shutil.copyfileobj(audio.file, buffer)
|
||||||
|
|
||||||
|
# Here you can process the audio file as needed
|
||||||
|
# For example, you might want to move it to a permanent location
|
||||||
|
# or perform some operations on it
|
||||||
|
#payload={"password":GetText2Voice.extractConfig(nameModel="SystemData",relPath=os.path.join(pwd,"conf/experiment_config.json"),dataOut="password"),"local":filename}
|
||||||
|
#A=requests.get("http://127.0.0.1:7870/voice2txtlocal", json=payload)
|
||||||
|
t=time.time()
|
||||||
|
return JSONResponse(content={
|
||||||
|
"message": filename,
|
||||||
|
"time":time.time()-t
|
||||||
|
}, status_code=200)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return JSONResponse(content={
|
||||||
|
"message": f"There was an error uploading the file: {str(e)}"
|
||||||
|
}, status_code=500)
|
||||||
|
|
||||||
|
finally:
|
||||||
|
audio.file.close()
|
||||||
|
|
||||||
|
@app.get("/addaudiohtml")
|
||||||
|
def addaudiohtml(request: Request):
|
||||||
|
return templates.TemplateResponse("addaudio.html", {"request": request})
|
||||||
|
|
||||||
|
@app.get("/addimagehtml")
|
||||||
|
def addimagehtml(request: Request):
|
||||||
|
return templates.TemplateResponse("addimage.html", {"request": request})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/addTrusted")
|
@app.get("/addTrusted")
|
||||||
@app.post("/addTrusted")
|
@app.post("/addTrusted")
|
||||||
def addTrusted(response:Response3):
|
def addTrusted(response:Response3):
|
||||||
|
@ -230,7 +309,7 @@ def EvalVoicehtml():
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Evaluacion de modelos voice2txt</title>
|
<title>Evaluación de modelos voice2txt</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
|
@ -257,8 +336,7 @@ def EvalVoicehtml():
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<select id="texto2">
|
<select id="texto2">
|
||||||
<option value="whisper">whisper</option>
|
%s
|
||||||
<option value="vosk">vosk</option>
|
|
||||||
</select>
|
</select>
|
||||||
<br>
|
<br>
|
||||||
<button onclick="enviarPeticion()">Enviar petición</button>
|
<button onclick="enviarPeticion()">Enviar petición</button>
|
||||||
|
@ -291,7 +369,7 @@ def EvalVoicehtml():
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""%(Sal)
|
"""%(Sal,menuaudtext)
|
||||||
return HTMLResponse(content=html, status_code=200)
|
return HTMLResponse(content=html, status_code=200)
|
||||||
|
|
||||||
|
|
||||||
|
@ -376,9 +454,7 @@ def EvalLLMComprahtml():
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<select id="texto2">
|
<select id="texto2">
|
||||||
<option value="meta-llama/Meta-Llama-3.1-70B-Instruct">meta-llama/Meta-Llama-3.1-70B-Instruct</option>
|
%s
|
||||||
<option value="meta-llama/Meta-Llama-3.1-8B-Instruct">meta-llama/Meta-Llama-3.1-8B-Instruct</option>
|
|
||||||
<option value="Mistral">Mistral</option>
|
|
||||||
</select>
|
</select>
|
||||||
<br>
|
<br>
|
||||||
<select id="texto3">
|
<select id="texto3">
|
||||||
|
@ -421,7 +497,7 @@ def EvalLLMComprahtml():
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""%(Sal,Sal2)
|
"""%(Sal,menuLLM,Sal2)
|
||||||
return HTMLResponse(content=html, status_code=200)
|
return HTMLResponse(content=html, status_code=200)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -506,9 +582,7 @@ def EvalLLMGeneracionTextohtml():
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<select id="texto2">
|
<select id="texto2">
|
||||||
<option value="meta-llama/Meta-Llama-3.1-70B-Instruct">meta-llama/Meta-Llama-3.1-70B-Instruct</option>
|
%s
|
||||||
<option value="meta-llama/Meta-Llama-3.1-8B-Instruct">meta-llama/Meta-Llama-3.1-8B-Instruct</option>
|
|
||||||
<option value="Mistral">Mistral</option>
|
|
||||||
</select>
|
</select>
|
||||||
<br>
|
<br>
|
||||||
<select id="texto3">
|
<select id="texto3">
|
||||||
|
@ -551,7 +625,7 @@ def EvalLLMGeneracionTextohtml():
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""%(Sal,Sal2)
|
"""%(Sal,menuLLM,Sal2)
|
||||||
return HTMLResponse(content=html, status_code=200)
|
return HTMLResponse(content=html, status_code=200)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="es">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{{title}}</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
input, button {
|
||||||
|
margin: 10px 0;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
#respuesta {
|
||||||
|
margin-top: 20px;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>{{title}}</h1>
|
||||||
|
|
||||||
|
<select id="texto1">
|
||||||
|
{{Sal}}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<select id="texto2">
|
||||||
|
<option value="whisper">whisper</option>
|
||||||
|
<option value="vosk">vosk</option>
|
||||||
|
</select>
|
||||||
|
<br>
|
||||||
|
<button onclick="enviarPeticion()">Enviar petición</button>
|
||||||
|
<div id="respuesta"></div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function enviarPeticion() {
|
||||||
|
const texto1 = document.getElementById('texto1').value;
|
||||||
|
const texto2 = document.getElementById('texto2').value;
|
||||||
|
const datos = {
|
||||||
|
path: texto1,
|
||||||
|
model: texto2
|
||||||
|
};
|
||||||
|
|
||||||
|
fetch('/EvalVoice', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(datos)
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
document.getElementById('respuesta').innerHTML = JSON.stringify(data, null, 2);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
document.getElementById('respuesta').innerHTML = 'Error: ' + error;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,49 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Audio Upload</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Upload Audio File</h1>
|
||||||
|
<form id="audio-upload-form" enctype="multipart/form-data">
|
||||||
|
<input type="file" name="audio" id="audio-file" accept="audio/*" required>
|
||||||
|
<br>
|
||||||
|
<button type="submit">Upload</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const form = document.getElementById('audio-upload-form');
|
||||||
|
form.addEventListener('submit', async (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
const fileInput = document.getElementById('audio-file');
|
||||||
|
const audioFile = fileInput.files[0];
|
||||||
|
|
||||||
|
if (!audioFile) {
|
||||||
|
alert('Please select an audio file to upload.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('audio', audioFile);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('uploadaud', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
const result = await response.json();
|
||||||
|
alert(`File uploaded successfully: ${result.filename}`);
|
||||||
|
} else {
|
||||||
|
const error = await response.json();
|
||||||
|
alert(`Error uploading file: ${error.message}`);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
alert(`Error uploading file: ${error.message}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,49 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>image Upload</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Upload image File</h1>
|
||||||
|
<form id="image-upload-form" enctype="multipart/form-data">
|
||||||
|
<input type="file" name="image" id="image-file" accept="image/*" required>
|
||||||
|
<button type="submit">Upload</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const form = document.getElementById('image-upload-form');
|
||||||
|
form.addEventListener('submit', async (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
const fileInput = document.getElementById('image-file');
|
||||||
|
const imageFile = fileInput.files[0];
|
||||||
|
|
||||||
|
if (!imageFile) {
|
||||||
|
alert('Please select an image file to upload.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('image', imageFile);
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('uploadimg', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
const result = await response.json();
|
||||||
|
alert(`File uploaded successfully: ${result.filename}`);
|
||||||
|
} else {
|
||||||
|
const error = await response.json();
|
||||||
|
alert(`Error uploading file: ${error.message}`);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
alert(`Error uploading file: ${error.message}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue