KJ24 commited on
Commit
8e038e1
·
verified ·
1 Parent(s): 5ac0022

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -50,6 +50,9 @@ class ChunkRequest(BaseModel):
50
  @app.post("/chunk")
51
  async def chunk_text(data: ChunkRequest):
52
  try:
 
 
 
53
  # ✅ Chargement du modèle LLM depuis Hugging Face en ligne (pas de .gguf local)
54
  llm = LlamaCPP(
55
  model_url="https://huggingface.co/leafspark/Mistral-7B-Instruct-v0.2-Q4_K_M-GGUF/resolve/main/mistral-7b-instruct-v0.2.Q4_K_M.gguf",
@@ -68,10 +71,14 @@ async def chunk_text(data: ChunkRequest):
68
  Settings.llm = llm
69
  Settings.embed_model = SimpleEmbedding()
70
 
 
71
  # ✅ Découpage sémantique intelligent
72
  parser = SemanticSplitterNodeParser.from_defaults()
73
  nodes = parser.get_nodes_from_documents([Document(text=data.text)])
74
 
 
 
 
75
  return {
76
  "chunks": [node.text for node in nodes],
77
  "metadatas": [node.metadata for node in nodes],
 
50
  @app.post("/chunk")
51
  async def chunk_text(data: ChunkRequest):
52
  try:
53
+ # ✅ Vérification du texte reçu
54
+ print(f"✅ Texte reçu ({len(data.text)} caractères) : {data.text[:200]}...")
55
+
56
  # ✅ Chargement du modèle LLM depuis Hugging Face en ligne (pas de .gguf local)
57
  llm = LlamaCPP(
58
  model_url="https://huggingface.co/leafspark/Mistral-7B-Instruct-v0.2-Q4_K_M-GGUF/resolve/main/mistral-7b-instruct-v0.2.Q4_K_M.gguf",
 
71
  Settings.llm = llm
72
  Settings.embed_model = SimpleEmbedding()
73
 
74
+
75
  # ✅ Découpage sémantique intelligent
76
  parser = SemanticSplitterNodeParser.from_defaults()
77
  nodes = parser.get_nodes_from_documents([Document(text=data.text)])
78
 
79
+ # ✅ Vérification du nombre de chunks générés
80
+ print(f"✅ Nombre de chunks générés : {len(nodes)}")
81
+
82
  return {
83
  "chunks": [node.text for node in nodes],
84
  "metadatas": [node.metadata for node in nodes],