Ludovicollin commited on
Commit
79832e2
·
1 Parent(s): 1b2fca8

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +1 -5
main.py CHANGED
@@ -78,23 +78,19 @@ async def on_action(action):
78
 
79
  @cl.cache
80
  def to_cache(file):
81
- #time.sleep(5) # Simulate a time-consuming process
82
  return "https://cipen.univ-gustave-eiffel.fr/fileadmin/CIPEN/datas/assets/docs/" + file + ".csv"
83
 
84
  @cl.cache
85
  def retriever_to_cache():
86
  index_name = os.environ['PINECONE_INDEX_NAME']
87
  embeddings = HuggingFaceEmbeddings()
88
- time.sleep(11)
89
  pinecone.init(
90
  api_key=os.environ['PINECONE_API_KEY'],
91
  environment="us-west4-gcp-free"
92
  )
93
- time.sleep(11)
94
  vectorstore = Pinecone.from_existing_index(
95
  index_name=index_name, embedding=embeddings
96
  )
97
- time.sleep(11)
98
  retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 30,"filter": {'categorie': {'$eq': 'OF'}}})
99
  return retriever
100
 
@@ -269,7 +265,7 @@ async def main(message: cl.Message):
269
  text_elements = []
270
  metadatas = ''
271
  if source_documents:
272
- for source_idx, source_doc in enumerate(source_documents[::-1]):
273
  numSource = source_idx + 1
274
  source_name = f"Source n°{numSource}"
275
  text_elements.append(
 
78
 
79
  @cl.cache
80
  def to_cache(file):
 
81
  return "https://cipen.univ-gustave-eiffel.fr/fileadmin/CIPEN/datas/assets/docs/" + file + ".csv"
82
 
83
  @cl.cache
84
  def retriever_to_cache():
85
  index_name = os.environ['PINECONE_INDEX_NAME']
86
  embeddings = HuggingFaceEmbeddings()
 
87
  pinecone.init(
88
  api_key=os.environ['PINECONE_API_KEY'],
89
  environment="us-west4-gcp-free"
90
  )
 
91
  vectorstore = Pinecone.from_existing_index(
92
  index_name=index_name, embedding=embeddings
93
  )
 
94
  retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 30,"filter": {'categorie': {'$eq': 'OF'}}})
95
  return retriever
96
 
 
265
  text_elements = []
266
  metadatas = ''
267
  if source_documents:
268
+ for source_idx, source_doc in enumerate(source_documents):
269
  numSource = source_idx + 1
270
  source_name = f"Source n°{numSource}"
271
  text_elements.append(