Perfect! Now with the new improvements, I went back to the code I had before, and it is…
- User
Perfect! Now with the new improvements, I went back to the code I had before, and it is giving me another weird error which makes no sense:
TypeError Traceback (most recent call last) Cell In[91], line 5 3 test_input = {"messages": [HumanMessage(content="...")]} ----> 4 result = await graph.ainvoke(test_input)
File ...\Lib\site-packages\langgraph\pregel_init_.py:1604, in Pregel.ainvoke(self, input, config, stream_mode, output_keys, interrupt_before, interrupt_after, debug, **kwargs) 1602 else: 1603 chunks = [] -> 1604 async for chunk in self.astream( 1605 input, 1606 config, 1607 stream_mode=stream_mode, 1608 output_keys=output_keys, 1609 interrupt_before=interrupt_before, 1610 interrupt_after=interrupt_after, 1611 debug=debug, 1612 **kwargs, 1613 ): 1614 if stream_mode == "values": 1615 latest = chunk ... ---> 96 state["messages"].append('\n---\n---\n'.join(rules_list) if rules_list else 'No Rules.')
TypeError: sequence item 1: expected str instance, NoneType found
and this is my updated code:
#... if (self.is_python_list(response.content)): logger.info("Valid answer.") rules_list = await self.retrieve_rules('./rules', self.parse_response_content(response.content)) else: logger.warning("Wrong answer.") rules_list = []
logger.info(f"RulesFinder Rules Found: {rules_list}") state["messages"].append('\n---\n---\n'.join(rules_list) if rules_list else 'No rules.')#...
and the terminal output was: 2024-10-21 12:02:01,241 - INFO - Valid answer. 2024-10-21 12:02:01,260 - INFO - RulesFinder Rules Found: ['...']
- Assistant
The error message you're encountering indicates that during the execution of your updated code, a
NoneTypevalue was found when Python was expecting a string. This is causing theTypeErrorwhen trying to join elements ofrules_listusing'\n---\n---\n'.join(rules_list).