Ludovicollin commited on
Commit
ecbcdef
Β·
verified Β·
1 Parent(s): 405726f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +3 -26
main.py CHANGED
@@ -76,32 +76,8 @@ async def on_action(action):
76
  author="Datapcc 🌐🌐🌐", content="[Lien] πŸ”—", elements=elements
77
  ).send()
78
  await action.remove()
79
-
80
- @cl.action_callback("close_button")
81
- async def on_action(action):
82
- time.sleep(0.5)
83
- track = user_session.get("tracker")
84
- await track.remove()
85
-
86
- @cl.action_callback("action_button")
87
- async def on_action(action):
88
- task_list = cl.TaskList()
89
- # Create the TaskList
90
- # Create a task and put it in the running state
91
- task1 = cl.Task(title="Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data Processing data \n\n Processing data", status=cl.TaskStatus.READY)
92
- await task_list.add_task(task1)
93
- task2 = cl.Task(title=action.value, status=cl.TaskStatus.READY)
94
- await task_list.add_task(task2)
95
- # Perform some action on your end
96
- await task_list.send()
97
- tracking = user_session.set("tracker", task_list)
98
-
99
- others = [
100
- cl.Action(name="close_button", value="closed", label="Fermer", description="Fermer le volet d'information!")
101
- ]
102
- await cl.Message(author="Datapcc 🌐🌐🌐",content="Fermer le panneau d'information", actions=others).send()
103
 
104
- @cl.cache
105
  def retriever_to_cache():
106
  os.environ['PINECONE_API_KEY'] = os.environ['PINECONE_API_KEY']
107
  os.environ['PINECONE_ENVIRONMENT'] = "us-west4-gcp-free"
@@ -147,6 +123,7 @@ async def start():
147
  CONDENSE_QUESTION_PROMPT = PromptTemplate.from_template(_template)
148
 
149
  ########## Chain with streaming ##########
 
150
  message_history = ChatMessageHistory()
151
  memory = ConversationBufferMemory(
152
  memory_key="chat_history",
@@ -165,7 +142,7 @@ async def start():
165
  chain_type="stuff",
166
  return_source_documents=True,
167
  verbose=False,
168
- retriever=retriever_to_cache()
169
  )
170
  cl.user_session.set("conversation_chain", qa)
171
 
 
76
  author="Datapcc 🌐🌐🌐", content="[Lien] πŸ”—", elements=elements
77
  ).send()
78
  await action.remove()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
+ @cl.step(type="retrieval")
81
  def retriever_to_cache():
82
  os.environ['PINECONE_API_KEY'] = os.environ['PINECONE_API_KEY']
83
  os.environ['PINECONE_ENVIRONMENT'] = "us-west4-gcp-free"
 
123
  CONDENSE_QUESTION_PROMPT = PromptTemplate.from_template(_template)
124
 
125
  ########## Chain with streaming ##########
126
+ retrieval = wait retriever_to_cache()
127
  message_history = ChatMessageHistory()
128
  memory = ConversationBufferMemory(
129
  memory_key="chat_history",
 
142
  chain_type="stuff",
143
  return_source_documents=True,
144
  verbose=False,
145
+ retriever=retrieval
146
  )
147
  cl.user_session.set("conversation_chain", qa)
148