From 7c574fb34f71721d1dcbe9cfebaad48b610d8d9e Mon Sep 17 00:00:00 2001 From: Lance Martin Date: Tue, 17 Sep 2024 15:36:55 -0700 Subject: [PATCH] Remove docstrings from nodes --- src/enrichment_agent/graph.py | 74 ----------------------------------- 1 file changed, 74 deletions(-) diff --git a/src/enrichment_agent/graph.py b/src/enrichment_agent/graph.py index 099e81c..cbefe5d 100644 --- a/src/enrichment_agent/graph.py +++ b/src/enrichment_agent/graph.py @@ -31,21 +31,6 @@ async def call_agent_model( 3. Initializes and configures the LLM with available tools. 4. Invokes the LLM and processes its response. 5. Handles the LLM's decision to either continue research or submit final info. - - Args: - state (State): The current state of the research process, including topic and extraction schema. - config (Optional[RunnableConfig]): Configuration for the LLM, if provided. - - Returns: - Dict[str, Any]: A dictionary containing: - - 'messages': List of response messages from the LLM. - - 'info': Extracted information if the LLM decided to submit final info, else None. - - 'loop_step': Incremented step count for the research loop. - - Note: - - The function uses three tools: scrape_website, search, and a dynamic 'Info' tool. - - If the LLM calls the 'Info' tool, it's considered as submitting the final answer. - - If the LLM doesn't call any tool, a prompt to use a tool is appended to the messages. """ # Load configuration from the provided RunnableConfig configuration = Configuration.from_runnable_config(config) @@ -121,24 +106,6 @@ async def reflect( 4. Initializes and configures a language model with structured output. 5. Invokes the model to assess the quality of the gathered information. 6. Processes the model's response and determines if the info is satisfactory. - - Args: - state (State): The current state of the research process, including topic, - extraction schema, and gathered information. - config (Optional[RunnableConfig]): Configuration for the language model, if provided. - - Returns: - Dict[str, Any]: A dictionary containing either: - - 'info': The presumed info if it's deemed satisfactory. - - 'messages': A list with a ToolMessage indicating an error or unsatisfactory result. - - Raises: - ValueError: If the last message in the state is not an AIMessage with tool calls. - - Note: - - This function acts as a quality check for the information gathered by the agent. - - It uses a separate language model invocation to critique the gathered info. - - The function can either approve the gathered info or request further research. """ p = prompts.MAIN_PROMPT.format( info=json.dumps(state.extraction_schema, indent=2), topic=state.topic @@ -202,24 +169,6 @@ def route_after_agent( 1. Error recovery: If the last message is unexpectedly not an AIMessage. 2. Info submission: If the agent has called the "Info" tool to submit findings. 3. Continued research: If the agent has called any other tool. - - Args: - state (State): The current state of the research process, including - the message history. - - Returns: - Literal["reflect", "tools", "call_agent_model", "__end__"]: - - "reflect": If the agent has submitted info for review. - - "tools": If the agent has called a tool other than "Info". - - "call_agent_model": If an unexpected message type is encountered. - - Note: - - The function assumes that normally, the last message should be an AIMessage. - - The "Info" tool call indicates that the agent believes it has gathered - sufficient information to answer the query. - - Any other tool call indicates that the agent needs to continue research. - - The error recovery path (returning "call_agent_model" for non-AIMessages) - serves as a safeguard against unexpected states. """ last_message = state.messages[-1] @@ -242,29 +191,6 @@ def route_after_checker( This function determines whether to continue the research process or end it based on the checker's evaluation and the current state of the research. - - Args: - state (State): The current state of the research process, including - the message history, info gathered, and loop step count. - config (RunnableConfig): Configuration object containing settings like - the maximum number of allowed loops. - - Returns: - Literal["__end__", "call_agent_model"]: - - "__end__": If the research process should terminate. - - "call_agent_model": If further research is needed. - - The function makes decisions based on the following criteria: - 1. If the maximum number of loops has been reached, it ends the process. - 2. If no info has been gathered yet, it continues the research. - 3. If the last message indicates an error or unsatisfactory result, it continues the research. - 4. If none of the above conditions are met, it assumes the result is satisfactory and ends the process. - - Note: - - The function relies on a Configuration object derived from the RunnableConfig. - - It checks the loop_step against max_loops to prevent infinite loops. - - The presence of info and its quality (determined by the checker) influence the decision. - - An error status in the last message triggers additional research. """ configurable = Configuration.from_runnable_config(config) last_message = state.messages