ALBERT Clement commited on
Commit ·
0961faf
1
Parent(s): c4bf3b5
Maj Rag 1
Browse files- .gitignore +2 -0
- app.py +9 -3
- requirements.txt +2 -1
.gitignore
CHANGED
|
@@ -47,3 +47,5 @@ src/main.py
|
|
| 47 |
src/chat.py
|
| 48 |
src/llm/prompt2.py
|
| 49 |
src/loaders
|
|
|
|
|
|
|
|
|
| 47 |
src/chat.py
|
| 48 |
src/llm/prompt2.py
|
| 49 |
src/loaders
|
| 50 |
+
|
| 51 |
+
###
|
app.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
from src.vectorstore.faiss_index import load_index
|
|
@@ -16,12 +18,16 @@ from pathlib import Path
|
|
| 16 |
|
| 17 |
BASE_DIR = Path(__file__).parent
|
| 18 |
|
| 19 |
-
INDEX_PATH = BASE_DIR / "data/vectorstore/faiss.index"
|
| 20 |
-
METADATA_PATH = BASE_DIR / "data/metadata/metadata.json"
|
| 21 |
|
| 22 |
index = load_index(INDEX_PATH)
|
| 23 |
metadata = load_metadata(METADATA_PATH)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
def chat_fn(message, history):
|
| 27 |
|
|
@@ -49,7 +55,7 @@ Answer:
|
|
| 49 |
"""
|
| 50 |
|
| 51 |
# 6. Génération réponse LLM
|
| 52 |
-
answer =
|
| 53 |
|
| 54 |
# 6.1. Postprocessing
|
| 55 |
answer = clean_answer(answer)
|
|
|
|
| 1 |
+
import spaces
|
| 2 |
+
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
from src.vectorstore.faiss_index import load_index
|
|
|
|
| 18 |
|
| 19 |
BASE_DIR = Path(__file__).parent
|
| 20 |
|
| 21 |
+
INDEX_PATH = str(BASE_DIR / "data/vectorstore/faiss.index")
|
| 22 |
+
METADATA_PATH = str(BASE_DIR / "data/metadata/metadata.json")
|
| 23 |
|
| 24 |
index = load_index(INDEX_PATH)
|
| 25 |
metadata = load_metadata(METADATA_PATH)
|
| 26 |
|
| 27 |
+
@spaces.GPU
|
| 28 |
+
def generate_answer_gpu(prompt):
|
| 29 |
+
return generate_answer(prompt)
|
| 30 |
+
|
| 31 |
|
| 32 |
def chat_fn(message, history):
|
| 33 |
|
|
|
|
| 55 |
"""
|
| 56 |
|
| 57 |
# 6. Génération réponse LLM
|
| 58 |
+
answer = generate_answer_gpu(prompt)
|
| 59 |
|
| 60 |
# 6.1. Postprocessing
|
| 61 |
answer = clean_answer(answer)
|
requirements.txt
CHANGED
|
@@ -9,4 +9,5 @@ pandas==2.3.3
|
|
| 9 |
faiss-cpu==1.14.3
|
| 10 |
accelerate==1.14.0
|
| 11 |
safetensors==0.8.0
|
| 12 |
-
gradio==6.19.0
|
|
|
|
|
|
| 9 |
faiss-cpu==1.14.3
|
| 10 |
accelerate==1.14.0
|
| 11 |
safetensors==0.8.0
|
| 12 |
+
gradio==6.19.0
|
| 13 |
+
spaces==0.50.4
|