Amodit commited on
Commit
31f292c
·
1 Parent(s): 188eb69

Fix scheme chatbot chain bug

Browse files
Files changed (1) hide show
  1. agents/scheme_chatbot.py +8 -4
agents/scheme_chatbot.py CHANGED
@@ -44,16 +44,20 @@ prompt = PromptTemplate(
44
  )
45
 
46
  # --- Build Chain ---
47
- def get_search_results(query: dict):
48
- print(f"---NODE: Searching Schemes for profile: {query['user_profile']}---")
 
49
  try:
50
- return scheme_search.invoke(query["user_profile"])
51
  except Exception as e:
52
  print(f"Scheme search failed: {e}")
53
  return "Search unavailable."
54
 
 
 
 
55
  scheme_chatbot = (
56
- {"search_results": get_search_results, "user_profile": RunnablePassthrough()}
57
  | prompt
58
  | llm
59
  | parser
 
44
  )
45
 
46
  # --- Build Chain ---
47
+ def get_search_results(input_data):
48
+ user_profile = input_data.get("user_profile", "") if isinstance(input_data, dict) else input_data
49
+ print(f"---NODE: Searching Schemes for profile: {user_profile}---")
50
  try:
51
+ return scheme_search.invoke(user_profile)
52
  except Exception as e:
53
  print(f"Scheme search failed: {e}")
54
  return "Search unavailable."
55
 
56
+ def extract_user_profile(input_data):
57
+ return input_data.get("user_profile", "") if isinstance(input_data, dict) else input_data
58
+
59
  scheme_chatbot = (
60
+ {"search_results": get_search_results, "user_profile": extract_user_profile}
61
  | prompt
62
  | llm
63
  | parser