diff --git a/README.md b/README.md index 4a973d61..cecbe5d2 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ import os from autogen.agentchat import ConversableAgent from fastagency import UI, FastAgency, Workflows -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.runtimes.autogen import AutoGenWorkflows from fastagency.ui.mesop import MesopUI ``` diff --git a/docs/docs/SUMMARY.md b/docs/docs/SUMMARY.md index 9b21a473..9cfc0c12 100644 --- a/docs/docs/SUMMARY.md +++ b/docs/docs/SUMMARY.md @@ -5,12 +5,12 @@ search: - Getting Started - [Getting Started](getting-started/index.md) - [User guide](user-guide/index.md) - - [Runtimes](user-guide/runtime/index.md) - - [AutoGen](user-guide/runtime/autogen/index.md) + - [Runtimes](user-guide/runtimes/index.md) + - [AutoGen](user-guide/runtimes/autogen/index.md) - Agents - - [WebSurfer](user-guide/runtime/autogen/websurfer.md) - - [User interaction](user-guide/runtime/autogen/interactions.md) - - [CrewAI](user-guide/runtime/crewai/basics.md) + - [WebSurfer](user-guide/runtimes/autogen/websurfer.md) + - [User interaction](user-guide/runtimes/autogen/interactions.md) + - [CrewAI](user-guide/runtimes/crewai/basics.md) - [UI](user-guide/ui/index.md) - [Console](user-guide/ui/console/basics.md) - [Mesop](user-guide/ui/mesop/basics.md) @@ -75,22 +75,10 @@ search: - base - [ASGIProtocol](api/fastagency/base/ASGIProtocol.md) - [AdapterProtocol](api/fastagency/base/AdapterProtocol.md) - - [AskingMessage](api/fastagency/base/AskingMessage.md) - - [Error](api/fastagency/base/Error.md) - - [FunctionCallExecution](api/fastagency/base/FunctionCallExecution.md) - - [IOMessage](api/fastagency/base/IOMessage.md) - - [IOMessageVisitor](api/fastagency/base/IOMessageVisitor.md) - - [KeepAlive](api/fastagency/base/KeepAlive.md) - - [MultipleChoice](api/fastagency/base/MultipleChoice.md) - [ProviderProtocol](api/fastagency/base/ProviderProtocol.md) - [Runnable](api/fastagency/base/Runnable.md) - - [SuggestedFunctionCall](api/fastagency/base/SuggestedFunctionCall.md) - - [SystemMessage](api/fastagency/base/SystemMessage.md) - - [TextInput](api/fastagency/base/TextInput.md) - - [TextMessage](api/fastagency/base/TextMessage.md) - [UI](api/fastagency/base/UI.md) - [WSGIProtocol](api/fastagency/base/WSGIProtocol.md) - - [WorkflowCompleted](api/fastagency/base/WorkflowCompleted.md) - [WorkflowsProtocol](api/fastagency/base/WorkflowsProtocol.md) - [run_workflow](api/fastagency/base/run_workflow.md) - cli @@ -123,34 +111,45 @@ search: - [optional_temp_path](api/fastagency/helpers/optional_temp_path.md) - logging - [get_logger](api/fastagency/logging/get_logger.md) - - runtime + - messages + - [AskingMessage](api/fastagency/messages/AskingMessage.md) + - [Error](api/fastagency/messages/Error.md) + - [FunctionCallExecution](api/fastagency/messages/FunctionCallExecution.md) + - [IOMessage](api/fastagency/messages/IOMessage.md) + - [KeepAlive](api/fastagency/messages/KeepAlive.md) + - [MessageProcessorMixin](api/fastagency/messages/MessageProcessorMixin.md) + - [MessageProcessorProtocol](api/fastagency/messages/MessageProcessorProtocol.md) + - [MultipleChoice](api/fastagency/messages/MultipleChoice.md) + - [SuggestedFunctionCall](api/fastagency/messages/SuggestedFunctionCall.md) + - [SystemMessage](api/fastagency/messages/SystemMessage.md) + - [TextInput](api/fastagency/messages/TextInput.md) + - [TextMessage](api/fastagency/messages/TextMessage.md) + - [WorkflowCompleted](api/fastagency/messages/WorkflowCompleted.md) + - [WorkflowStarted](api/fastagency/messages/WorkflowStarted.md) + - runtimes - autogen - - [AutoGenWorkflows](api/fastagency/runtime/autogen/AutoGenWorkflows.md) - - [IOStreamAdapter](api/fastagency/runtime/autogen/IOStreamAdapter.md) + - [AutoGenWorkflows](api/fastagency/runtimes/autogen/AutoGenWorkflows.md) + - [IOStreamAdapter](api/fastagency/runtimes/autogen/IOStreamAdapter.md) - agents - websurfer - - [WebSurferAgent](api/fastagency/runtime/autogen/agents/websurfer/WebSurferAgent.md) - - base - - [AutoGenWorkflows](api/fastagency/runtime/autogen/base/AutoGenWorkflows.md) - - [CurrentMessage](api/fastagency/runtime/autogen/base/CurrentMessage.md) - - [IOStreamAdapter](api/fastagency/runtime/autogen/base/IOStreamAdapter.md) - - [Toolable](api/fastagency/runtime/autogen/base/Toolable.md) + - [WebSurferAgent](api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md) + - autogen + - [AutoGenWorkflows](api/fastagency/runtimes/autogen/autogen/AutoGenWorkflows.md) + - [CurrentMessage](api/fastagency/runtimes/autogen/autogen/CurrentMessage.md) + - [IOStreamAdapter](api/fastagency/runtimes/autogen/autogen/IOStreamAdapter.md) + - [Toolable](api/fastagency/runtimes/autogen/autogen/Toolable.md) - tools - - [WebSurferTool](api/fastagency/runtime/autogen/tools/WebSurferTool.md) + - [WebSurferTool](api/fastagency/runtimes/autogen/tools/WebSurferTool.md) - web_surfer - - [WebSurferAnswer](api/fastagency/runtime/autogen/tools/web_surfer/WebSurferAnswer.md) - - [WebSurferTool](api/fastagency/runtime/autogen/tools/web_surfer/WebSurferTool.md) + - [WebSurferAnswer](api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferAnswer.md) + - [WebSurferTool](api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferTool.md) - ui - console - [ConsoleUI](api/fastagency/ui/console/ConsoleUI.md) - - base - - [ConsoleUI](api/fastagency/ui/console/base/ConsoleUI.md) + - console + - [ConsoleUI](api/fastagency/ui/console/console/ConsoleUI.md) - mesop - [MesopUI](api/fastagency/ui/mesop/MesopUI.md) - - base - - [MesopMessage](api/fastagency/ui/mesop/base/MesopMessage.md) - - [MesopUI](api/fastagency/ui/mesop/base/MesopUI.md) - - [run_workflow](api/fastagency/ui/mesop/base/run_workflow.md) - components - helpers - [darken_hex_color](api/fastagency/ui/mesop/components/helpers/darken_hex_color.md) @@ -164,6 +163,10 @@ search: - [MesopHomePage](api/fastagency/ui/mesop/main/MesopHomePage.md) - [MesopHomePageParams](api/fastagency/ui/mesop/main/MesopHomePageParams.md) - [create_home_page](api/fastagency/ui/mesop/main/create_home_page.md) + - mesop + - [MesopMessage](api/fastagency/ui/mesop/mesop/MesopMessage.md) + - [MesopUI](api/fastagency/ui/mesop/mesop/MesopUI.md) + - [run_workflow](api/fastagency/ui/mesop/mesop/run_workflow.md) - message - [MesopGUIMessageVisitor](api/fastagency/ui/mesop/message/MesopGUIMessageVisitor.md) - [consume_responses](api/fastagency/ui/mesop/message/consume_responses.md) diff --git a/docs/docs/en/api/fastagency/base/AskingMessage.md b/docs/docs/en/api/fastagency/messages/AskingMessage.md similarity index 74% rename from docs/docs/en/api/fastagency/base/AskingMessage.md rename to docs/docs/en/api/fastagency/messages/AskingMessage.md index e219a8bb..005ab7ac 100644 --- a/docs/docs/en/api/fastagency/base/AskingMessage.md +++ b/docs/docs/en/api/fastagency/messages/AskingMessage.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.base.AskingMessage +::: fastagency.messages.AskingMessage diff --git a/docs/docs/en/api/fastagency/base/Error.md b/docs/docs/en/api/fastagency/messages/Error.md similarity index 78% rename from docs/docs/en/api/fastagency/base/Error.md rename to docs/docs/en/api/fastagency/messages/Error.md index 34bee775..54fc92f3 100644 --- a/docs/docs/en/api/fastagency/base/Error.md +++ b/docs/docs/en/api/fastagency/messages/Error.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.base.Error +::: fastagency.messages.Error diff --git a/docs/docs/en/api/fastagency/base/FunctionCallExecution.md b/docs/docs/en/api/fastagency/messages/FunctionCallExecution.md similarity index 70% rename from docs/docs/en/api/fastagency/base/FunctionCallExecution.md rename to docs/docs/en/api/fastagency/messages/FunctionCallExecution.md index 032d46b9..61884d44 100644 --- a/docs/docs/en/api/fastagency/base/FunctionCallExecution.md +++ b/docs/docs/en/api/fastagency/messages/FunctionCallExecution.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.base.FunctionCallExecution +::: fastagency.messages.FunctionCallExecution diff --git a/docs/docs/en/api/fastagency/base/IOMessage.md b/docs/docs/en/api/fastagency/messages/IOMessage.md similarity index 76% rename from docs/docs/en/api/fastagency/base/IOMessage.md rename to docs/docs/en/api/fastagency/messages/IOMessage.md index 61e169d2..0c54021c 100644 --- a/docs/docs/en/api/fastagency/base/IOMessage.md +++ b/docs/docs/en/api/fastagency/messages/IOMessage.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.base.IOMessage +::: fastagency.messages.IOMessage diff --git a/docs/docs/en/api/fastagency/base/KeepAlive.md b/docs/docs/en/api/fastagency/messages/KeepAlive.md similarity index 76% rename from docs/docs/en/api/fastagency/base/KeepAlive.md rename to docs/docs/en/api/fastagency/messages/KeepAlive.md index 67bfdd07..58727a73 100644 --- a/docs/docs/en/api/fastagency/base/KeepAlive.md +++ b/docs/docs/en/api/fastagency/messages/KeepAlive.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.base.KeepAlive +::: fastagency.messages.KeepAlive diff --git a/docs/docs/en/api/fastagency/messages/MessageProcessorMixin.md b/docs/docs/en/api/fastagency/messages/MessageProcessorMixin.md new file mode 100644 index 00000000..03d8a1c4 --- /dev/null +++ b/docs/docs/en/api/fastagency/messages/MessageProcessorMixin.md @@ -0,0 +1,11 @@ +--- +# 0.5 - API +# 2 - Release +# 3 - Contributing +# 5 - Template Page +# 10 - Default +search: + boost: 0.5 +--- + +::: fastagency.messages.MessageProcessorMixin diff --git a/docs/docs/en/api/fastagency/messages/MessageProcessorProtocol.md b/docs/docs/en/api/fastagency/messages/MessageProcessorProtocol.md new file mode 100644 index 00000000..7fac6e3e --- /dev/null +++ b/docs/docs/en/api/fastagency/messages/MessageProcessorProtocol.md @@ -0,0 +1,11 @@ +--- +# 0.5 - API +# 2 - Release +# 3 - Contributing +# 5 - Template Page +# 10 - Default +search: + boost: 0.5 +--- + +::: fastagency.messages.MessageProcessorProtocol diff --git a/docs/docs/en/api/fastagency/base/MultipleChoice.md b/docs/docs/en/api/fastagency/messages/MultipleChoice.md similarity index 73% rename from docs/docs/en/api/fastagency/base/MultipleChoice.md rename to docs/docs/en/api/fastagency/messages/MultipleChoice.md index a9d35b0d..3581f49e 100644 --- a/docs/docs/en/api/fastagency/base/MultipleChoice.md +++ b/docs/docs/en/api/fastagency/messages/MultipleChoice.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.base.MultipleChoice +::: fastagency.messages.MultipleChoice diff --git a/docs/docs/en/api/fastagency/base/SuggestedFunctionCall.md b/docs/docs/en/api/fastagency/messages/SuggestedFunctionCall.md similarity index 70% rename from docs/docs/en/api/fastagency/base/SuggestedFunctionCall.md rename to docs/docs/en/api/fastagency/messages/SuggestedFunctionCall.md index 24e2895a..88d4a59a 100644 --- a/docs/docs/en/api/fastagency/base/SuggestedFunctionCall.md +++ b/docs/docs/en/api/fastagency/messages/SuggestedFunctionCall.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.base.SuggestedFunctionCall +::: fastagency.messages.SuggestedFunctionCall diff --git a/docs/docs/en/api/fastagency/base/SystemMessage.md b/docs/docs/en/api/fastagency/messages/SystemMessage.md similarity index 74% rename from docs/docs/en/api/fastagency/base/SystemMessage.md rename to docs/docs/en/api/fastagency/messages/SystemMessage.md index 7546ee08..ba3ad628 100644 --- a/docs/docs/en/api/fastagency/base/SystemMessage.md +++ b/docs/docs/en/api/fastagency/messages/SystemMessage.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.base.SystemMessage +::: fastagency.messages.SystemMessage diff --git a/docs/docs/en/api/fastagency/base/TextInput.md b/docs/docs/en/api/fastagency/messages/TextInput.md similarity index 76% rename from docs/docs/en/api/fastagency/base/TextInput.md rename to docs/docs/en/api/fastagency/messages/TextInput.md index 70526328..c7c68613 100644 --- a/docs/docs/en/api/fastagency/base/TextInput.md +++ b/docs/docs/en/api/fastagency/messages/TextInput.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.base.TextInput +::: fastagency.messages.TextInput diff --git a/docs/docs/en/api/fastagency/base/TextMessage.md b/docs/docs/en/api/fastagency/messages/TextMessage.md similarity index 75% rename from docs/docs/en/api/fastagency/base/TextMessage.md rename to docs/docs/en/api/fastagency/messages/TextMessage.md index 7fee196a..02550b02 100644 --- a/docs/docs/en/api/fastagency/base/TextMessage.md +++ b/docs/docs/en/api/fastagency/messages/TextMessage.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.base.TextMessage +::: fastagency.messages.TextMessage diff --git a/docs/docs/en/api/fastagency/base/WorkflowCompleted.md b/docs/docs/en/api/fastagency/messages/WorkflowCompleted.md similarity index 72% rename from docs/docs/en/api/fastagency/base/WorkflowCompleted.md rename to docs/docs/en/api/fastagency/messages/WorkflowCompleted.md index 6c60e080..29f6d8eb 100644 --- a/docs/docs/en/api/fastagency/base/WorkflowCompleted.md +++ b/docs/docs/en/api/fastagency/messages/WorkflowCompleted.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.base.WorkflowCompleted +::: fastagency.messages.WorkflowCompleted diff --git a/docs/docs/en/api/fastagency/base/IOMessageVisitor.md b/docs/docs/en/api/fastagency/messages/WorkflowStarted.md similarity index 73% rename from docs/docs/en/api/fastagency/base/IOMessageVisitor.md rename to docs/docs/en/api/fastagency/messages/WorkflowStarted.md index f7ca8138..38b72a7e 100644 --- a/docs/docs/en/api/fastagency/base/IOMessageVisitor.md +++ b/docs/docs/en/api/fastagency/messages/WorkflowStarted.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.base.IOMessageVisitor +::: fastagency.messages.WorkflowStarted diff --git a/docs/docs/en/api/fastagency/runtime/autogen/AutoGenWorkflows.md b/docs/docs/en/api/fastagency/runtimes/autogen/AutoGenWorkflows.md similarity index 69% rename from docs/docs/en/api/fastagency/runtime/autogen/AutoGenWorkflows.md rename to docs/docs/en/api/fastagency/runtimes/autogen/AutoGenWorkflows.md index 3f840bb1..01c0b718 100644 --- a/docs/docs/en/api/fastagency/runtime/autogen/AutoGenWorkflows.md +++ b/docs/docs/en/api/fastagency/runtimes/autogen/AutoGenWorkflows.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.runtime.autogen.AutoGenWorkflows +::: fastagency.runtimes.autogen.AutoGenWorkflows diff --git a/docs/docs/en/api/fastagency/runtime/autogen/IOStreamAdapter.md b/docs/docs/en/api/fastagency/runtimes/autogen/IOStreamAdapter.md similarity index 69% rename from docs/docs/en/api/fastagency/runtime/autogen/IOStreamAdapter.md rename to docs/docs/en/api/fastagency/runtimes/autogen/IOStreamAdapter.md index cdcf8879..a8ee8e0e 100644 --- a/docs/docs/en/api/fastagency/runtime/autogen/IOStreamAdapter.md +++ b/docs/docs/en/api/fastagency/runtimes/autogen/IOStreamAdapter.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.runtime.autogen.IOStreamAdapter +::: fastagency.runtimes.autogen.IOStreamAdapter diff --git a/docs/docs/en/api/fastagency/runtime/autogen/agents/websurfer/WebSurferAgent.md b/docs/docs/en/api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md similarity index 63% rename from docs/docs/en/api/fastagency/runtime/autogen/agents/websurfer/WebSurferAgent.md rename to docs/docs/en/api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md index 70e3329c..4b6b4a8a 100644 --- a/docs/docs/en/api/fastagency/runtime/autogen/agents/websurfer/WebSurferAgent.md +++ b/docs/docs/en/api/fastagency/runtimes/autogen/agents/websurfer/WebSurferAgent.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.runtime.autogen.agents.websurfer.WebSurferAgent +::: fastagency.runtimes.autogen.agents.websurfer.WebSurferAgent diff --git a/docs/docs/en/api/fastagency/runtime/autogen/base/AutoGenWorkflows.md b/docs/docs/en/api/fastagency/runtimes/autogen/autogen/AutoGenWorkflows.md similarity index 65% rename from docs/docs/en/api/fastagency/runtime/autogen/base/AutoGenWorkflows.md rename to docs/docs/en/api/fastagency/runtimes/autogen/autogen/AutoGenWorkflows.md index 7478687e..b1f2179a 100644 --- a/docs/docs/en/api/fastagency/runtime/autogen/base/AutoGenWorkflows.md +++ b/docs/docs/en/api/fastagency/runtimes/autogen/autogen/AutoGenWorkflows.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.runtime.autogen.base.AutoGenWorkflows +::: fastagency.runtimes.autogen.autogen.AutoGenWorkflows diff --git a/docs/docs/en/api/fastagency/runtime/autogen/base/CurrentMessage.md b/docs/docs/en/api/fastagency/runtimes/autogen/autogen/CurrentMessage.md similarity index 66% rename from docs/docs/en/api/fastagency/runtime/autogen/base/CurrentMessage.md rename to docs/docs/en/api/fastagency/runtimes/autogen/autogen/CurrentMessage.md index e6cc9830..bd3b8136 100644 --- a/docs/docs/en/api/fastagency/runtime/autogen/base/CurrentMessage.md +++ b/docs/docs/en/api/fastagency/runtimes/autogen/autogen/CurrentMessage.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.runtime.autogen.base.CurrentMessage +::: fastagency.runtimes.autogen.autogen.CurrentMessage diff --git a/docs/docs/en/api/fastagency/runtime/autogen/base/IOStreamAdapter.md b/docs/docs/en/api/fastagency/runtimes/autogen/autogen/IOStreamAdapter.md similarity index 66% rename from docs/docs/en/api/fastagency/runtime/autogen/base/IOStreamAdapter.md rename to docs/docs/en/api/fastagency/runtimes/autogen/autogen/IOStreamAdapter.md index 78a63815..3701640f 100644 --- a/docs/docs/en/api/fastagency/runtime/autogen/base/IOStreamAdapter.md +++ b/docs/docs/en/api/fastagency/runtimes/autogen/autogen/IOStreamAdapter.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.runtime.autogen.base.IOStreamAdapter +::: fastagency.runtimes.autogen.autogen.IOStreamAdapter diff --git a/docs/docs/en/api/fastagency/runtime/autogen/base/Toolable.md b/docs/docs/en/api/fastagency/runtimes/autogen/autogen/Toolable.md similarity index 69% rename from docs/docs/en/api/fastagency/runtime/autogen/base/Toolable.md rename to docs/docs/en/api/fastagency/runtimes/autogen/autogen/Toolable.md index 7dce90dd..83204ca5 100644 --- a/docs/docs/en/api/fastagency/runtime/autogen/base/Toolable.md +++ b/docs/docs/en/api/fastagency/runtimes/autogen/autogen/Toolable.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.runtime.autogen.base.Toolable +::: fastagency.runtimes.autogen.autogen.Toolable diff --git a/docs/docs/en/api/fastagency/runtime/autogen/tools/WebSurferTool.md b/docs/docs/en/api/fastagency/runtimes/autogen/tools/WebSurferTool.md similarity index 67% rename from docs/docs/en/api/fastagency/runtime/autogen/tools/WebSurferTool.md rename to docs/docs/en/api/fastagency/runtimes/autogen/tools/WebSurferTool.md index 0702a6ee..b76ae40d 100644 --- a/docs/docs/en/api/fastagency/runtime/autogen/tools/WebSurferTool.md +++ b/docs/docs/en/api/fastagency/runtimes/autogen/tools/WebSurferTool.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.runtime.autogen.tools.WebSurferTool +::: fastagency.runtimes.autogen.tools.WebSurferTool diff --git a/docs/docs/en/api/fastagency/runtime/autogen/tools/web_surfer/WebSurferAnswer.md b/docs/docs/en/api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferAnswer.md similarity index 62% rename from docs/docs/en/api/fastagency/runtime/autogen/tools/web_surfer/WebSurferAnswer.md rename to docs/docs/en/api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferAnswer.md index 4e33024a..636f139e 100644 --- a/docs/docs/en/api/fastagency/runtime/autogen/tools/web_surfer/WebSurferAnswer.md +++ b/docs/docs/en/api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferAnswer.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.runtime.autogen.tools.web_surfer.WebSurferAnswer +::: fastagency.runtimes.autogen.tools.web_surfer.WebSurferAnswer diff --git a/docs/docs/en/api/fastagency/runtime/autogen/tools/web_surfer/WebSurferTool.md b/docs/docs/en/api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferTool.md similarity index 63% rename from docs/docs/en/api/fastagency/runtime/autogen/tools/web_surfer/WebSurferTool.md rename to docs/docs/en/api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferTool.md index 2192998c..c0f498bf 100644 --- a/docs/docs/en/api/fastagency/runtime/autogen/tools/web_surfer/WebSurferTool.md +++ b/docs/docs/en/api/fastagency/runtimes/autogen/tools/web_surfer/WebSurferTool.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.runtime.autogen.tools.web_surfer.WebSurferTool +::: fastagency.runtimes.autogen.tools.web_surfer.WebSurferTool diff --git a/docs/docs/en/api/fastagency/ui/console/base/ConsoleUI.md b/docs/docs/en/api/fastagency/ui/console/console/ConsoleUI.md similarity index 71% rename from docs/docs/en/api/fastagency/ui/console/base/ConsoleUI.md rename to docs/docs/en/api/fastagency/ui/console/console/ConsoleUI.md index a4cb0e76..63a732f4 100644 --- a/docs/docs/en/api/fastagency/ui/console/base/ConsoleUI.md +++ b/docs/docs/en/api/fastagency/ui/console/console/ConsoleUI.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.ui.console.base.ConsoleUI +::: fastagency.ui.console.console.ConsoleUI diff --git a/docs/docs/en/api/fastagency/ui/mesop/base/MesopMessage.md b/docs/docs/en/api/fastagency/ui/mesop/mesop/MesopMessage.md similarity index 71% rename from docs/docs/en/api/fastagency/ui/mesop/base/MesopMessage.md rename to docs/docs/en/api/fastagency/ui/mesop/mesop/MesopMessage.md index ae545610..aa497f7e 100644 --- a/docs/docs/en/api/fastagency/ui/mesop/base/MesopMessage.md +++ b/docs/docs/en/api/fastagency/ui/mesop/mesop/MesopMessage.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.ui.mesop.base.MesopMessage +::: fastagency.ui.mesop.mesop.MesopMessage diff --git a/docs/docs/en/api/fastagency/ui/mesop/base/MesopUI.md b/docs/docs/en/api/fastagency/ui/mesop/mesop/MesopUI.md similarity index 74% rename from docs/docs/en/api/fastagency/ui/mesop/base/MesopUI.md rename to docs/docs/en/api/fastagency/ui/mesop/mesop/MesopUI.md index 7ec2a96f..7f49f8a6 100644 --- a/docs/docs/en/api/fastagency/ui/mesop/base/MesopUI.md +++ b/docs/docs/en/api/fastagency/ui/mesop/mesop/MesopUI.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.ui.mesop.base.MesopUI +::: fastagency.ui.mesop.mesop.MesopUI diff --git a/docs/docs/en/api/fastagency/ui/mesop/base/run_workflow.md b/docs/docs/en/api/fastagency/ui/mesop/mesop/run_workflow.md similarity index 71% rename from docs/docs/en/api/fastagency/ui/mesop/base/run_workflow.md rename to docs/docs/en/api/fastagency/ui/mesop/mesop/run_workflow.md index b9404a57..0a1ec305 100644 --- a/docs/docs/en/api/fastagency/ui/mesop/base/run_workflow.md +++ b/docs/docs/en/api/fastagency/ui/mesop/mesop/run_workflow.md @@ -8,4 +8,4 @@ search: boost: 0.5 --- -::: fastagency.ui.mesop.base.run_workflow +::: fastagency.ui.mesop.mesop.run_workflow diff --git a/docs/docs/en/tutorial/giphy/index.md b/docs/docs/en/tutorial/giphy/index.md index d2fcfbdb..a87f9e7d 100644 --- a/docs/docs/en/tutorial/giphy/index.md +++ b/docs/docs/en/tutorial/giphy/index.md @@ -118,7 +118,7 @@ This is a core function used by the **GiphyAgent** to either present the task re ### Creating the Giphy and WebSurfer Agents - **GiphyAgent**: A ***ConversableAgent*** is created with the name "Giphy_Agent". It uses the system message defined earlier and relies on the termination function to end the chat when needed. -- **WebSurferAgent**: The ***WebSurferAgent*** is responsible for scraping web content and passes the retrieved data to the **GiphyAgent**. It’s configured with a summarizer to condense web content, which is useful when presenting concise data to the user. For more information, visit [**WebSurfer User Guide**](../../user-guide/runtime/autogen/websurfer){target="_blank"}. +- **WebSurferAgent**: The ***WebSurferAgent*** is responsible for scraping web content and passes the retrieved data to the **GiphyAgent**. It’s configured with a summarizer to condense web content, which is useful when presenting concise data to the user. For more information, visit [**WebSurfer User Guide**](../../user-guide/runtimes/autogen/websurfer){target="_blank"}. ```python {! docs_src/tutorial/giphy/main.py [ln:79-93] !} diff --git a/docs/docs/en/user-guide/index.md b/docs/docs/en/user-guide/index.md index be089530..07dc73a8 100644 --- a/docs/docs/en/user-guide/index.md +++ b/docs/docs/en/user-guide/index.md @@ -6,7 +6,7 @@ Whether you're orchestrating complex AI agents or integrating external APIs into ## Key Features -- [**Multi-Runtime Support**](runtime/): FastAgency supports multiple agentic [runtimes](runtime/) to provide maximum flexibility. Currently, it supports **AutoGen** and plans to extend support to [CrewAI](https://www.crewai.com/){target="_blank"}. This ensures that as the AI ecosystem evolves, FastAgency remains a reliable and adaptable framework, capable of leveraging emerging agentic technologies. Developers can easily switch between frameworks, choosing the best one for their project's specific needs. +- [**Multi-Runtime Support**](runtimes/): FastAgency supports multiple agentic [runtimes](runtimes/) to provide maximum flexibility. Currently, it supports **AutoGen** and plans to extend support to [CrewAI](https://www.crewai.com/){target="_blank"}. This ensures that as the AI ecosystem evolves, FastAgency remains a reliable and adaptable framework, capable of leveraging emerging agentic technologies. Developers can easily switch between frameworks, choosing the best one for their project's specific needs. - [**Unified Programming Interface Across UIs**](ui/): FastAgency features a **common programming interface** that enables you to develop your core workflows once and reuse them across various user interfaces without rewriting code. This includes support for both **console-based applications** via `ConsoleUI` and **web-based applications** via `MesopUI`. Whether you need a command-line tool or a fully interactive web app, FastAgency allows you to deploy the same underlying workflows across environments, saving development time and ensuring consistency. diff --git a/docs/docs/en/user-guide/runtime/autogen/index.md b/docs/docs/en/user-guide/runtimes/autogen/index.md similarity index 100% rename from docs/docs/en/user-guide/runtime/autogen/index.md rename to docs/docs/en/user-guide/runtimes/autogen/index.md diff --git a/docs/docs/en/user-guide/runtime/autogen/interactions.md b/docs/docs/en/user-guide/runtimes/autogen/interactions.md similarity index 100% rename from docs/docs/en/user-guide/runtime/autogen/interactions.md rename to docs/docs/en/user-guide/runtimes/autogen/interactions.md diff --git a/docs/docs/en/user-guide/runtime/autogen/websurfer.md b/docs/docs/en/user-guide/runtimes/autogen/websurfer.md similarity index 100% rename from docs/docs/en/user-guide/runtime/autogen/websurfer.md rename to docs/docs/en/user-guide/runtimes/autogen/websurfer.md diff --git a/docs/docs/en/user-guide/runtime/crewai/basics.md b/docs/docs/en/user-guide/runtimes/crewai/basics.md similarity index 100% rename from docs/docs/en/user-guide/runtime/crewai/basics.md rename to docs/docs/en/user-guide/runtimes/crewai/basics.md diff --git a/docs/docs/en/user-guide/runtime/index.md b/docs/docs/en/user-guide/runtimes/index.md similarity index 100% rename from docs/docs/en/user-guide/runtime/index.md rename to docs/docs/en/user-guide/runtimes/index.md diff --git a/docs/docs/en/user-guide/ui/console/basics.md b/docs/docs/en/user-guide/ui/console/basics.md index c6ba0f9e..b1b56b04 100644 --- a/docs/docs/en/user-guide/ui/console/basics.md +++ b/docs/docs/en/user-guide/ui/console/basics.md @@ -20,7 +20,7 @@ We begin by importing the necessary modules from **FastAgency** and **AutoGen**. - **ConversableAgent**: This class allows the creation of agents that can engage in conversational tasks. - **[FastAgency](../../../../api/fastagency/FastAgency/)**: The core class responsible for orchestrating workflows and connecting them with UIs. - **[UI](../../../../api/fastagency/UI/)** and **[ConsoleUI](../../../../api/fastagency/ui/console/ConsoleUI/)**: These classes define the user interface for interaction, with ConsoleUI providing a text-based interface. -- **[AutoGenWorkflows](../../../../api/fastagency/runtime/autogen/base/AutoGenWorkflows/)**: Manages the creation and execution of multi-agent workflows. +- **[AutoGenWorkflows](../../../../api/fastagency/runtimes/autogen/base/AutoGenWorkflows/)**: Manages the creation and execution of multi-agent workflows. #### 2. **Configure the Language Model (LLM)** Next, we configure the language model that will power the agents. In this case, we're using **GPT-4o**, and the API key is retrieved from the environment. diff --git a/docs/docs/en/user-guide/ui/mesop/basics.md b/docs/docs/en/user-guide/ui/mesop/basics.md index 68d34981..ed0f7b79 100644 --- a/docs/docs/en/user-guide/ui/mesop/basics.md +++ b/docs/docs/en/user-guide/ui/mesop/basics.md @@ -80,7 +80,7 @@ We begin by importing the necessary modules from **FastAgency** and **AutoGen**. - **ConversableAgent**: This class allows the creation of agents that can engage in conversational tasks. - **[FastAgency](../../../../api/fastagency/FastAgency/)**: The core class responsible for orchestrating workflows and connecting them with UIs. - **[UI](../../../../api/fastagency/UI/)** and **[MesopUI](../../../../api/fastagency/ui/mesop/MesopUI/)**: These classes define the user interface for interaction, with **MesopUI** enabling a web-based interaction. -- **[AutoGenWorkflows](../../../../api/fastagency/runtime/autogen/base/AutoGenWorkflows/)**: Manages the creation and execution of multi-agent workflows. +- **[AutoGenWorkflows](../../../../api/fastagency/runtimes/autogen/base/AutoGenWorkflows/)**: Manages the creation and execution of multi-agent workflows. #### 2. **Configure the Language Model (LLM)** Next, we configure the language model that powers the agents. In this case, we're using **GPT-4o**, and the API key is retrieved from the environment. diff --git a/docs/docs/navigation_template.txt b/docs/docs/navigation_template.txt index f3e44bf9..751395dc 100644 --- a/docs/docs/navigation_template.txt +++ b/docs/docs/navigation_template.txt @@ -5,12 +5,12 @@ search: - Getting Started - [Getting Started](getting-started/index.md) - [User guide](user-guide/index.md) - - [Runtimes](user-guide/runtime/index.md) - - [AutoGen](user-guide/runtime/autogen/index.md) + - [Runtimes](user-guide/runtimes/index.md) + - [AutoGen](user-guide/runtimes/autogen/index.md) - Agents - - [WebSurfer](user-guide/runtime/autogen/websurfer.md) - - [User interaction](user-guide/runtime/autogen/interactions.md) - - [CrewAI](user-guide/runtime/crewai/basics.md) + - [WebSurfer](user-guide/runtimes/autogen/websurfer.md) + - [User interaction](user-guide/runtimes/autogen/interactions.md) + - [CrewAI](user-guide/runtimes/crewai/basics.md) - [UI](user-guide/ui/index.md) - [Console](user-guide/ui/console/basics.md) - [Mesop](user-guide/ui/mesop/basics.md) diff --git a/docs/docs_src/getting_started/main_console.py b/docs/docs_src/getting_started/main_console.py index ce3223a8..7c34f9be 100644 --- a/docs/docs_src/getting_started/main_console.py +++ b/docs/docs_src/getting_started/main_console.py @@ -3,7 +3,7 @@ from autogen.agentchat import ConversableAgent from fastagency import UI, FastAgency, WorkflowsProtocol -from fastagency.runtime.autogen import AutoGenWorkflows +from fastagency.runtimes.autogen import AutoGenWorkflows from fastagency.ui.console import ConsoleUI llm_config = { diff --git a/docs/docs_src/getting_started/main_mesop.py b/docs/docs_src/getting_started/main_mesop.py index e22a1cb0..554188e9 100644 --- a/docs/docs_src/getting_started/main_mesop.py +++ b/docs/docs_src/getting_started/main_mesop.py @@ -3,7 +3,7 @@ from autogen.agentchat import ConversableAgent from fastagency import UI, FastAgency, WorkflowsProtocol -from fastagency.runtime.autogen import AutoGenWorkflows +from fastagency.runtimes.autogen import AutoGenWorkflows from fastagency.ui.mesop import MesopUI llm_config = { diff --git a/docs/docs_src/tutorial/giphy/main.py b/docs/docs_src/tutorial/giphy/main.py index 61ee7216..24516f49 100644 --- a/docs/docs_src/tutorial/giphy/main.py +++ b/docs/docs_src/tutorial/giphy/main.py @@ -7,12 +7,11 @@ from fastagency import UI, FastAgency, WorkflowsProtocol from fastagency.api.openapi.client import OpenAPI from fastagency.api.openapi.security import APIKeyQuery -from fastagency.base import TextInput -from fastagency.runtime.autogen.agents.websurfer import WebSurferAgent -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.messages import TextInput +from fastagency.runtimes.autogen.agents.websurfer import WebSurferAgent +from fastagency.runtimes.autogen.autogen import AutoGenWorkflows from fastagency.ui.mesop import MesopUI - llm_config = { "config_list": [ { diff --git a/docs/docs_src/tutorial/giphy/simple_main.py b/docs/docs_src/tutorial/giphy/simple_main.py index 79e081a4..6641896d 100644 --- a/docs/docs_src/tutorial/giphy/simple_main.py +++ b/docs/docs_src/tutorial/giphy/simple_main.py @@ -6,7 +6,7 @@ from fastagency import UI, FastAgency, WorkflowsProtocol from fastagency.api.openapi.client import OpenAPI from fastagency.api.openapi.security import APIKeyQuery -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.runtimes.autogen.autogen import AutoGenWorkflows from fastagency.ui.mesop import MesopUI open_api_key = os.getenv("OPENAI_API_KEY") diff --git a/docs/docs_src/user_guide/custom_user_interactions/main.py b/docs/docs_src/user_guide/custom_user_interactions/main.py index f293e542..228e8e0b 100644 --- a/docs/docs_src/user_guide/custom_user_interactions/main.py +++ b/docs/docs_src/user_guide/custom_user_interactions/main.py @@ -5,8 +5,8 @@ from autogen.agentchat import ConversableAgent from fastagency import UI, FastAgency, WorkflowsProtocol -from fastagency.base import MultipleChoice, SystemMessage, TextInput -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.messages import MultipleChoice, SystemMessage, TextInput +from fastagency.runtimes.autogen.autogen import AutoGenWorkflows from fastagency.ui.console import ConsoleUI llm_config = { diff --git a/docs/docs_src/user_guide/external_rest_apis/main.py b/docs/docs_src/user_guide/external_rest_apis/main.py index 91bb5a30..c4b8fb8b 100644 --- a/docs/docs_src/user_guide/external_rest_apis/main.py +++ b/docs/docs_src/user_guide/external_rest_apis/main.py @@ -5,7 +5,7 @@ from fastagency import UI, FastAgency, WorkflowsProtocol from fastagency.api.openapi import OpenAPI -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.runtimes.autogen.autogen import AutoGenWorkflows from fastagency.ui.console import ConsoleUI llm_config = { diff --git a/docs/docs_src/user_guide/external_rest_apis/security.py b/docs/docs_src/user_guide/external_rest_apis/security.py index f123b415..eb6c90f1 100644 --- a/docs/docs_src/user_guide/external_rest_apis/security.py +++ b/docs/docs_src/user_guide/external_rest_apis/security.py @@ -6,7 +6,7 @@ from fastagency import UI, FastAgency, WorkflowsProtocol from fastagency.api.openapi.client import OpenAPI from fastagency.api.openapi.security import APIKeyHeader -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.runtimes.autogen.autogen import AutoGenWorkflows from fastagency.ui.console import ConsoleUI llm_config = { diff --git a/docs/docs_src/user_guide/runtime/__init__.py b/docs/docs_src/user_guide/runtimes/__init__.py similarity index 100% rename from docs/docs_src/user_guide/runtime/__init__.py rename to docs/docs_src/user_guide/runtimes/__init__.py diff --git a/docs/docs_src/user_guide/runtime/autogen/__init__.py b/docs/docs_src/user_guide/runtimes/autogen/__init__.py similarity index 100% rename from docs/docs_src/user_guide/runtime/autogen/__init__.py rename to docs/docs_src/user_guide/runtimes/autogen/__init__.py diff --git a/docs/docs_src/user_guide/runtime/autogen/main.py b/docs/docs_src/user_guide/runtimes/autogen/main.py similarity index 96% rename from docs/docs_src/user_guide/runtime/autogen/main.py rename to docs/docs_src/user_guide/runtimes/autogen/main.py index 1a9e2c54..809245ea 100644 --- a/docs/docs_src/user_guide/runtime/autogen/main.py +++ b/docs/docs_src/user_guide/runtimes/autogen/main.py @@ -5,7 +5,7 @@ from fastagency import UI, FastAgency from fastagency.api.openapi import OpenAPI -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.runtimes.autogen.autogen import AutoGenWorkflows from fastagency.ui.console import ConsoleUI llm_config = { diff --git a/docs/docs_src/user_guide/runtime/autogen/websurfer.py b/docs/docs_src/user_guide/runtimes/autogen/websurfer.py similarity index 90% rename from docs/docs_src/user_guide/runtime/autogen/websurfer.py rename to docs/docs_src/user_guide/runtimes/autogen/websurfer.py index 087dfdcc..a6e0fe7a 100644 --- a/docs/docs_src/user_guide/runtime/autogen/websurfer.py +++ b/docs/docs_src/user_guide/runtimes/autogen/websurfer.py @@ -3,8 +3,8 @@ from autogen import UserProxyAgent from fastagency import UI, FastAgency -from fastagency.runtime.autogen import AutoGenWorkflows -from fastagency.runtime.autogen.agents.websurfer import WebSurferAgent +from fastagency.runtimes.autogen import AutoGenWorkflows +from fastagency.runtimes.autogen.agents.websurfer import WebSurferAgent from fastagency.ui.console import ConsoleUI llm_config = { diff --git a/docs/docs_src/user_guide/runtime/autogen/websurfer_tool.py b/docs/docs_src/user_guide/runtimes/autogen/websurfer_tool.py similarity index 92% rename from docs/docs_src/user_guide/runtime/autogen/websurfer_tool.py rename to docs/docs_src/user_guide/runtimes/autogen/websurfer_tool.py index ec7046f4..438709ec 100644 --- a/docs/docs_src/user_guide/runtime/autogen/websurfer_tool.py +++ b/docs/docs_src/user_guide/runtimes/autogen/websurfer_tool.py @@ -4,8 +4,8 @@ from autogen.agentchat import ConversableAgent from fastagency import UI, FastAgency -from fastagency.runtime.autogen import AutoGenWorkflows -from fastagency.runtime.autogen.tools import WebSurferTool +from fastagency.runtimes.autogen import AutoGenWorkflows +from fastagency.runtimes.autogen.tools import WebSurferTool from fastagency.ui.console import ConsoleUI llm_config = { diff --git a/docs/docs_src/user_guide/ui/mesop/main_mesop.py b/docs/docs_src/user_guide/ui/mesop/main_mesop.py index b76d1abf..559da683 100644 --- a/docs/docs_src/user_guide/ui/mesop/main_mesop.py +++ b/docs/docs_src/user_guide/ui/mesop/main_mesop.py @@ -1,11 +1,10 @@ import os import mesop as me - from autogen.agentchat import ConversableAgent from fastagency import UI, FastAgency, WorkflowsProtocol -from fastagency.runtime.autogen import AutoGenWorkflows +from fastagency.runtimes.autogen import AutoGenWorkflows from fastagency.ui.mesop import MesopUI from fastagency.ui.mesop.styles import ( MesopHomePageStyles, diff --git a/examples/cli/main_console.py b/examples/cli/main_console.py index 877e86be..d3f438c8 100644 --- a/examples/cli/main_console.py +++ b/examples/cli/main_console.py @@ -3,7 +3,7 @@ from autogen.agentchat import ConversableAgent from fastagency import UI, FastAgency -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.runtimes.autogen.autogen import AutoGenWorkflows from fastagency.ui.console import ConsoleUI llm_config = { diff --git a/examples/cli/main_mesop.py b/examples/cli/main_mesop.py index fa26cc6d..2e76e38c 100644 --- a/examples/cli/main_mesop.py +++ b/examples/cli/main_mesop.py @@ -3,7 +3,7 @@ from autogen.agentchat import ConversableAgent from fastagency import UI, FastAgency, WorkflowsProtocol -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.runtimes.autogen.autogen import AutoGenWorkflows from fastagency.ui.mesop import MesopUI llm_config = { diff --git a/examples/cli/main_user_proxy.py b/examples/cli/main_user_proxy.py index e1630d36..9bccae57 100644 --- a/examples/cli/main_user_proxy.py +++ b/examples/cli/main_user_proxy.py @@ -5,7 +5,7 @@ from fastagency import UI, FastAgency from fastagency.api.openapi.client import OpenAPI from fastagency.api.openapi.security import APIKeyHeader -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.runtimes.autogen.autogen import AutoGenWorkflows from fastagency.ui.console import ConsoleUI llm_config = { diff --git a/examples/cli/nats-n-fastapi/1_main_natsprovider.py b/examples/cli/nats-n-fastapi/1_main_natsprovider.py index ab7fd34c..7a1538dd 100644 --- a/examples/cli/nats-n-fastapi/1_main_natsprovider.py +++ b/examples/cli/nats-n-fastapi/1_main_natsprovider.py @@ -7,7 +7,7 @@ from fastagency import UI from fastagency.adapters.nats import NatsAdapter from fastagency.logging import get_logger -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.runtimes.autogen.autogen import AutoGenWorkflows llm_config = { "config_list": [ diff --git a/fastagency/__init__.py b/fastagency/__init__.py index 50ea13a4..72e43377 100644 --- a/fastagency/__init__.py +++ b/fastagency/__init__.py @@ -2,8 +2,8 @@ from .__about__ import __version__ from .app import FastAgency -from .base import ( - UI, +from .base import UI, Workflow, WorkflowsProtocol +from .messages import ( FunctionCallExecution, IOMessage, MessageType, @@ -11,8 +11,6 @@ SuggestedFunctionCall, TextInput, TextMessage, - Workflow, - WorkflowsProtocol, ) __all__ = [ diff --git a/fastagency/adapters/fastapi/base.py b/fastagency/adapters/fastapi/base.py index 5a3e3cae..aa4a2920 100644 --- a/fastagency/adapters/fastapi/base.py +++ b/fastagency/adapters/fastapi/base.py @@ -3,7 +3,6 @@ import asyncio import json import re -from collections.abc import Iterable, Mapping from typing import Any, Callable, Optional, Union from uuid import UUID, uuid4 @@ -15,21 +14,18 @@ from fastagency.logging import get_logger -from ...base import ( - UI, - Agent, +from ...base import UI, ProviderProtocol, WorkflowsProtocol +from ...messages import ( AskingMessage, IOMessage, - IOMessageVisitor, - Workflow, - WorkflowsProtocol, + MessageProcessorMixin, ) from ..nats import InitiateModel, InputResponseModel, NatsProvider logger = get_logger(__name__) -class FastAPIAdapter(IOMessageVisitor): +class FastAPIAdapter(MessageProcessorMixin): def __init__( self, provider: NatsProvider, @@ -123,7 +119,7 @@ def create_provider( nats_url: Optional[str] = None, nats_user: Optional[str] = None, nats_password: Optional[str] = None, - ) -> WorkflowsProtocol: + ) -> ProviderProtocol: return FastAPIProvider( fastapi_url=fastapi_url, fastapi_user=fastapi_user, @@ -134,7 +130,7 @@ def create_provider( ) -class FastAPIProvider(WorkflowsProtocol): +class FastAPIProvider: def __init__( self, fastapi_url: str, @@ -167,11 +163,6 @@ def __init__( self.is_broker_running: bool = False - def register( - self, name: str, description: str, *, fail_on_redefintion: bool = False - ) -> Callable[[Workflow], Workflow]: - raise NotImplementedError("Just ignore this for now; @register") - def _send_initiate_chat_msg( self, workflow_name: str, initial_message: str ) -> dict[str, str]: @@ -290,16 +281,3 @@ def names(self) -> list[str]: def get_description(self, name: str) -> str: return "Student and teacher learning chat" - - def register_api( - self, - api: Any, - callers: Union[Agent, Iterable[Agent]], - executors: Union[Agent, Iterable[Agent]], - functions: Optional[ - Union[str, Iterable[Union[str, Mapping[str, Mapping[str, str]]]]] - ] = None, - ) -> None: - raise NotImplementedError( - "Just ignore this for now, will be removed from this protocol; @register_api" - ) diff --git a/fastagency/adapters/nats/base.py b/fastagency/adapters/nats/base.py index c9afa99b..b53f9339 100644 --- a/fastagency/adapters/nats/base.py +++ b/fastagency/adapters/nats/base.py @@ -15,18 +15,16 @@ from nats.js import api from pydantic import BaseModel -from ...base import ( - UI, +from ...base import UI, ProviderProtocol, run_workflow +from ...logging import get_logger +from ...messages import ( AskingMessage, IOMessage, - IOMessageVisitor, + MessageProcessorMixin, MultipleChoice, - ProviderProtocol, TextInput, TextMessage, - run_workflow, ) -from ...logging import get_logger if TYPE_CHECKING: from faststream.nats.subscriber.asyncapi import AsyncAPISubscriber @@ -61,7 +59,7 @@ class InitiateModel(BaseModel): ) -class NatsAdapter(IOMessageVisitor): +class NatsAdapter(MessageProcessorMixin): def __init__( self, provider: ProviderProtocol, diff --git a/fastagency/base.py b/fastagency/base.py index 0c931584..d687e143 100644 --- a/fastagency/base.py +++ b/fastagency/base.py @@ -1,231 +1,42 @@ -import re -import textwrap -from abc import ABC, abstractmethod from collections.abc import Awaitable, Generator, Iterable, Iterator, Mapping from contextlib import contextmanager -from dataclasses import asdict, dataclass, field, fields from typing import ( TYPE_CHECKING, Any, Callable, - Literal, Optional, Protocol, - Type, TypeVar, Union, runtime_checkable, ) -from uuid import uuid4 + +from .messages import ( + MessageProcessorProtocol, + TextInput, + WorkflowCompleted, + WorkflowStarted, +) if TYPE_CHECKING: from fastagency.api.openapi import OpenAPI __all__ = [ "UI", - "FunctionCallExecution", - "IOMessage", - "MessageType", - "MultipleChoice", + "WSGIProtocol", + "ASGIProtocol", + "ProviderProtocol", + "WorkflowsProtocol", + "AdapterProtocol", "Runnable", - "SuggestedFunctionCall", - "KeepAlive", - "SystemMessage", - "TextInput", - "TextMessage", "Workflow", - "WorkflowCompleted", - "WorkflowsProtocol", + "Agent", "run_workflow", ] -MessageType = Literal[ - "text_message", - "suggested_function_call", - "function_call_execution", - "text_input", - "multiple_choice", - "system_message", - "keep_alive", - "workflow_completed", - "error", -] - - -def _camel_to_snake(name: str) -> str: - name = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", name) - return re.sub("([a-z0-9])([A-Z])", r"\1_\2", name).lower() - - -@dataclass -class IOMessage(ABC): # noqa: B024 # `IOMessage` is an abstract base class, but it has no abstract methods - sender: Optional[str] = None - recipient: Optional[str] = None - # streaming: bool = False - auto_reply: bool = False - uuid: str = field(default_factory=lambda: str(uuid4().hex)) - - @property - def type(self) -> MessageType: - retval: MessageType = _camel_to_snake(self.__class__.__name__) # type: ignore[assignment] - return retval - - @staticmethod - def _get_message_class(type: Optional[MessageType]) -> "Type[IOMessage]": - type = type or "text_message" - lookup: dict[MessageType, "Type[IOMessage]"] = { - "text_message": TextMessage, - "suggested_function_call": SuggestedFunctionCall, - "function_call_execution": FunctionCallExecution, - "text_input": TextInput, - "multiple_choice": MultipleChoice, - "keep_alive": KeepAlive, - "system_message": SystemMessage, - "workflow_completed": WorkflowCompleted, - "error": Error, - } - return lookup[type] - - @staticmethod - def create(type: Optional[MessageType] = None, **kwargs: Any) -> "IOMessage": - cls = IOMessage._get_message_class(type) - - content = kwargs.pop("content", {}) - kwargs.update(content) - - return cls(**kwargs) - - @staticmethod - def _get_parameters_names() -> list[str]: - return [field.name for field in fields(IOMessage)] - - def model_dump(self) -> dict[str, Any]: - params_names = IOMessage._get_parameters_names() - d = asdict(self) - content = {k: v for k, v in d.items() if k not in params_names} - retval = {k: v for k, v in d.items() if k in params_names} - retval["content"] = content - retval["type"] = self.type - return retval - - -# message type that asks user something - - -@dataclass -class AskingMessage(IOMessage): ... - - -# type of output messages -@dataclass -class TextMessage(IOMessage): - body: Optional[str] = None - - def __post_init__(self) -> None: - """Set the default value for the `type` attribute.""" - if self.type is None: - self.type = "text_message" - - -@dataclass -class SuggestedFunctionCall(IOMessage): - function_name: Optional[str] = None - call_id: Optional[str] = None - arguments: dict[str, Any] = field(default_factory=dict) - - -@dataclass -class FunctionCallExecution(IOMessage): - function_name: Optional[str] = None - call_id: Optional[str] = None - retval: Any = None - - -# types of input messages -@dataclass -class TextInput(AskingMessage): - prompt: Optional[str] = None - suggestions: list[str] = field(default_factory=list) - password: bool = False - - -@dataclass -class MultipleChoice(AskingMessage): - prompt: Optional[str] = None - choices: list[str] = field(default_factory=list) - default: Optional[str] = None - single: bool = True - # todo: add validation - - -@dataclass -class SystemMessage(IOMessage): - message: dict[str, Any] = field(default_factory=dict) - - -@dataclass -class WorkflowCompleted(IOMessage): - result: Optional[str] = None - - -@dataclass -class Error(IOMessage): - short: Optional[str] = None - long: Optional[str] = None - - -@dataclass -class KeepAlive(IOMessage): ... - - -class IOMessageVisitor(ABC): - def visit(self, message: IOMessage) -> Optional[str]: - method_name = f"visit_{message.type}" - method = getattr(self, method_name, self.visit_default) - return method(message) - - @abstractmethod - def visit_default(self, message: IOMessage) -> Optional[str]: ... - - def visit_text_message(self, message: TextMessage) -> Optional[str]: - return self.visit_default(message) - - def visit_suggested_function_call( - self, message: SuggestedFunctionCall - ) -> Optional[str]: - return self.visit_default(message) - - def visit_function_call_execution( - self, message: FunctionCallExecution - ) -> Optional[str]: - return self.visit_default(message) - - def visit_text_input(self, message: TextInput) -> Optional[str]: - return self.visit_default(message) - - def visit_multiple_choice(self, message: MultipleChoice) -> Optional[str]: - return self.visit_default(message) - - def visit_system_message(self, message: SystemMessage) -> Optional[str]: - return self.visit_default(message) - - def visit_keep_alive(self, message: KeepAlive) -> Optional[str]: - return self.visit_default(message) - - def visit_workflow_completed(self, message: WorkflowCompleted) -> Optional[str]: - return self.visit_default(message) - - def visit_error(self, message: Error) -> Optional[str]: - return self.visit_default(message) - - -# @dataclass -# class IOStreamingMessage: -# chunk: str - @runtime_checkable -class UI(Protocol): +class UI(MessageProcessorProtocol, Protocol): @contextmanager def create(self, app: "Runnable", import_string: str) -> Iterator[None]: ... @@ -239,8 +50,6 @@ def start( single_run: bool = False, ) -> None: ... - def process_message(self, message: IOMessage) -> Optional[str]: ... - # def process_streaming_message( # self, message: IOStreamingMessage # ) -> Optional[str]: ... @@ -371,18 +180,12 @@ def run_workflow( ) else: ui.process_message( - SystemMessage( + WorkflowStarted( sender="FastAgency", recipient="user", - message={ - "body": ( - f"Starting a new workflow '{name}' with the following description:" - + "\n\n" - + textwrap.indent(description, prefix=" " * 2) - + "\n\nand using the following initial message:" - + textwrap.indent(initial_message, prefix=" " * 2) - ) - }, + name=name, + description=description, + params={"initial_message": initial_message}, ) ) diff --git a/fastagency/messages.py b/fastagency/messages.py new file mode 100644 index 00000000..290280c9 --- /dev/null +++ b/fastagency/messages.py @@ -0,0 +1,596 @@ +import re +from abc import ABC, abstractmethod +from dataclasses import asdict, dataclass, field, fields +from typing import Any, Literal, Optional, Protocol, Type +from uuid import uuid4 + +from .logging import get_logger + +__all__ = [ + "IOMessage", + "TextMessage", + "SuggestedFunctionCall", + "FunctionCallExecution", + "TextInput", + "MultipleChoice", + "SystemMessage", + "KeepAlive", + "WorkflowStarted", + "WorkflowCompleted", + "Error", + "MessageType", + "MessageProcessorProtocol", + "MessageProcessorMixin", +] + + +logger = get_logger(__name__) + + +def _camel_to_snake(name: str) -> str: + name = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", name) + return re.sub("([a-z0-9])([A-Z])", r"\1_\2", name).lower() + + +# we keep this hardcoded for mypy and type checks +MessageType = Literal[ + "text_message", + "suggested_function_call", + "function_call_execution", + "text_input", + "multiple_choice", + "system_message", + "keep_alive", + "workflow_started", + "workflow_completed", + "error", +] + + +@dataclass +class IOMessage(ABC): # noqa: B024 # `IOMessage` is an abstract base class, but it has no abstract methods + sender: Optional[str] = None + recipient: Optional[str] = None + auto_reply: bool = False + uuid: str = field(default_factory=lambda: str(uuid4().hex)) + workflow_id: Optional[str] = None + + @property + def type(self) -> MessageType: + retval: MessageType = _camel_to_snake(self.__class__.__name__) # type: ignore[assignment] + return retval + + @staticmethod + def _get_message_class(type: Optional[MessageType]) -> "Type[IOMessage]": + type = type or "text_message" + lookup: dict[MessageType, "Type[IOMessage]"] = { + "text_message": TextMessage, + "suggested_function_call": SuggestedFunctionCall, + "function_call_execution": FunctionCallExecution, + "text_input": TextInput, + "multiple_choice": MultipleChoice, + "keep_alive": KeepAlive, + "system_message": SystemMessage, + "workflow_started": WorkflowStarted, + "workflow_completed": WorkflowCompleted, + "error": Error, + } + return lookup[type] + + @staticmethod + def create(type: Optional[MessageType] = None, **kwargs: Any) -> "IOMessage": + cls = IOMessage._get_message_class(type) + + content = kwargs.pop("content", {}) + kwargs.update(content) + + return cls(**kwargs) + + @staticmethod + def _get_parameters_names() -> list[str]: + return [field.name for field in fields(IOMessage)] + + def model_dump(self) -> dict[str, Any]: + params_names = IOMessage._get_parameters_names() + d = asdict(self) + content = {k: v for k, v in d.items() if k not in params_names} + retval = {k: v for k, v in d.items() if k in params_names} + retval["content"] = content + retval["type"] = self.type + return retval + + +# message type that asks user something + + +@dataclass +class AskingMessage(IOMessage): ... + + +# type of output messages +@dataclass +class TextMessage(IOMessage): + body: Optional[str] = None + + def __post_init__(self) -> None: + """Set the default value for the `type` attribute.""" + if self.type is None: + self.type = "text_message" + + +@dataclass +class SuggestedFunctionCall(IOMessage): + function_name: Optional[str] = None + call_id: Optional[str] = None + arguments: dict[str, Any] = field(default_factory=dict) + + +@dataclass +class FunctionCallExecution(IOMessage): + function_name: Optional[str] = None + call_id: Optional[str] = None + retval: Any = None + + +# types of input messages +@dataclass +class TextInput(AskingMessage): + prompt: Optional[str] = None + suggestions: list[str] = field(default_factory=list) + password: bool = False + + +@dataclass +class MultipleChoice(AskingMessage): + prompt: Optional[str] = None + choices: list[str] = field(default_factory=list) + default: Optional[str] = None + single: bool = True + # todo: add validation + + +@dataclass +class SystemMessage(IOMessage): + message: dict[str, Any] = field(default_factory=dict) + + +@dataclass +class WorkflowStarted(IOMessage): + name: Optional[str] = None + description: Optional[str] = None + params: dict[str, Any] = field(default_factory=dict) + + +@dataclass +class WorkflowCompleted(IOMessage): + result: Optional[str] = None + + +@dataclass +class Error(IOMessage): + short: Optional[str] = None + long: Optional[str] = None + + +@dataclass +class KeepAlive(IOMessage): ... + + +class MessageProcessorProtocol(Protocol): + def process_message(self, message: IOMessage) -> Optional[str]: ... + + def text_message( + self, + # common parameters for all messages + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + # text_message specific parameters + body: Optional[str] = None, + ) -> Optional[str]: ... + + def suggested_function_call( + self, + # common parameters for all messages + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + # suggested_function_call specific parameters + function_name: Optional[str] = None, + call_id: Optional[str] = None, + arguments: Optional[dict[str, Any]] = None, + ) -> Optional[str]: ... + + def function_call_execution( + self, + # common parameters for all messages + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + # function_call_execution specific parameters + function_name: Optional[str] = None, + call_id: Optional[str] = None, + retval: Any = None, + ) -> Optional[str]: ... + + def text_input( + self, + # common parameters for all messages + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + # text_input specific parameters + prompt: Optional[str] = None, + suggestions: Optional[list[str]] = None, + password: bool = False, + ) -> Optional[str]: ... + + def multiple_choice( + self, + # common parameters for all messages + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + # multiple_choice specific parameters + prompt: Optional[str] = None, + choices: Optional[list[str]] = None, + default: Optional[str] = None, + single: bool = True, + ) -> Optional[str]: ... + + def system_message( + self, + # common parameters for all messages + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + # system_message specific parameters + message: Optional[dict[str, Any]] = None, + ) -> Optional[str]: ... + + def workflow_started( + self, + # common parameters for all messages + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + # workflow_started specific parameters + name: Optional[str] = None, + description: Optional[str] = None, + params: Optional[dict[str, Any]] = None, + ) -> Optional[str]: ... + + def workflow_completed( + self, + # common parameters for all messages + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + # workflow_completed specific parameters + result: Optional[str] = None, + ) -> Optional[str]: ... + + def error( + self, + # common parameters for all messages + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + # error specific parameters + short: Optional[str] = None, + long: Optional[str] = None, + ) -> Optional[str]: ... + + def keep_alive( + self, + # common parameters for all messages + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + ) -> Optional[str]: ... + + +class MessageProcessorMixin(ABC): + def visit(self, message: IOMessage) -> Optional[str]: + method_name = f"visit_{message.type}" + method = getattr(self, method_name, self.visit_default) + return method(message) + + @abstractmethod + def visit_default(self, message: IOMessage) -> Optional[str]: ... + + def visit_text_message(self, message: TextMessage) -> Optional[str]: + return self.visit_default(message) + + def visit_suggested_function_call( + self, message: SuggestedFunctionCall + ) -> Optional[str]: + return self.visit_default(message) + + def visit_function_call_execution( + self, message: FunctionCallExecution + ) -> Optional[str]: + return self.visit_default(message) + + def visit_text_input(self, message: TextInput) -> Optional[str]: + return self.visit_default(message) + + def visit_multiple_choice(self, message: MultipleChoice) -> Optional[str]: + return self.visit_default(message) + + def visit_system_message(self, message: SystemMessage) -> Optional[str]: + return self.visit_default(message) + + def visit_keep_alive(self, message: KeepAlive) -> Optional[str]: + return self.visit_default(message) + + def visit_workflow_completed(self, message: WorkflowCompleted) -> Optional[str]: + return self.visit_default(message) + + def visit_error(self, message: Error) -> Optional[str]: + return self.visit_default(message) + + def process_message(self, message: IOMessage) -> Optional[str]: + try: + return self.visit(message) + except Exception as e: + # log the error and return None + logger.error(f"Error processing message: {e}") + return None + + def text_message( + self, + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + body: Optional[str] = None, + ) -> Optional[str]: + uuid = uuid or str(uuid4().hex) + return self.process_message( + TextMessage( + sender=sender, + recipient=recipient, + auto_reply=auto_reply, + uuid=uuid, + workflow_id=workflow_id, + body=body, + ) + ) + + def suggested_function_call( + self, + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + function_name: Optional[str] = None, + call_id: Optional[str] = None, + arguments: Optional[dict[str, Any]] = None, + ) -> Optional[str]: + uuid = uuid or str(uuid4().hex) + arguments = arguments or {} + return self.process_message( + SuggestedFunctionCall( + sender=sender, + recipient=recipient, + auto_reply=auto_reply, + uuid=uuid, + workflow_id=workflow_id, + function_name=function_name, + call_id=call_id, + arguments=arguments, + ) + ) + + def function_call_execution( + self, + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + function_name: Optional[str] = None, + call_id: Optional[str] = None, + retval: Any = None, + ) -> Optional[str]: + uuid = uuid or str(uuid4().hex) + return self.process_message( + FunctionCallExecution( + sender=sender, + recipient=recipient, + auto_reply=auto_reply, + uuid=uuid, + workflow_id=workflow_id, + function_name=function_name, + call_id=call_id, + retval=retval, + ) + ) + + def text_input( + self, + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + prompt: Optional[str] = None, + suggestions: Optional[list[str]] = None, + password: bool = False, + ) -> Optional[str]: + uuid = uuid or str(uuid4().hex) + suggestions = suggestions or [] + return self.process_message( + TextInput( + sender=sender, + recipient=recipient, + auto_reply=auto_reply, + uuid=uuid, + workflow_id=workflow_id, + prompt=prompt, + suggestions=suggestions, + password=password, + ) + ) + + def multiple_choice( + self, + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + prompt: Optional[str] = None, + choices: Optional[list[str]] = None, + default: Optional[str] = None, + single: bool = True, + ) -> Optional[str]: + uuid = uuid or str(uuid4().hex) + choices = choices or [] + return self.process_message( + MultipleChoice( + sender=sender, + recipient=recipient, + auto_reply=auto_reply, + uuid=uuid, + workflow_id=workflow_id, + prompt=prompt, + choices=choices, + default=default, + single=single, + ) + ) + + def system_message( + self, + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + message: Optional[dict[str, Any]] = None, + ) -> Optional[str]: + uuid = uuid or str(uuid4().hex) + message = message or {} + return self.process_message( + SystemMessage( + sender=sender, + recipient=recipient, + auto_reply=auto_reply, + uuid=uuid, + workflow_id=workflow_id, + message=message, + ) + ) + + def workflow_started( + self, + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + name: Optional[str] = None, + description: Optional[str] = None, + params: Optional[dict[str, Any]] = None, + ) -> Optional[str]: + uuid = uuid or str(uuid4().hex) + params = params or {} + return self.process_message( + WorkflowStarted( + sender=sender, + recipient=recipient, + auto_reply=auto_reply, + uuid=uuid, + workflow_id=workflow_id, + name=name, + description=description, + params=params, + ) + ) + + def workflow_completed( + self, + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + result: Optional[str] = None, + ) -> Optional[str]: + uuid = uuid or str(uuid4().hex) + return self.process_message( + WorkflowCompleted( + sender=sender, + recipient=recipient, + auto_reply=auto_reply, + uuid=uuid, + workflow_id=workflow_id, + result=result, + ) + ) + + def error( + self, + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + short: Optional[str] = None, + long: Optional[str] = None, + ) -> Optional[str]: + uuid = uuid or str(uuid4().hex) + return self.process_message( + Error( + sender=sender, + recipient=recipient, + auto_reply=auto_reply, + uuid=uuid, + workflow_id=workflow_id, + short=short, + long=long, + ) + ) + + def keep_alive( + self, + sender: Optional[str] = None, + recipient: Optional[str] = None, + auto_reply: bool = False, + uuid: Optional[str] = None, + workflow_id: Optional[str] = None, + ) -> Optional[str]: + uuid = uuid or str(uuid4().hex) + return self.process_message( + KeepAlive( + sender=sender, + recipient=recipient, + auto_reply=auto_reply, + uuid=uuid, + workflow_id=workflow_id, + ) + ) diff --git a/fastagency/runtime/__init__.py b/fastagency/runtimes/__init__.py similarity index 100% rename from fastagency/runtime/__init__.py rename to fastagency/runtimes/__init__.py diff --git a/fastagency/runtime/autogen/__init__.py b/fastagency/runtimes/autogen/__init__.py similarity index 65% rename from fastagency/runtime/autogen/__init__.py rename to fastagency/runtimes/autogen/__init__.py index 5926f639..a4dc920b 100644 --- a/fastagency/runtime/autogen/__init__.py +++ b/fastagency/runtimes/autogen/__init__.py @@ -3,6 +3,6 @@ check_imports(["autogen"], "autogen") -from .base import AutoGenWorkflows, IOStreamAdapter # noqa: E402 +from .autogen import AutoGenWorkflows, IOStreamAdapter # noqa: E402 __all__ = ["IOStreamAdapter", "AutoGenWorkflows"] diff --git a/fastagency/runtime/autogen/agents/__init__.py b/fastagency/runtimes/autogen/agents/__init__.py similarity index 100% rename from fastagency/runtime/autogen/agents/__init__.py rename to fastagency/runtimes/autogen/agents/__init__.py diff --git a/fastagency/runtime/autogen/agents/websurfer.py b/fastagency/runtimes/autogen/agents/websurfer.py similarity index 100% rename from fastagency/runtime/autogen/agents/websurfer.py rename to fastagency/runtimes/autogen/agents/websurfer.py diff --git a/fastagency/runtime/autogen/base.py b/fastagency/runtimes/autogen/autogen.py similarity index 99% rename from fastagency/runtime/autogen/base.py rename to fastagency/runtimes/autogen/autogen.py index b7ea9af0..5773ec56 100644 --- a/fastagency/runtime/autogen/base.py +++ b/fastagency/runtimes/autogen/autogen.py @@ -15,17 +15,15 @@ from autogen.agentchat import ConversableAgent from autogen.io import IOStream -from ...base import ( - UI, +from ...base import UI, Workflow, WorkflowsProtocol +from ...logging import get_logger +from ...messages import ( AskingMessage, IOMessage, MessageType, MultipleChoice, TextInput, - Workflow, - WorkflowsProtocol, ) -from ...logging import get_logger if TYPE_CHECKING: from fastagency.api.openapi import OpenAPI diff --git a/fastagency/runtime/autogen/tools/__init__.py b/fastagency/runtimes/autogen/tools/__init__.py similarity index 100% rename from fastagency/runtime/autogen/tools/__init__.py rename to fastagency/runtimes/autogen/tools/__init__.py diff --git a/fastagency/runtime/autogen/tools/web_surfer.py b/fastagency/runtimes/autogen/tools/web_surfer.py similarity index 100% rename from fastagency/runtime/autogen/tools/web_surfer.py rename to fastagency/runtimes/autogen/tools/web_surfer.py diff --git a/fastagency/ui/console/__init__.py b/fastagency/ui/console/__init__.py index eea5d192..14501034 100644 --- a/fastagency/ui/console/__init__.py +++ b/fastagency/ui/console/__init__.py @@ -1,3 +1,3 @@ -from .base import ConsoleUI +from .console import ConsoleUI __all__ = ["ConsoleUI"] diff --git a/fastagency/ui/console/base.py b/fastagency/ui/console/console.py similarity index 98% rename from fastagency/ui/console/base.py rename to fastagency/ui/console/console.py index a4b39d45..6a37467b 100644 --- a/fastagency/ui/console/base.py +++ b/fastagency/ui/console/console.py @@ -7,20 +7,22 @@ from typing import Optional from ...base import ( + Runnable, + run_workflow, +) +from ...logging import get_logger +from ...messages import ( IOMessage, - IOMessageVisitor, + MessageProcessorMixin, MultipleChoice, - Runnable, TextInput, TextMessage, - run_workflow, ) -from ...logging import get_logger logger = get_logger(__name__) -class ConsoleUI(IOMessageVisitor): # implements UI +class ConsoleUI(MessageProcessorMixin): # implements UI @dataclass class ConsoleMessage: """A console message.""" diff --git a/fastagency/ui/mesop/__init__.py b/fastagency/ui/mesop/__init__.py index d934ce3c..32de8033 100644 --- a/fastagency/ui/mesop/__init__.py +++ b/fastagency/ui/mesop/__init__.py @@ -8,6 +8,6 @@ check_imports(["mesop"], "mesop") -from .base import MesopUI # noqa: E402 +from .mesop import MesopUI # noqa: E402 __all__ = ["MesopUI"] diff --git a/fastagency/ui/mesop/main.py b/fastagency/ui/mesop/main.py index 4e685aa0..4958ae0a 100644 --- a/fastagency/ui/mesop/main.py +++ b/fastagency/ui/mesop/main.py @@ -13,7 +13,7 @@ from .styles import MesopHomePageStyles if TYPE_CHECKING: - from .base import MesopUI + from .mesop import MesopUI __all__ = ["me"] diff --git a/fastagency/ui/mesop/base.py b/fastagency/ui/mesop/mesop.py similarity index 98% rename from fastagency/ui/mesop/base.py rename to fastagency/ui/mesop/mesop.py index 05d64898..96841aee 100644 --- a/fastagency/ui/mesop/base.py +++ b/fastagency/ui/mesop/mesop.py @@ -13,19 +13,18 @@ from mesop.bin.bin import FLAGS as MESOP_FLAGS from mesop.bin.bin import main as mesop_main -from ...base import ( +from ...base import ProviderProtocol, Runnable +from ...logging import get_logger +from ...messages import ( AskingMessage, IOMessage, - IOMessageVisitor, KeepAlive, + MessageProcessorMixin, MultipleChoice, - ProviderProtocol, - Runnable, TextInput, TextMessage, WorkflowCompleted, ) -from ...logging import get_logger from .styles import MesopHomePageStyles from .timer import configure_static_file_serving @@ -40,7 +39,7 @@ class MesopMessage: conversation: "MesopUI" -class MesopUI(IOMessageVisitor): # UI +class MesopUI(MessageProcessorMixin): # UI _import_string: Optional[str] = None _main_path: Optional[str] = None _created_instance: Optional["MesopUI"] = None diff --git a/fastagency/ui/mesop/message.py b/fastagency/ui/mesop/message.py index 07e173e5..5a2aea6c 100644 --- a/fastagency/ui/mesop/message.py +++ b/fastagency/ui/mesop/message.py @@ -8,13 +8,14 @@ from fastagency.helpers import jsonify_string -from ...base import ( +from ...logging import get_logger +from ...messages import ( AskingMessage, Error, FunctionCallExecution, IOMessage, - IOMessageVisitor, KeepAlive, + MessageProcessorMixin, MultipleChoice, SuggestedFunctionCall, SystemMessage, @@ -22,10 +23,9 @@ TextMessage, WorkflowCompleted, ) -from ...logging import get_logger -from .base import MesopMessage from .components.inputs import input_text from .data_model import Conversation, ConversationMessage, State +from .mesop import MesopMessage from .send_prompt import get_more_messages, send_user_feedback_to_autogen from .styles import MesopHomePageStyles, MesopMessageStyles from .timer import wakeup_component @@ -89,7 +89,7 @@ def message_box( visitor.process_message(io_message) -class MesopGUIMessageVisitor(IOMessageVisitor): +class MesopGUIMessageVisitor(MessageProcessorMixin): def __init__( self, level: int, diff --git a/fastagency/ui/mesop/send_prompt.py b/fastagency/ui/mesop/send_prompt.py index c939eb05..ffa2aa59 100644 --- a/fastagency/ui/mesop/send_prompt.py +++ b/fastagency/ui/mesop/send_prompt.py @@ -3,8 +3,8 @@ import mesop as me from ...base import ProviderProtocol -from .base import MesopMessage, MesopUI, run_workflow from .data_model import State +from .mesop import MesopMessage, MesopUI, run_workflow def send_prompt_to_autogen( diff --git a/tests/cli/test_discover.py b/tests/cli/test_discover.py index 8fe9118e..947738df 100644 --- a/tests/cli/test_discover.py +++ b/tests/cli/test_discover.py @@ -32,7 +32,7 @@ def _import_fixture( main_content = f""" from unittest.mock import MagicMock from fastagency.ui.console import ConsoleUI -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.runtimes.autogen import AutoGenWorkflows {'frim' if syntax_error else 'from'} fastagency import FastAgency diff --git a/tests/cli/test_mesop.py b/tests/cli/test_mesop.py index f83faf54..98da01bf 100644 --- a/tests/cli/test_mesop.py +++ b/tests/cli/test_mesop.py @@ -14,7 +14,7 @@ from autogen.agentchat import ConversableAgent from fastagency import UI, FastAgency, WorkflowsProtocol -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.runtimes.autogen import AutoGenWorkflows from fastagency.ui.mesop import MesopUI llm_config = { diff --git a/tests/docs_src/user_guide/runtime/__init__.py b/tests/docs_src/user_guide/runtimes/__init__.py similarity index 100% rename from tests/docs_src/user_guide/runtime/__init__.py rename to tests/docs_src/user_guide/runtimes/__init__.py diff --git a/tests/docs_src/user_guide/runtime/autogen/__init__.py b/tests/docs_src/user_guide/runtimes/autogen/__init__.py similarity index 100% rename from tests/docs_src/user_guide/runtime/autogen/__init__.py rename to tests/docs_src/user_guide/runtimes/autogen/__init__.py diff --git a/tests/docs_src/user_guide/runtime/autogen/test_main.py b/tests/docs_src/user_guide/runtimes/autogen/test_main.py similarity index 100% rename from tests/docs_src/user_guide/runtime/autogen/test_main.py rename to tests/docs_src/user_guide/runtimes/autogen/test_main.py diff --git a/tests/docs_src/user_guide/runtime/autogen/test_websurfer.py b/tests/docs_src/user_guide/runtimes/autogen/test_websurfer.py similarity index 100% rename from tests/docs_src/user_guide/runtime/autogen/test_websurfer.py rename to tests/docs_src/user_guide/runtimes/autogen/test_websurfer.py diff --git a/tests/docs_src/user_guide/runtime/autogen/test_websurfer_tool.py b/tests/docs_src/user_guide/runtimes/autogen/test_websurfer_tool.py similarity index 100% rename from tests/docs_src/user_guide/runtime/autogen/test_websurfer_tool.py rename to tests/docs_src/user_guide/runtimes/autogen/test_websurfer_tool.py diff --git a/tests/runtime/autogen/test_autogen.py b/tests/runtime/autogen/test_autogen.py index e4b6f292..7fd2900c 100644 --- a/tests/runtime/autogen/test_autogen.py +++ b/tests/runtime/autogen/test_autogen.py @@ -9,8 +9,8 @@ from fastagency import UI, IOMessage from fastagency.api.openapi import OpenAPI from fastagency.base import WorkflowsProtocol -from fastagency.runtime.autogen import AutoGenWorkflows -from fastagency.runtime.autogen.base import _findall, _match +from fastagency.runtimes.autogen import AutoGenWorkflows +from fastagency.runtimes.autogen.autogen import _findall, _match from fastagency.ui.console import ConsoleUI from tests.conftest import InputMock diff --git a/tests/runtime/autogen/tools/test_web_surfer.py b/tests/runtime/autogen/tools/test_web_surfer.py index a7ba498a..4a36fb53 100644 --- a/tests/runtime/autogen/tools/test_web_surfer.py +++ b/tests/runtime/autogen/tools/test_web_surfer.py @@ -3,8 +3,8 @@ import pytest from autogen import ConversableAgent, UserProxyAgent -from fastagency.runtime.autogen.base import Toolable -from fastagency.runtime.autogen.tools import WebSurferTool +from fastagency.runtimes.autogen.autogen import Toolable +from fastagency.runtimes.autogen.tools import WebSurferTool class TestWebSurferTool: diff --git a/tests/test_import.py b/tests/test_import.py index bb87db99..a7e95686 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -51,7 +51,7 @@ def test_list_submodules() -> None: assert "fastagency.ui" in submodules assert "fastagency.ui.mesop" in submodules - assert "fastagency.ui.console.base" in submodules + assert "fastagency.ui.console.console" in submodules @pytest.mark.parametrize("module", list_submodules("fastagency")) diff --git a/tests/ui/console/test_base.py b/tests/ui/console/test_base.py index 62db65be..4fa18eb6 100644 --- a/tests/ui/console/test_base.py +++ b/tests/ui/console/test_base.py @@ -4,7 +4,7 @@ import pytest from fastagency.app import FastAgency -from fastagency.runtime.autogen import AutoGenWorkflows +from fastagency.runtimes.autogen import AutoGenWorkflows from fastagency.ui.console import ConsoleUI diff --git a/tests/ui/mesop/test_base.py b/tests/ui/mesop/test_base.py index 7ecb21a0..f0481275 100644 --- a/tests/ui/mesop/test_base.py +++ b/tests/ui/mesop/test_base.py @@ -3,11 +3,11 @@ import pytest from fastagency.app import FastAgency -from fastagency.base import TextMessage -from fastagency.runtime.autogen.base import AutoGenWorkflows +from fastagency.messages import TextMessage +from fastagency.runtimes.autogen.autogen import AutoGenWorkflows if sys.version_info >= (3, 10): - from fastagency.ui.mesop.base import MesopUI + from fastagency.ui.mesop.mesop import MesopUI class TestMesopUI: def test_mesop_init(self) -> None: diff --git a/tests/ui/mesop/test_message.py b/tests/ui/mesop/test_message.py index ac58867a..5d00d988 100644 --- a/tests/ui/mesop/test_message.py +++ b/tests/ui/mesop/test_message.py @@ -5,7 +5,7 @@ import pytest -from fastagency.base import ( +from fastagency.messages import ( FunctionCallExecution, MultipleChoice, SuggestedFunctionCall,