yash-srivastava19 commited on
Commit
307474b
·
1 Parent(s): 4c15032

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -13,7 +13,7 @@ Code:
13
  """
14
 
15
 
16
- @cl.langchain_factory(use_async=False)
17
  def factory():
18
  system_message_prompt = SystemMessagePromptTemplate.from_template(template)
19
 
@@ -23,9 +23,17 @@ def factory():
23
  llm_chain = LLMChain(prompt=prompt, llm=llm, verbose=True,)
24
 
25
  cl.user_session.set("llm_chain", llm_chain)
26
- return llm_chain
27
 
28
 
 
 
 
 
 
 
 
 
 
29
  @cl.langchain_rename # This will be particularly useful when we want to customize this thing for production.
30
  def rename(orig_author):
31
  rename_dict = {
@@ -33,7 +41,3 @@ def rename(orig_author):
33
  }
34
  return rename_dict.get(orig_author, orig_author)
35
 
36
-
37
- @cl.on_chat_start
38
- async def main():
39
- await cl.Message(content="Welcome to CodeSmith !! Let's start this").send()
 
13
  """
14
 
15
 
16
+ @cl.on_chat_start
17
  def factory():
18
  system_message_prompt = SystemMessagePromptTemplate.from_template(template)
19
 
 
23
  llm_chain = LLMChain(prompt=prompt, llm=llm, verbose=True,)
24
 
25
  cl.user_session.set("llm_chain", llm_chain)
 
26
 
27
 
28
+
29
+ @cl.on_message
30
+ async def main(message):
31
+ llm_chain = cl.user_session.get("llm_chain")
32
+
33
+ res = await llm_chain.acall(message, callbacks=[cl.AsyncLangchainCallbackHandler()])
34
+
35
+ await cl.Message(content=res["text"]).send()
36
+
37
  @cl.langchain_rename # This will be particularly useful when we want to customize this thing for production.
38
  def rename(orig_author):
39
  rename_dict = {
 
41
  }
42
  return rename_dict.get(orig_author, orig_author)
43