readme and demo
Browse filesFiles changed (6)
- AutoGPTFlow.py+115-2
- README.md+158-12
- __init__.py+3-3
- AutoGPT.yaml → demo.yamlRenamed+7
- pip_requirements.txt+8-1
- run.py+16-11
11 unmodified lines121314151617181 unmodified line20212223242527 unmodified lines535455565758593 unmodified lines6364656667686970717273744 unmodified lines7980818283847 unmodified lines92939495969711 unmodified linesfrom flow_modules.aiflows.VectorStoreFlowModule import ChromaDBFlowclass AutoGPTFlow(CircularFlow):def _on_reach_max_round(self):self._state_update_dict({"answer": "The maximum amount of rounds was reached before the model found an answer.","status": "unfinished"1 unmodified line@staticmethoddef _get_memory_key(flow_state):goal = flow_state.get("goal")last_command = flow_state.get("command")last_command_args = flow_state.get("command_args")27 unmodified lines@CircularFlow.input_msg_payload_builderdef prepare_memory_read_input(self, flow_state: Dict[str, Any], dst_flow: ChromaDBFlow) -> Dict[str, Any]:"""A (very) basic example implementation of how the memory retrieval could be constructed."""query = self._get_memory_key(flow_state)return {3 unmodified lines@CircularFlow.output_msg_payload_processordef prepare_memory_read_output(self, output_payload: Dict[str, Any], src_flow: ControllerAtomicFlow):retrieved_memories = output_payload["retrieved"][0][1:]return {"memory": "\n".join(retrieved_memories)}@CircularFlow.input_msg_payload_builderdef prepare_memory_write_input(self, flow_state: Dict[str, Any], dst_flow: ChromaDBFlow) -> Dict[str, Any]:"""An (very) example (not optimized) implementation of how the memory population could be implemented."""query = self._get_memory_key(flow_state)return {4 unmodified lines@CircularFlow.output_msg_payload_processordef detect_finish_or_continue(self, output_payload: Dict[str, Any], src_flow: ControllerAtomicFlow) -> Dict[str, Any]:command = output_payload["command"]if command == "finish":return {7 unmodified lines@CircularFlow.output_msg_payload_processordef detect_finish_in_human_input(self, output_payload: Dict[str, Any], src_flow: ControllerAtomicFlow) -> Dict[str, Any]:human_feedback = output_payload["human_input"]if human_feedback.strip().lower() == "q":return {11 unmodified lines121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677781 unmodified line8081828384858687888990919227 unmodified lines1201211221231241251261271281291301311321331341353 unmodified lines1391401411421431441451461471481491501511521531541551561571581591601611621631641651661671684 unmodified lines1731741751761771781791801811821831841851861877 unmodified lines19519619719819920020120220320420520620720820921011 unmodified linesfrom flow_modules.aiflows.VectorStoreFlowModule import ChromaDBFlowclass AutoGPTFlow(CircularFlow):""" This class implements a (very basic) AutoGPT flow. It is a flow that consists of multiple sub-flows that are executed circularly. It Contains the following subflows:- A Controller Flow: A Flow that controls which subflow of the Executor Flow to execute next.- A Memory Flow: A Flow used to save and retrieve messages or memories which might be useful for the Controller Flow.- A HumanFeedback Flow: A flow use to get feedback from the user/human.- A Executor Flow: A Flow that executes commands generated by the Controller Flow. Typically it's a branching flow (see BranchingFlow) and the commands are which branch to execute next.An illustration of the flow is as follows:| -------> Memory Flow -------> Controller Flow ------->|^ || || v| <----- HumanFeedback Flow <------- Executor Flow <----|*Configuration Parameters*:- `name` (str): The name of the flow. Default is "AutoGPTFlow".- `description` (str): A description of the flow. Default is "An example implementation of AutoGPT with Flows."- `max_rounds` (int): The maximum number of rounds the circular flow can run for. Default is 30.- `early_exit_key` (str): The key that is used to terminate the flow early. Default is "EARLY_EXIT".- `subflows_config` (Dict[str,Any]): A dictionary of subflows configurations. Default:- `Controller` (Dict[str,Any]): The configuration of the Controller Flow. By default the controller flow is a ControllerAtomicFlow (see ControllerExecutorFlowModule). It's default values aredefined in ControllerAtomicFlow.yaml of the ControllerExecutorFlowModule. Except for the following parameters who are overwritten by the AutoGPTFlow in AutoGPTFlow.yaml:- `finish` (Dict[str,Any]): The configuration of the finish command (used to terminate the flow early when the controller has accomplished its goal).- `description` (str): The description of the command. Default is "The finish command is used to terminate the flow early when the controller has accomplished its goal."- `input_args` (List[str]): The list of expected keys to run the finish command. Default is ["answer"].- `human_message_prompt_template`(Dict[str,Any]): The prompt template used to generate the message that is shown to the user/human when the finish command is executed. Default is:- `template` (str): The template of the humand message prompt (see AutoGPTFlow.yaml for default template)- `input_variables` (List[str]): The list of variables to be included in the template. Default is ["observation", "human_feedback", "memory"].- `ìnput_interface_initialized` (List[str]): The input interface that Controller Flow expects except for the first time in the flow. Default is ["observation", "human_feedback", "memory"].- `Executor` (Dict[str,Any]): The configuration of the Executor Flow. By default the executor flow is a Branching Flow (see BranchingFlow). It's default values are the default values of the BranchingFlow. Fields to define:- `subflows_config` (Dict[str,Any]): A Dictionary of subflows configurations.The keys are the names of the subflows and the values are the configurations of the subflows. Each subflow is a branch of the branching flow.- `HumanFeedback` (Dict[str,Any]): The configuration of the HumanFeedback Flow. By default the human feedback flow is a HumanStandardInputFlow (see HumanStandardInputFlowModule ).It's default values are specified in the REAMDE.md of HumanStandardInputFlowModule. Except for the following parameters who are overwritten by the AutoGPTFlow in AutoGPTFlow.yaml:- `request_multi_line_input_flag` (bool): Flag to request multi-line input. Default is False.- `query_message_prompt_template` (Dict[str,Any]): The prompt template presented to the user/human to request input. Default is:- `template` (str): The template of the query message prompt (see AutoGPTFlow.yaml for default template)- `input_variables` (List[str]): The list of variables to be included in the template. Default is ["goal","command","command_args",observation"]- input_interface_initialized (List[str]): The input interface that HumanFeeback Flow expects except for the first time in the flow. Default is ["goal","command","command_args",observation"]- `Memory` (Dict[str,Any]): The configuration of the Memory Flow. By default the memory flow is a ChromaDBFlow (see VectorStoreFlowModule). It's default values are defined in ChromaDBFlow.yaml of the VectorStoreFlowModule. Except for the following parameters who are overwritten by the AutoGPTFlow in AutoGPTFlow.yaml:- `n_results`: The number of results to retrieve from the memory. Default is 2.- `topology` (List[Dict[str,Any]]): The topology of the flow which is "circular". By default, the topology is the one shown in the illustration above (the topology is also described in AutoGPTFlow.yaml).*Input Interface*:- `goal` (str): The goal of the flow.*Output Interface*:- `answer` (str): The answer of the flow.- `status` (str): The status of the flow. It can be "finished" or "unfinished".:param flow_config: The configuration of the flow. Contains the parameters described above and the parameters required by the parent class (CircularFlow).:type flow_config: Dict[str,Any]:param subflows: A list of subflows constituating the circular flow. Required when instantiating the subflow programmatically (it replaces subflows_config from flow_config).:type subflows: List[Flow]"""def _on_reach_max_round(self):""" This method is called when the flow reaches the max_rounds."""self._state_update_dict({"answer": "The maximum amount of rounds was reached before the model found an answer.","status": "unfinished"1 unmodified line@staticmethoddef _get_memory_key(flow_state):""" This method returns the memory key that is used to retrieve memories from the ChromaDB model.:param flow_state: The state of the flow:type flow_state: Dict[str, Any]:return: The current context:rtype: str"""goal = flow_state.get("goal")last_command = flow_state.get("command")last_command_args = flow_state.get("command_args")27 unmodified lines@CircularFlow.input_msg_payload_builderdef prepare_memory_read_input(self, flow_state: Dict[str, Any], dst_flow: ChromaDBFlow) -> Dict[str, Any]:""" This method prepares the input for the Memory Flow. It is called before the Memory Flow is called.A (very) basic example implementation of how the memory retrieval could be constructed.:param flow_state: The state of the flow:type flow_state: Dict[str, Any]:param dst_flow: The destination flow:type dst_flow: Flow:return: The input message for the Memory Flow:rtype: Dict[str, Any]"""query = self._get_memory_key(flow_state)return {3 unmodified lines@CircularFlow.output_msg_payload_processordef prepare_memory_read_output(self, output_payload: Dict[str, Any], src_flow: ControllerAtomicFlow):""" This method processes the output of the Memory Flow. It is called after the Memory Flow is called.:param output_payload: The output payload of the Memory Flow:type output_payload: Dict[str, Any]:param src_flow: The source flow:type src_flow: Flow:return: The processed output payload:rtype: Dict[str, Any]"""retrieved_memories = output_payload["retrieved"][0][1:]return {"memory": "\n".join(retrieved_memories)}@CircularFlow.input_msg_payload_builderdef prepare_memory_write_input(self, flow_state: Dict[str, Any], dst_flow: ChromaDBFlow) -> Dict[str, Any]:""" This method prepares the input for the Memory Flow. It is called before the Memory Flow is called.A (very) basic example implementation of how the memory population could be constructed.:param flow_state: The state of the flow:type flow_state: Dict[str, Any]:param dst_flow: The destination flow:type dst_flow: Flow:return: The input message to write the Memory Flow:rtype: Dict[str, Any]"""""query = self._get_memory_key(flow_state)return {4 unmodified lines@CircularFlow.output_msg_payload_processordef detect_finish_or_continue(self, output_payload: Dict[str, Any], src_flow: ControllerAtomicFlow) -> Dict[str, Any]:""" This method detects whether the Controller flow has generated a "finish" command or not to terminate the flow. . It is called after the Controller Flow is called.:param output_payload: The output payload of the Controller Flow:type output_payload: Dict[str, Any]:param src_flow: The source flow:type src_flow: Flow:return: The processed output payload:rtype: Dict[str, Any]"""command = output_payload["command"]if command == "finish":return {7 unmodified lines@CircularFlow.output_msg_payload_processordef detect_finish_in_human_input(self, output_payload: Dict[str, Any], src_flow: ControllerAtomicFlow) -> Dict[str, Any]:""" This method detects whether the HumanFeedback (the human/user) flow has generated a "finish" command or not to terminate the flow. It is called after the HumanFeedback Flow is called.:param output_payload: The output payload of the HumanFeedback Flow:type output_payload: Dict[str, Any]:param src_flow: The source flow:type src_flow: Flow:return: The processed output payload:rtype: Dict[str, Any]"""human_feedback = output_payload["human_input"]if human_feedback.strip().lower() == "q":return {
1234567891011121314151617181920212223242526---license: mit---ToDo:## Description< Flow description >## Configuration parameters< Name 1 > (< Type 1 >): < Description 1 >. Required parameter.< Name 2 > (< Type 2 >): < Description 2 >. Default value is: < value 2 >## Input interface< Name 1 > (< Type 1 >): < Description 1 >.(Note that the interface might depend on the state of the Flow.)## Output interface< Name 1 > (< Type 1 >): < Description 1 >.(Note that the interface might depend on the state of the Flow.)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172---license: mit---# Table of Contents* [AutoGPTFlow](#AutoGPTFlow)* [AutoGPTFlow](#AutoGPTFlow.AutoGPTFlow)* [prepare\_memory\_read\_input](#AutoGPTFlow.AutoGPTFlow.prepare_memory_read_input)* [prepare\_memory\_read\_output](#AutoGPTFlow.AutoGPTFlow.prepare_memory_read_output)* [detect\_finish\_or\_continue](#AutoGPTFlow.AutoGPTFlow.detect_finish_or_continue)* [detect\_finish\_in\_human\_input](#AutoGPTFlow.AutoGPTFlow.detect_finish_in_human_input)<a id="AutoGPTFlow"></a># AutoGPTFlow<a id="AutoGPTFlow.AutoGPTFlow"></a>## AutoGPTFlow Objects```pythonclass AutoGPTFlow(CircularFlow)```This class implements a (very basic) AutoGPT flow. It is a flow that consists of multiple sub-flows that are executed circularly. It Contains the following subflows:- A Controller Flow: A Flow that controls which subflow of the Executor Flow to execute next.- A Memory Flow: A Flow used to save and retrieve messages or memories which might be useful for the Controller Flow.- A HumanFeedback Flow: A flow use to get feedback from the user/human.- A Executor Flow: A Flow that executes commands generated by the Controller Flow. Typically it's a branching flow (see BranchingFlow) and the commands are which branch to execute next.An illustration of the flow is as follows:| -------> Memory Flow -------> Controller Flow ------->|^ || || v| <----- HumanFeedback Flow <------- Executor Flow <----|*Configuration Parameters*:- `name` (str): The name of the flow. Default is "AutoGPTFlow".- `description` (str): A description of the flow. Default is "An example implementation of AutoGPT with Flows."- `max_rounds` (int): The maximum number of rounds the circular flow can run for. Default is 30.- `early_exit_key` (str): The key that is used to terminate the flow early. Default is "EARLY_EXIT".- `subflows_config` (Dict[str,Any]): A dictionary of subflows configurations. Default:- `Controller` (Dict[str,Any]): The configuration of the Controller Flow. By default the controller flow is a ControllerAtomicFlow (see ControllerExecutorFlowModule). It's default values aredefined in ControllerAtomicFlow.yaml of the ControllerExecutorFlowModule. Except for the following parameters who are overwritten by the AutoGPTFlow in AutoGPTFlow.yaml:- `finish` (Dict[str,Any]): The configuration of the finish command (used to terminate the flow early when the controller has accomplished its goal).- `description` (str): The description of the command. Default is "The finish command is used to terminate the flow early when the controller has accomplished its goal."- `input_args` (List[str]): The list of expected keys to run the finish command. Default is ["answer"].- `human_message_prompt_template`(Dict[str,Any]): The prompt template used to generate the message that is shown to the user/human when the finish command is executed. Default is:- `template` (str): The template of the humand message prompt (see AutoGPTFlow.yaml for default template)- `input_variables` (List[str]): The list of variables to be included in the template. Default is ["observation", "human_feedback", "memory"].- `ìnput_interface_initialized` (List[str]): The input interface that Controller Flow expects except for the first time in the flow. Default is ["observation", "human_feedback", "memory"].- `Executor` (Dict[str,Any]): The configuration of the Executor Flow. By default the executor flow is a Branching Flow (see BranchingFlow). It's default values are the default values of the BranchingFlow. Fields to define:- `subflows_config` (Dict[str,Any]): A Dictionary of subflows configurations.The keys are the names of the subflows and the values are the configurations of the subflows. Each subflow is a branch of the branching flow.- `HumanFeedback` (Dict[str,Any]): The configuration of the HumanFeedback Flow. By default the human feedback flow is a HumanStandardInputFlow (see HumanStandardInputFlowModule ).It's default values are specified in the REAMDE.md of HumanStandardInputFlowModule. Except for the following parameters who are overwritten by the AutoGPTFlow in AutoGPTFlow.yaml:- `request_multi_line_input_flag` (bool): Flag to request multi-line input. Default is False.- `query_message_prompt_template` (Dict[str,Any]): The prompt template presented to the user/human to request input. Default is:- `template` (str): The template of the query message prompt (see AutoGPTFlow.yaml for default template)- `input_variables` (List[str]): The list of variables to be included in the template. Default is ["goal","command","command_args",observation"]- input_interface_initialized (List[str]): The input interface that HumanFeeback Flow expects except for the first time in the flow. Default is ["goal","command","command_args",observation"]- `Memory` (Dict[str,Any]): The configuration of the Memory Flow. By default the memory flow is a ChromaDBFlow (see VectorStoreFlowModule). It's default values are defined in ChromaDBFlow.yaml of the VectorStoreFlowModule. Except for the following parameters who are overwritten by the AutoGPTFlow in AutoGPTFlow.yaml:- `n_results`: The number of results to retrieve from the memory. Default is 2.- `topology` (List[Dict[str,Any]]): The topology of the flow which is "circular". By default, the topology is the one shown in the illustration above (the topology is also described in AutoGPTFlow.yaml).*Input Interface*:- `goal` (str): The goal of the flow.*Output Interface*:- `answer` (str): The answer of the flow.- `status` (str): The status of the flow. It can be "finished" or "unfinished".**Arguments**:- `flow_config` (`Dict[str,Any]`): The configuration of the flow. Contains the parameters described above and the parameters required by the parent class (CircularFlow).- `subflows` (`List[Flow]`): A list of subflows constituating the circular flow. Required when instantiating the subflow programmatically (it replaces subflows_config from flow_config).<a id="AutoGPTFlow.AutoGPTFlow.prepare_memory_read_input"></a>#### prepare\_memory\_read\_input```python@CircularFlow.input_msg_payload_builderdef prepare_memory_read_input(flow_state: Dict[str, Any],dst_flow: ChromaDBFlow) -> Dict[str, Any]```This method prepares the input for the Memory Flow. It is called before the Memory Flow is called.A (very) basic example implementation of how the memory retrieval could be constructed.**Arguments**:- `flow_state` (`Dict[str, Any]`): The state of the flow- `dst_flow` (`Flow`): The destination flow**Returns**:`Dict[str, Any]`: The input message for the Memory Flow<a id="AutoGPTFlow.AutoGPTFlow.prepare_memory_read_output"></a>#### prepare\_memory\_read\_output```python@CircularFlow.output_msg_payload_processordef prepare_memory_read_output(output_payload: Dict[str, Any],src_flow: ControllerAtomicFlow)```This method processes the output of the Memory Flow. It is called after the Memory Flow is called.**Arguments**:- `output_payload` (`Dict[str, Any]`): The output payload of the Memory Flow- `src_flow` (`Flow`): The source flow**Returns**:`Dict[str, Any]`: The processed output payload<a id="AutoGPTFlow.AutoGPTFlow.detect_finish_or_continue"></a>#### detect\_finish\_or\_continue```python@CircularFlow.output_msg_payload_processordef detect_finish_or_continue(output_payload: Dict[str, Any],src_flow: ControllerAtomicFlow) -> Dict[str, Any]```This method detects whether the Controller flow has generated a "finish" command or not to terminate the flow. . It is called after the Controller Flow is called.**Arguments**:- `output_payload` (`Dict[str, Any]`): The output payload of the Controller Flow- `src_flow` (`Flow`): The source flow**Returns**:`Dict[str, Any]`: The processed output payload<a id="AutoGPTFlow.AutoGPTFlow.detect_finish_in_human_input"></a>#### detect\_finish\_in\_human\_input```python@CircularFlow.output_msg_payload_processordef detect_finish_in_human_input(output_payload: Dict[str, Any],src_flow: ControllerAtomicFlow) -> Dict[str, Any]```This method detects whether the HumanFeedback (the human/user) flow has generated a "finish" command or not to terminate the flow. It is called after the HumanFeedback Flow is called.**Arguments**:- `output_payload` (`Dict[str, Any]`): The output payload of the HumanFeedback Flow- `src_flow` (`Flow`): The source flow**Returns**:`Dict[str, Any]`: The processed output payload
1234567891011# ~~~ Specify the dependencies ~~~dependencies = [{"url": "aiflows/ControllerExecutorFlowModule","revision": "263bf393e165f42d3bc9792976b37c4cf221dd81"},{"url": "aiflows/HumanStandardInputFlowModule","revision": "a690582584ff5345fe768e41558959a7e99bbeee"},{"url": "aiflows/VectorStoreFlowModule","revision": "46d070566496a31ead631ef3f8e8ea2cd5f098f2"},]from flows import flow_verse1234567891011# ~~~ Specify the dependencies ~~~dependencies = [{"url": "aiflows/ControllerExecutorFlowModule","revision": "09cda9615e5c48ae18e2c1244519ed7321145187"},{"url": "aiflows/HumanStandardInputFlowModule","revision": "5683a922372c5fa90be9f6447d6662d8d80341fc"},{"url": "aiflows/VectorStoreFlowModule","revision": "692f5d1b55936d813d4f41e8b0ec11754c7da9ac"},]from flows import flow_verse
15 unmodified lines16171819202116 unmodified lines38394015 unmodified linesfinish:description: "Signal that the objective has been satisfied, and returns the answer to the user."input_args: [ "answer" ]human_message_prompt_template:template: |2-Here is the response to your last action:16 unmodified lines_target_: aiflows.LCToolFlowModule.LCToolFlow.instantiate_from_default_configbackend:_target_: langchain.tools.DuckDuckGoSearchRun15 unmodified lines161718192021222316 unmodified lines404142434445464715 unmodified linesfinish:description: "Signal that the objective has been satisfied, and returns the answer to the user."input_args: [ "answer" ]backend:api_infos: ???human_message_prompt_template:template: |2-Here is the response to your last action:16 unmodified lines_target_: aiflows.LCToolFlowModule.LCToolFlow.instantiate_from_default_configbackend:_target_: langchain.tools.DuckDuckGoSearchRunMemory:backend:api_infos: ???
1duckduckgo-search==3.9.212345678# LCToolFLowModule dependency. Needed if you want to run the demoduckduckgo-search==3.9.6# ControllerExecutorFlowModule dependency. Needed if you want to run the demowikipedia==1.4.0# VectorStore FlowModule dependencies. Needed if you want to run the demolangchain==0.0.336chromadb==0.3.29faiss-cpu==1.7.4
2 unmodified lines34567896 unmodified lines1617181920212223242526272829303132333435363738394041424344454647481 unmodified line505152535455566 unmodified lines636465666768692 unmodified linesimport hydraimport flowsfrom flows.flow_launchers import FlowLauncher, ApiInfofrom flows.utils.general_helpers import read_yaml_filefrom flows import logging6 unmodified linesdependencies = [{"url": "aiflows/AutoGPTFlowModule", "revision": os.getcwd()},{"url": "aiflows/LCToolFlowModule", "revision": "46dd24ecc3dc4f4f0191e57c202cc7d20e8e7782"},]from flows import flow_verseflow_verse.sync_dependencies(dependencies)if __name__ == "__main__":# ~~~ Set the API information ~~~# OpenAI backend# api_information = ApiInfo("openai", os.getenv("OPENAI_API_KEY"))# Azure backendapi_information = ApiInfo("azure", os.getenv("AZURE_OPENAI_KEY"), os.getenv("AZURE_OPENAI_ENDPOINT"))root_dir = "."cfg_path = os.path.join(root_dir, "AutoGPT.yaml")cfg = read_yaml_file(cfg_path)# ~~~ Instantiate the Flow ~~~flow_with_interfaces = {"flow": hydra.utils.instantiate(cfg['flow'], _recursive_=False, _convert_="partial"),"input_interface": (Noneif getattr(cfg, "input_interface", None) is Noneelse hydra.utils.instantiate(cfg['input_interface'], _recursive_=False)),"output_interface": (Noneif getattr(cfg, "output_interface", None) is Noneelse hydra.utils.instantiate(cfg['output_interface'], _recursive_=False)),}1 unmodified line# ~~~ Get the data ~~~# data = {"id": 0, "goal": "Answer the following question: What is the population of Canada?"} # Uses wikipedia# data = {"id": 0, "goal": "Answer the following question: Who was the NBA champion in 2023?"} # Uses duckduckgodata = {"id": 0, "goal": "Answer the following question: What is the date of birth of Michael Jordan?"}# At first, we retrieve information about Michael Jordan the basketball player# If we provide feedback, only in the first round, that we are not interested in the basketball player,# but the statistician, and skip the feedback in the next rounds, we get the correct answer6 unmodified linesflow_with_interfaces=flow_with_interfaces,data=data,path_to_output_file=path_to_output_file,api_information=api_information,)# ~~~ Print the output ~~~2 unmodified lines3456789106 unmodified lines17181920212223242526272829303132333435363738394041424344454647484950515253541 unmodified line565758596061626 unmodified lines6970717273742 unmodified linesimport hydraimport flowsfrom flows.flow_launchers import FlowLauncherfrom flows.backends.api_info import ApiInfofrom flows.utils.general_helpers import read_yaml_filefrom flows import logging6 unmodified linesdependencies = [{"url": "aiflows/AutoGPTFlowModule", "revision": os.getcwd()},{"url": "aiflows/LCToolFlowModule", "revision": "f1020b23fe2a1ab6157c3faaf5b91b5cdaf02c1b"},]from flows import flow_verseflow_verse.sync_dependencies(dependencies)if __name__ == "__main__":# ~~~ Set the API information ~~~# OpenAI backendapi_information = [ApiInfo(backend_used="openai",api_key = os.getenv("OPENAI_API_KEY"))]# Azure backend# api_information = ApiInfo(backend_used = "azure",# api_base = os.getenv("AZURE_API_BASE"),# api_key = os.getenv("AZURE_OPENAI_KEY"),# api_version = os.getenv("AZURE_API_VERSION") )root_dir = "."cfg_path = os.path.join(root_dir, "demo.yaml")cfg = read_yaml_file(cfg_path)cfg["flow"]["subflows_config"]["Controller"]["backend"]["api_infos"] = api_informationcfg["flow"]["subflows_config"]["Memory"]["backend"]["api_infos"] = api_information# ~~~ Instantiate the Flow ~~~flow_with_interfaces = {"flow": hydra.utils.instantiate(cfg['flow'], _recursive_=False, _convert_="partial"),"input_interface": (Noneif cfg.get( "input_interface", None) is Noneelse hydra.utils.instantiate(cfg['input_interface'], _recursive_=False)),"output_interface": (Noneif cfg.get( "output_interface", None) is Noneelse hydra.utils.instantiate(cfg['output_interface'], _recursive_=False)),}1 unmodified line# ~~~ Get the data ~~~# data = {"id": 0, "goal": "Answer the following question: What is the population of Canada?"} # Uses wikipedia# data = {"id": 0, "goal": "Answer the following question: Who was the NBA champion in 2023?"} # Uses duckduckgodata = {"id": 0, "goal": "Answer the following question: What is the profession and date of birth of Michael Jordan?"}# At first, we retrieve information about Michael Jordan the basketball player# If we provide feedback, only in the first round, that we are not interested in the basketball player,# but the statistician, and skip the feedback in the next rounds, we get the correct answer6 unmodified linesflow_with_interfaces=flow_with_interfaces,data=data,path_to_output_file=path_to_output_file,)# ~~~ Print the output ~~~
AutoGPTFlow.py+115-2
README.md+158-12
__init__.py+3-3
AutoGPT.yaml → demo.yamlRenamed+7
pip_requirements.txt+8-1
run.py+16-11