philmui commited on
Commit
dce8d18
1 Parent(s): ae1f715

moving init of semantic_rag_chain to start()

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -8,6 +8,7 @@ _logger.addHandler(logging.StreamHandler(stream=sys.stdout))
8
 
9
  from langchain_core.prompts import ChatPromptTemplate
10
  from langchain_core.vectorstores import VectorStore
 
11
 
12
  from globals import (
13
  DEFAULT_QUESTION1,
@@ -21,7 +22,7 @@ from semantic import (
21
  SemanticRAGChainFactory
22
  )
23
 
24
- _semantic_rag_chain = SemanticRAGChainFactory.get_semantic_rag_chain()
25
 
26
  @cl.on_message
27
  async def main(message: cl.Message):
@@ -50,6 +51,12 @@ async def start():
50
  name="User",
51
  url="https://media.architecturaldigest.com/photos/5f241de2c850b2a36b415024/master/w_1600%2Cc_limit/Luke-logo.png"
52
  ).send()
 
 
 
 
 
 
53
  content = ""
54
  # if _semantic_rag_chain is not None:
55
  # try:
@@ -66,7 +73,6 @@ async def start():
66
  # _logger.error(f"init error: {e}")
67
 
68
  cl.user_session.set("message_history", [{"role": "system", "content": "You are a helpful assistant. "}])
69
- _logger.info("\tsending message back: ready!!!")
70
  await cl.Message(
71
  content=content + "\nHow can I help you with Meta's 2023 10K?"
72
  ).send()
 
8
 
9
  from langchain_core.prompts import ChatPromptTemplate
10
  from langchain_core.vectorstores import VectorStore
11
+ from langchain_core.runnables.base import RunnableSequence
12
 
13
  from globals import (
14
  DEFAULT_QUESTION1,
 
22
  SemanticRAGChainFactory
23
  )
24
 
25
+ _semantic_rag_chain: RunnableSequence = None
26
 
27
  @cl.on_message
28
  async def main(message: cl.Message):
 
51
  name="User",
52
  url="https://media.architecturaldigest.com/photos/5f241de2c850b2a36b415024/master/w_1600%2Cc_limit/Luke-logo.png"
53
  ).send()
54
+
55
+ global _semantic_rag_chain
56
+ _semantic_rag_chain = SemanticRAGChainFactory.get_semantic_rag_chain()
57
+
58
+ _logger.info("\tsending message back: ready!!!")
59
+
60
  content = ""
61
  # if _semantic_rag_chain is not None:
62
  # try:
 
73
  # _logger.error(f"init error: {e}")
74
 
75
  cl.user_session.set("message_history", [{"role": "system", "content": "You are a helpful assistant. "}])
 
76
  await cl.Message(
77
  content=content + "\nHow can I help you with Meta's 2023 10K?"
78
  ).send()