-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issues with external agent workflow
- Loading branch information
1 parent
a6701b8
commit 06323c9
Showing
22 changed files
with
310 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,18 @@ | |
> [!NOTE] | ||
> This section is for changes that are not yet released but will affect future releases. | ||
## Starting with 0.9.1-rc103 | ||
## Starting with 0.9.1-rc106 | ||
|
||
### Configuration changes | ||
|
||
The following new App Configuration settings are required: | ||
|
||
|Name | Default value | Description | | ||
|--- | --- | --- | | ||
|`FoundationaLLM:PythonSDK:Logging:LogLevel:Azure` | `Warning` | Provides the default level of logging for Azure modules in the Python SDK. | | ||
|
||
### Agent workflow configuration changes | ||
|
||
Agent resource configuration files that have a `workflow` property now requires a `name` and `package_name` property. This is to support loading external workflows via plugins. For internal workflows, the `package_name` should be set to `FoundationaLLM`. Example below truncated for brevity. | ||
|
||
```json | ||
|
@@ -22,6 +30,26 @@ Agent resource configuration files that have a `workflow` property now requires | |
} | ||
``` | ||
|
||
A new `Workflow` resource must be added to the `FoundationaLLM.Agent` resource provider: | ||
|
||
```json | ||
{ | ||
"type": "external-agent-workflow", | ||
"name": "ExternalAgentWorkflow", | ||
"object_id": "/instances/<instance_id>/providers/FoundationaLLM.Agent/workflows/ExternalAgentWorkflow", | ||
"display_name": "ExternalAgentWorkflow", | ||
"description": "External Agent workflow", | ||
"cost_center": null, | ||
"properties": null, | ||
"created_on": "2024-11-13T18:12:07.0223039+00:00", | ||
"updated_on": "0001-01-01T00:00:00+00:00", | ||
"created_by": "[email protected]", | ||
"updated_by": null, | ||
"deleted": false, | ||
"expiration_date": null | ||
} | ||
``` | ||
|
||
## Starting with 0.9.1-rc102 | ||
|
||
### Configuration changes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/python/Experimental/src/skunkworks_foundationallm/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .skunkworks_tool_plugin_manager import SkunkworksToolPluginManager | ||
from .skunkworks_workflow_plugin_manager import SkunkworksWorkflowPluginManager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/python/Experimental/src/skunkworks_foundationallm/skunkworks_workflow_plugin_manager.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from typing import List | ||
|
||
from foundationallm.config import Configuration, UserIdentity | ||
from foundationallm.models.agents import AgentTool, ExternalAgentWorkflow | ||
from foundationallm.langchain.common import FoundationaLLMWorkflowBase | ||
from foundationallm.plugins import WorkflowPluginManagerBase | ||
|
||
from skunkworks_foundationallm.workflows import ( | ||
FoundationaLLMRouterWorkflow | ||
) | ||
|
||
class SkunkworksWorkflowPluginManager(WorkflowPluginManagerBase): | ||
|
||
FOUNDATIONALLM_ROUTER_WORKFLOW_NAME = 'FoundationaLLMRouterWorkflow' | ||
|
||
def __init__(self): | ||
super().__init__() | ||
|
||
def create_workflow( | ||
self, | ||
workflow_config: ExternalAgentWorkflow, | ||
objects: dict, | ||
tools: List[AgentTool], | ||
user_identity: UserIdentity, | ||
config: Configuration) -> FoundationaLLMWorkflowBase: | ||
""" | ||
Create a workflow instance based on the given configuration and tools. | ||
Parameters | ||
---------- | ||
workflow_config : ExternalAgentWorkflow | ||
The workflow assigned to the agent. | ||
objects : dict | ||
The exploded objects assigned from the agent. | ||
tools : List[AgentTool] | ||
The tools assigned to the agent. | ||
user_identity : UserIdentity | ||
The user identity of the user initiating the request. | ||
config : Configuration | ||
The application configuration for FoundationaLLM. | ||
""" | ||
match workflow_config.name: | ||
case SkunkworksWorkflowPluginManager.FOUNDATIONALLM_ROUTER_WORKFLOW_NAME: | ||
return FoundationaLLMRouterWorkflow(workflow_config, objects, tools, user_identity, config) | ||
case _: | ||
raise ValueError(f"Unknown tool name: {workflow_config.name}") | ||
|
||
def refresh_tools(): | ||
print('Refreshing tools...') |
1 change: 1 addition & 0 deletions
1
src/python/Experimental/src/skunkworks_foundationallm/workflows/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .foundationallm_router_workflow import FoundationaLLMRouterWorkflow |
77 changes: 77 additions & 0 deletions
77
...on/Experimental/src/skunkworks_foundationallm/workflows/foundationallm_router_workflow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
""" | ||
Class: FoundationaLLMWorkflowBase | ||
Description: FoundationaLLM base class for tools that uses the agent workflow model for its configuration. | ||
""" | ||
from abc import ABC, abstractmethod | ||
from azure.identity import DefaultAzureCredential | ||
from langchain_core.messages import BaseMessage | ||
from pydantic import BaseModel | ||
from typing import List | ||
from foundationallm.config import Configuration, UserIdentity | ||
from foundationallm.langchain.common import FoundationaLLMWorkflowBase | ||
from foundationallm.models.agents import AgentTool, ExternalAgentWorkflow | ||
from foundationallm.models.constants import AgentCapabilityCategories | ||
from foundationallm.models.orchestration import CompletionResponse, OpenAITextMessageContentItem | ||
from foundationallm.telemetry import Telemetry | ||
|
||
class FoundationaLLMRouterWorkflow(FoundationaLLMWorkflowBase): | ||
""" | ||
FoundationaLLM base class for workflows that uses the agent workflow model for its configuration. | ||
""" | ||
def __init__(self, | ||
workflow_config: ExternalAgentWorkflow, | ||
objects: dict, | ||
tools: List[AgentTool], | ||
user_identity: UserIdentity, | ||
config: Configuration): | ||
""" | ||
Initializes the FoundationaLLMWorkflowBase class with the workflow configuration. | ||
Parameters | ||
---------- | ||
workflow_config : ExternalAgentWorkflow | ||
The workflow assigned to the agent. | ||
objects : dict | ||
The exploded objects assigned from the agent. | ||
tools : List[AgentTool] | ||
The tools assigned to the agent. | ||
user_identity : UserIdentity | ||
The user identity of the user initiating the request. | ||
config : Configuration | ||
The application configuration for FoundationaLLM. | ||
""" | ||
super().__init__(workflow_config, objects, tools, user_identity, config) | ||
|
||
async def invoke_async(self, | ||
operation_id: str, | ||
user_prompt:str, | ||
message_history: List[BaseMessage])-> CompletionResponse: | ||
""" | ||
Invokes the workflow asynchronously. | ||
Parameters | ||
---------- | ||
operation_id : str | ||
The unique identifier of the FoundationaLLM operation. | ||
user_prompt : str | ||
The user prompt message. | ||
message_history : List[BaseMessage] | ||
The message history. | ||
""" | ||
response_content = OpenAITextMessageContentItem( | ||
value = '42 is the answer to all questions', | ||
agent_capability_category = AgentCapabilityCategories.FOUNDATIONALLM_KNOWLEDGE_MANAGEMENT | ||
) | ||
|
||
|
||
return CompletionResponse( | ||
operation_id = operation_id, | ||
content = [response_content], | ||
content_artifacts = [], | ||
user_prompt = user_prompt, | ||
full_prompt = '', | ||
completion_tokens = 0, | ||
prompt_tokens = 0, | ||
total_tokens = 0, | ||
total_cost = 0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/python/PythonSDK/foundationallm/langchain/workflows/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from .external_workflow_factory import ExternalWorkflowFactory | ||
from .workflow_factory import WorkflowFactory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.