Avo-k commited on
Commit
d6cb9d2
1 Parent(s): 68e7534

base de données v2

Browse files
app.py CHANGED
@@ -61,8 +61,8 @@ openai.api_version = "2022-12-01"
61
 
62
  retrieve_all = EmbeddingRetriever(
63
  document_store=FAISSDocumentStore.load(
64
- index_path="./documents/climate_gpt.faiss",
65
- config_path="./documents/climate_gpt.json",
66
  ),
67
  embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
68
  model_format="sentence_transformers",
@@ -71,8 +71,8 @@ retrieve_all = EmbeddingRetriever(
71
 
72
  retrieve_giec = EmbeddingRetriever(
73
  document_store=FAISSDocumentStore.load(
74
- index_path="./documents/climate_gpt_only_giec.faiss",
75
- config_path="./documents/climate_gpt_only_giec.json",
76
  ),
77
  embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
78
  model_format="sentence_transformers",
@@ -124,18 +124,17 @@ def chat(
124
  stop=["\n---\n", "<|im_end|>"],
125
  )
126
  reformulated_query = reformulated_query["choices"][0]["text"]
127
- reformulated_query,language = reformulated_query.split("\n")
128
  language = language.split(":")[1].strip()
129
  docs = [d for d in retriever.retrieve(query=reformulated_query, top_k=10) if d.score > threshold]
130
  messages = history + [{"role": "user", "content": query}]
131
 
132
  if docs:
133
-
134
  docs_string = []
135
- for i,d in enumerate(docs,1):
136
- content = d.content.replace("\r\n","")
137
  docs_string.append(f"📃 doc {i}: {d.meta['file_name']} page {d.meta['page_number']}\n{content}")
138
- sources = "\n\n".join([f"Query used for retrieval:\n{reformulated_query}"]+docs_string)
139
  messages.append({"role": "system", "content": f"{sources_prompt}\n\n{sources}\n\nAnswer in {language}:"})
140
 
141
  response = openai.Completion.create(
 
61
 
62
  retrieve_all = EmbeddingRetriever(
63
  document_store=FAISSDocumentStore.load(
64
+ index_path="./documents/climate_gpt_v2.faiss",
65
+ config_path="./documents/climate_gpt_v2.json",
66
  ),
67
  embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
68
  model_format="sentence_transformers",
 
71
 
72
  retrieve_giec = EmbeddingRetriever(
73
  document_store=FAISSDocumentStore.load(
74
+ index_path="./documents/climate_gpt_v2_only_giec.faiss",
75
+ config_path="./documents/climate_gpt_v2_only_giec.json",
76
  ),
77
  embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
78
  model_format="sentence_transformers",
 
124
  stop=["\n---\n", "<|im_end|>"],
125
  )
126
  reformulated_query = reformulated_query["choices"][0]["text"]
127
+ reformulated_query, language = reformulated_query.split("\n")
128
  language = language.split(":")[1].strip()
129
  docs = [d for d in retriever.retrieve(query=reformulated_query, top_k=10) if d.score > threshold]
130
  messages = history + [{"role": "user", "content": query}]
131
 
132
  if docs:
 
133
  docs_string = []
134
+ for i, d in enumerate(docs, 1):
135
+ content = d.content.replace("\r\n", "")
136
  docs_string.append(f"📃 doc {i}: {d.meta['file_name']} page {d.meta['page_number']}\n{content}")
137
+ sources = "\n\n".join([f"Query used for retrieval:\n{reformulated_query}"] + docs_string)
138
  messages.append({"role": "system", "content": f"{sources_prompt}\n\n{sources}\n\nAnswer in {language}:"})
139
 
140
  response = openai.Completion.create(
climate_gpt.db DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:38229336d47aa1c618a57443ccca94a13af559732b9f94754c00dd96563a1570
3
- size 105828352
 
 
 
 
climate_gpt_only_giec.db DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:2063cac42eab1bdebe38a4b7f9ee79545d4f4999d1288e637ffcc7701104ccdb
3
- size 76234752
 
 
 
 
documents/climate_gpt.faiss DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5f76824baf8ab91efd808728e6e4fbf31b6a30d621b3379835812ab0f75e9936
3
- size 178775085
 
 
 
 
documents/climate_gpt.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "sql_url": "sqlite:///climate_gpt.db",
3
- "faiss_index_factory_str": "Flat",
4
- "index": "climate_gpt",
5
- "similarity": "dot_product",
6
- "embedding_dim": 768
7
- }
 
 
 
 
 
 
 
 
documents/climate_gpt_only_giec.faiss DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:bd872dea502921a947d1339193b2587d6708efd7da4be5c49009bc95caacb356
3
- size 116155437
 
 
 
 
documents/climate_gpt_only_giec.json DELETED
@@ -1 +0,0 @@
1
- {"sql_url": "sqlite:///climate_gpt_only_giec.db", "faiss_index_factory_str": "Flat", "index": "climate_gpt_only_giec", "similarity": "dot_product", "embedding_dim": 768}