renamed flows to aiflows
Browse filesFiles changed (5)
- ChatAtomicFlow.py+12-12
- ChatAtomicFlow.yaml+5-5
- README.md+7-7
- demo.yaml+7-7
- run.py+7-7
4 unmodified lines5678910111213141516171815 unmodified lines343536373839409 unmodified lines50515253545556575859606162636422 unmodified lines878889909192934 unmodified linesfrom typing import Dict, Optional, Anyfrom flows.base_flows import AtomicFlowfrom flows.utils import loggingfrom flows.messages.flow_message import UpdateMessage_ChatMessagefrom flows.prompt_template import JinjaPromptfrom flows.backends.llm_lite import LiteLLMBackendlog = logging.get_logger(__name__)15 unmodified lines- `assistant_name` (str): The name of the assistant (roles of LLM). Default: "assistant"- `backend` Dict[str,Any]: The backend of the flow. Used to call models via an API.See litellm's supported models and APIs here: https://docs.litellm.ai/docs/providers.The default parameters of the backend are all defined at flows.backends.llm_lite.LiteLLMBackend(also see the defaul parameters of litellm's completion parameters: https://docs.litellm.ai/docs/completion/input#input-params-1).Except for the following parameters who are overwritten by the ChatAtomicFlow in ChatAtomicFlow.yaml:- `model_name` (Union[Dict[str,str],str]): The name of the model to use.9 unmodified lines- `presence_penalty` (number): It is used to penalize new tokens based on their existence in the text so far. Default: 0.0- `stream` (bool): Whether to stream the response or not. Default: True- `system_message_prompt_template` (Dict[str,Any]): The template of the system message. It is used to generate the system message.By default its of type flows.prompt_template.JinjaPrompt.None of the parameters of the prompt are defined by default and therefore need to be defined if one wants to use the system prompt.Default parameters are defined in flows.prompt_template.jinja2_prompts.JinjaPrompt.- `init_human_message_prompt_template` (Dict[str,Any]): The prompt template of the human/user message used to initialize the conversation(first time in). It is used to generate the human message. It's passed as the user message to the LLM.By default its of type flows.prompt_template.JinjaPrompt. None of the parameters of the prompt are defined by default and therefore need to be defined if onewants to use the init_human_message_prompt_template. Default parameters are defined in flows.prompt_template.jinja2_prompts.JinjaPrompt.- `human_message_prompt_template` (Dict[str,Any]): The prompt template of the human/user message (message used everytime the except the first time in).It's passed as the user message to the LLM. By default its of type flows.prompt_template.JinjaPrompt and has the following parameters:- `template` (str): The template of the human message. Default: see ChatAtomicFlow.yaml for the default value.- `input_variables` (List[str]): The input variables of the human message prompt template. Default: ["query"]- `previous_messages` (Dict[str,Any]): Defines which previous messages to include in the input of the LLM. Note that if `first_k`and `last_k` are both none,22 unmodified lines:type init_human_message_prompt_template: Optional[JinjaPrompt]:param backend: The backend of the flow. It is a LLM that is queried via an API. See litellm's supported models and APIs here: https://docs.litellm.ai/docs/providers:type backend: LiteLLMBackend:param \**kwargs: Additional arguments to pass to the flow. See :class:`flows.base_flows.AtomicFlow` for more details."""REQUIRED_KEYS_CONFIG = ["backend"]4 unmodified lines5678910111213141516171815 unmodified lines343536373839409 unmodified lines50515253545556575859606162636422 unmodified lines878889909192934 unmodified linesfrom typing import Dict, Optional, Anyfrom aiflows.base_flows import AtomicFlowfrom aiflows.utils import loggingfrom aiflows.messages.flow_message import UpdateMessage_ChatMessagefrom aiflows.prompt_template import JinjaPromptfrom aiflows.backends.llm_lite import LiteLLMBackendlog = logging.get_logger(__name__)15 unmodified lines- `assistant_name` (str): The name of the assistant (roles of LLM). Default: "assistant"- `backend` Dict[str,Any]: The backend of the flow. Used to call models via an API.See litellm's supported models and APIs here: https://docs.litellm.ai/docs/providers.The default parameters of the backend are all defined at aiflows.backends.llm_lite.LiteLLMBackend(also see the defaul parameters of litellm's completion parameters: https://docs.litellm.ai/docs/completion/input#input-params-1).Except for the following parameters who are overwritten by the ChatAtomicFlow in ChatAtomicFlow.yaml:- `model_name` (Union[Dict[str,str],str]): The name of the model to use.9 unmodified lines- `presence_penalty` (number): It is used to penalize new tokens based on their existence in the text so far. Default: 0.0- `stream` (bool): Whether to stream the response or not. Default: True- `system_message_prompt_template` (Dict[str,Any]): The template of the system message. It is used to generate the system message.By default its of type aiflows.prompt_template.JinjaPrompt.None of the parameters of the prompt are defined by default and therefore need to be defined if one wants to use the system prompt.Default parameters are defined in aiflows.prompt_template.jinja2_prompts.JinjaPrompt.- `init_human_message_prompt_template` (Dict[str,Any]): The prompt template of the human/user message used to initialize the conversation(first time in). It is used to generate the human message. It's passed as the user message to the LLM.By default its of type aiflows.prompt_template.JinjaPrompt. None of the parameters of the prompt are defined by default and therefore need to be defined if onewants to use the init_human_message_prompt_template. Default parameters are defined in aiflows.prompt_template.jinja2_prompts.JinjaPrompt.- `human_message_prompt_template` (Dict[str,Any]): The prompt template of the human/user message (message used everytime the except the first time in).It's passed as the user message to the LLM. By default its of type aiflows.prompt_template.JinjaPrompt and has the following parameters:- `template` (str): The template of the human message. Default: see ChatAtomicFlow.yaml for the default value.- `input_variables` (List[str]): The input variables of the human message prompt template. Default: ["query"]- `previous_messages` (Dict[str,Any]): Defines which previous messages to include in the input of the LLM. Note that if `first_k`and `last_k` are both none,22 unmodified lines:type init_human_message_prompt_template: Optional[JinjaPrompt]:param backend: The backend of the flow. It is a LLM that is queried via an API. See litellm's supported models and APIs here: https://docs.litellm.ai/docs/providers:type backend: LiteLLMBackend:param \**kwargs: Additional arguments to pass to the flow. See :class:`aiflows.base_flows.AtomicFlow` for more details."""REQUIRED_KEYS_CONFIG = ["backend"]
10 unmodified lines111213141516178 unmodified lines26272829303132333435363738391 unmodified line4142434445464710 unmodified linesassistant_name: assistantbackend:_target_: flows.backends.llm_lite.LiteLLMBackendapi_infos: ???model_name: "gpt-3.5-turbo"n: 18 unmodified linessystem_message_prompt_template:_target_: flows.prompt_template.JinjaPromptinit_human_message_prompt_template:_target_: flows.prompt_template.JinjaPrompthuman_message_prompt_template:_target_: flows.prompt_template.JinjaPrompttemplate: "{{query}}"input_variables:- "query"1 unmodified line- "query"query_message_prompt_template:_target_: flows.prompt_template.JinjaPromptprevious_messages:10 unmodified lines111213141516178 unmodified lines26272829303132333435363738391 unmodified line4142434445464710 unmodified linesassistant_name: assistantbackend:_target_: aiflows.backends.llm_lite.LiteLLMBackendapi_infos: ???model_name: "gpt-3.5-turbo"n: 18 unmodified linessystem_message_prompt_template:_target_: aiflows.prompt_template.JinjaPromptinit_human_message_prompt_template:_target_: aiflows.prompt_template.JinjaPrompthuman_message_prompt_template:_target_: aiflows.prompt_template.JinjaPrompttemplate: "{{query}}"input_variables:- "query"1 unmodified line- "query"query_message_prompt_template:_target_: aiflows.prompt_template.JinjaPromptprevious_messages:
39 unmodified lines404142434445469 unmodified lines56575859606162636465666768697020 unmodified lines9192939495969739 unmodified lines- `assistant_name` (str): The name of the assistant (roles of LLM). Default: "assistant"- `backend` Dict[str,Any]: The backend of the flow. Used to call models via an API.See litellm's supported models and APIs here: https://docs.litellm.ai/docs/providers.The default parameters of the backend are all defined at flows.backends.llm_lite.LiteLLMBackend(also see the defaul parameters of litellm's completion parameters: https://docs.litellm.ai/docs/completion/input#input-params-1).Except for the following parameters who are overwritten by the ChatAtomicFlow in ChatAtomicFlow.yaml:- `model_name` (Union[Dict[str,str],str]): The name of the model to use.9 unmodified lines- `presence_penalty` (number): It is used to penalize new tokens based on their existence in the text so far. Default: 0.0- `stream` (bool): Whether to stream the response or not. Default: True- `system_message_prompt_template` (Dict[str,Any]): The template of the system message. It is used to generate the system message.By default its of type flows.prompt_template.JinjaPrompt.None of the parameters of the prompt are defined by default and therefore need to be defined if one wants to use the system prompt.Default parameters are defined in flows.prompt_template.jinja2_prompts.JinjaPrompt.- `init_human_message_prompt_template` (Dict[str,Any]): The prompt template of the human/user message used to initialize the conversation(first time in). It is used to generate the human message. It's passed as the user message to the LLM.By default its of type flows.prompt_template.JinjaPrompt. None of the parameters of the prompt are defined by default and therefore need to be defined if onewants to use the init_human_message_prompt_template. Default parameters are defined in flows.prompt_template.jinja2_prompts.JinjaPrompt.- `human_message_prompt_template` (Dict[str,Any]): The prompt template of the human/user message (message used everytime the except the first time in).It's passed as the user message to the LLM. By default its of type flows.prompt_template.JinjaPrompt and has the following parameters:- `template` (str): The template of the human message. Default: see ChatAtomicFlow.yaml for the default value.- `input_variables` (List[str]): The input variables of the human message prompt template. Default: ["query"]- `previous_messages` (Dict[str,Any]): Defines which previous messages to include in the input of the LLM. Note that if `first_k`and `last_k` are both none,20 unmodified lines- `human_message_prompt_template` (`JinjaPrompt`): The template of the human message. It is used to generate the human message.- `init_human_message_prompt_template` (`Optional[JinjaPrompt]`): The template of the human message that is used to initialize the conversation (first time in). It is used to generate the human message.- `backend` (`LiteLLMBackend`): The backend of the flow. It is a LLM that is queried via an API. See litellm's supported models and APIs here: https://docs.litellm.ai/docs/providers- `\**kwargs`: Additional arguments to pass to the flow. See :class:`flows.base_flows.AtomicFlow` for more details.<a id="ChatAtomicFlow.ChatAtomicFlow.set_up_flow_state"></a>39 unmodified lines404142434445469 unmodified lines56575859606162636465666768697020 unmodified lines9192939495969739 unmodified lines- `assistant_name` (str): The name of the assistant (roles of LLM). Default: "assistant"- `backend` Dict[str,Any]: The backend of the flow. Used to call models via an API.See litellm's supported models and APIs here: https://docs.litellm.ai/docs/providers.The default parameters of the backend are all defined at aiflows.backends.llm_lite.LiteLLMBackend(also see the defaul parameters of litellm's completion parameters: https://docs.litellm.ai/docs/completion/input#input-params-1).Except for the following parameters who are overwritten by the ChatAtomicFlow in ChatAtomicFlow.yaml:- `model_name` (Union[Dict[str,str],str]): The name of the model to use.9 unmodified lines- `presence_penalty` (number): It is used to penalize new tokens based on their existence in the text so far. Default: 0.0- `stream` (bool): Whether to stream the response or not. Default: True- `system_message_prompt_template` (Dict[str,Any]): The template of the system message. It is used to generate the system message.By default its of type aiflows.prompt_template.JinjaPrompt.None of the parameters of the prompt are defined by default and therefore need to be defined if one wants to use the system prompt.Default parameters are defined in aiflows.prompt_template.jinja2_prompts.JinjaPrompt.- `init_human_message_prompt_template` (Dict[str,Any]): The prompt template of the human/user message used to initialize the conversation(first time in). It is used to generate the human message. It's passed as the user message to the LLM.By default its of type aiflows.prompt_template.JinjaPrompt. None of the parameters of the prompt are defined by default and therefore need to be defined if onewants to use the init_human_message_prompt_template. Default parameters are defined in aiflows.prompt_template.jinja2_prompts.JinjaPrompt.- `human_message_prompt_template` (Dict[str,Any]): The prompt template of the human/user message (message used everytime the except the first time in).It's passed as the user message to the LLM. By default its of type aiflows.prompt_template.JinjaPrompt and has the following parameters:- `template` (str): The template of the human message. Default: see ChatAtomicFlow.yaml for the default value.- `input_variables` (List[str]): The input variables of the human message prompt template. Default: ["query"]- `previous_messages` (Dict[str,Any]): Defines which previous messages to include in the input of the LLM. Note that if `first_k`and `last_k` are both none,20 unmodified lines- `human_message_prompt_template` (`JinjaPrompt`): The template of the human message. It is used to generate the human message.- `init_human_message_prompt_template` (`Optional[JinjaPrompt]`): The template of the human message that is used to initialize the conversation (first time in). It is used to generate the human message.- `backend` (`LiteLLMBackend`): The backend of the flow. It is a LLM that is queried via an API. See litellm's supported models and APIs here: https://docs.litellm.ai/docs/providers- `\**kwargs`: Additional arguments to pass to the flow. See :class:`aiflows.base_flows.AtomicFlow` for more details.<a id="ChatAtomicFlow.ChatAtomicFlow.set_up_flow_state"></a>
1234567891011121314154 unmodified lines2021222324252613 unmodified lines404142434445461 unmodified line48495051525354input_interface: # Connector between the "input data" and the Flow_target_: flows.interfaces.KeyInterfaceadditional_transformations:- _target_: flows.data_transformations.KeyMatchInput # Pass the input parameters specified by the flowoutput_interface: # Connector between the Flow's output and the caller_target_: flows.interfaces.KeyInterfacekeys_to_rename:api_output: answer # Rename the api_output to answerflow: # Overrides the ChatAtomicFlow config_target_: aiflows.ChatFlowModule.ChatAtomicFlow.instantiate_from_default_configname: "SimpleQA_Flow"description: "A flow that answers questions."4 unmodified lines# ~~~ backend model parameters ~~backend:_target_: flows.backends.llm_lite.LiteLLMBackendapi_infos: ???model_name:openai: "gpt-3.5-turbo"13 unmodified lines# ~~~ Prompt specification ~~~system_message_prompt_template:_target_: flows.prompt_template.JinjaPrompttemplate: |2-You are a helpful chatbot that truthfully answers questions.input_variables: []1 unmodified lineinit_human_message_prompt_template:_target_: flows.prompt_template.JinjaPrompttemplate: |2-Answer the following question: {{question}}input_variables: ["question"]1234567891011121314154 unmodified lines2021222324252613 unmodified lines404142434445461 unmodified line48495051525354input_interface: # Connector between the "input data" and the Flow_target_: aiflows.interfaces.KeyInterfaceadditional_transformations:- _target_: aiflows.data_transformations.KeyMatchInput # Pass the input parameters specified by the flowoutput_interface: # Connector between the Flow's output and the caller_target_: aiflows.interfaces.KeyInterfacekeys_to_rename:api_output: answer # Rename the api_output to answerflow: # Overrides the ChatAtomicFlow config_target_: flow_modules.aiflows.ChatFlowModule.ChatAtomicFlow.instantiate_from_default_configname: "SimpleQA_Flow"description: "A flow that answers questions."4 unmodified lines# ~~~ backend model parameters ~~backend:_target_: aiflows.backends.llm_lite.LiteLLMBackendapi_infos: ???model_name:openai: "gpt-3.5-turbo"13 unmodified lines# ~~~ Prompt specification ~~~system_message_prompt_template:_target_: aiflows.prompt_template.JinjaPrompttemplate: |2-You are a helpful chatbot that truthfully answers questions.input_variables: []1 unmodified lineinit_human_message_prompt_template:_target_: aiflows.prompt_template.JinjaPrompttemplate: |2-Answer the following question: {{question}}input_variables: ["question"]
1 unmodified line2345678910111213143 unmodified lines181920212223241 unmodified lineimport hydraimport flowsfrom flows.flow_launchers import FlowLauncherfrom flows.backends.api_info import ApiInfofrom flows.utils.general_helpers import read_yaml_filefrom flows import loggingfrom flows.flow_cache import CACHING_PARAMETERS, clear_cacheCACHING_PARAMETERS.do_caching = False # Set to True in order to disable caching# clear_cache() # Uncomment this line to clear the cache3 unmodified linesdependencies = [{"url": "aiflows/ChatFlowModule", "revision": os.getcwd()},]from flows import flow_verseflow_verse.sync_dependencies(dependencies)if __name__ == "__main__":1 unmodified line2345678910111213143 unmodified lines181920212223241 unmodified lineimport hydraimport aiflowsfrom aiflows.flow_launchers import FlowLauncherfrom aiflows.backends.api_info import ApiInfofrom aiflows.utils.general_helpers import read_yaml_filefrom aiflows import loggingfrom aiflows.flow_cache import CACHING_PARAMETERS, clear_cacheCACHING_PARAMETERS.do_caching = False # Set to True in order to disable caching# clear_cache() # Uncomment this line to clear the cache3 unmodified linesdependencies = [{"url": "aiflows/ChatFlowModule", "revision": os.getcwd()},]from aiflows import flow_verseflow_verse.sync_dependencies(dependencies)if __name__ == "__main__":
ChatAtomicFlow.py+12-12
ChatAtomicFlow.yaml+5-5
README.md+7-7
demo.yaml+7-7
run.py+7-7