Update main.py
Browse files
main.py
CHANGED
@@ -48,13 +48,7 @@ async def VectorDatabase(categorie):
|
|
48 |
@cl.step(type="retrieval")
|
49 |
async def Retriever(categorie):
|
50 |
vectorstore = await VectorDatabase(categorie)
|
51 |
-
if categorie == "
|
52 |
-
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 150,"filter": {'categorie': {'$eq': categorie}}})
|
53 |
-
elif categorie == "year":
|
54 |
-
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 6,"filter": {'year': {'$gte': 2019}}})
|
55 |
-
elif categorie == "skills":
|
56 |
-
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 200,"filter": {'file': {'$eq': 'competences-master-CFA.csv'}}})
|
57 |
-
elif categorie == "videosTC":
|
58 |
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 200,"filter": {"title": {"$eq": "videos-confinement-timeline"}}})
|
59 |
return retriever
|
60 |
|
@@ -128,7 +122,7 @@ async def set_starters():
|
|
128 |
async def on_message(message: cl.Message):
|
129 |
await cl.Message(f"> EVENTIA").send()
|
130 |
model = await LLModel()
|
131 |
-
retriever = await Retriever(
|
132 |
########## Chain with streaming ##########
|
133 |
message_history = ChatMessageHistory()
|
134 |
memory = ConversationBufferMemory(memory_key="chat_history",output_key="answer",chat_memory=message_history,return_messages=True)
|
@@ -174,24 +168,6 @@ async def on_message(message: cl.Message):
|
|
174 |
|
175 |
#search = vectorstore.similarity_search(message.content,k=50, filter={"categorie": {"$eq": "bibliographie-OPP-DGDIN"}})
|
176 |
search = await Search(message.content, "videosTC")
|
177 |
-
|
178 |
-
#os.environ["GOOGLE_CSE_ID"] = os.getenv('GOOGLE_CSE_ID')
|
179 |
-
#os.environ["GOOGLE_API_KEY"] = os.getenv('GOOGLE_API_KEY')
|
180 |
-
#searchAPI = GoogleSearchAPIWrapper()
|
181 |
-
#def top5_results(query):
|
182 |
-
# return searchAPI.results(query, 5)
|
183 |
-
|
184 |
-
#tool = Tool(
|
185 |
-
# name="Google Search Snippets",
|
186 |
-
# description="Search Google for recent results.",
|
187 |
-
# func=top5_results,
|
188 |
-
#)
|
189 |
-
#query = str(message.content)
|
190 |
-
#ref_text = tool.run(query)
|
191 |
-
#if 'Result' not in ref_text[0].keys():
|
192 |
-
# print(ref_text)
|
193 |
-
#else:
|
194 |
-
# print('None')
|
195 |
|
196 |
sources = [
|
197 |
cl.Text(name="Sources", content=search[0], display="inline")
|
|
|
48 |
@cl.step(type="retrieval")
|
49 |
async def Retriever(categorie):
|
50 |
vectorstore = await VectorDatabase(categorie)
|
51 |
+
if categorie == "videosTC":
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
retriever = vectorstore.as_retriever(search_type="similarity_score_threshold", search_kwargs={"score_threshold": .7, "k": 200,"filter": {"title": {"$eq": "videos-confinement-timeline"}}})
|
53 |
return retriever
|
54 |
|
|
|
122 |
async def on_message(message: cl.Message):
|
123 |
await cl.Message(f"> EVENTIA").send()
|
124 |
model = await LLModel()
|
125 |
+
retriever = await Retriever("videosTC")
|
126 |
########## Chain with streaming ##########
|
127 |
message_history = ChatMessageHistory()
|
128 |
memory = ConversationBufferMemory(memory_key="chat_history",output_key="answer",chat_memory=message_history,return_messages=True)
|
|
|
168 |
|
169 |
#search = vectorstore.similarity_search(message.content,k=50, filter={"categorie": {"$eq": "bibliographie-OPP-DGDIN"}})
|
170 |
search = await Search(message.content, "videosTC")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
sources = [
|
173 |
cl.Text(name="Sources", content=search[0], display="inline")
|