ibm-watsonx-orchestrate 1.5.1__py3-none-any.whl → 1.7.0a0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ibm_watsonx_orchestrate/__init__.py +1 -1
- ibm_watsonx_orchestrate/agent_builder/agents/__init__.py +1 -1
- ibm_watsonx_orchestrate/agent_builder/agents/agent.py +1 -0
- ibm_watsonx_orchestrate/agent_builder/agents/types.py +58 -4
- ibm_watsonx_orchestrate/agent_builder/agents/webchat_customizations/__init__.py +2 -0
- ibm_watsonx_orchestrate/agent_builder/agents/webchat_customizations/prompts.py +33 -0
- ibm_watsonx_orchestrate/agent_builder/agents/webchat_customizations/welcome_content.py +20 -0
- ibm_watsonx_orchestrate/agent_builder/connections/__init__.py +2 -2
- ibm_watsonx_orchestrate/agent_builder/connections/types.py +38 -31
- ibm_watsonx_orchestrate/agent_builder/model_policies/types.py +1 -1
- ibm_watsonx_orchestrate/agent_builder/models/types.py +0 -1
- ibm_watsonx_orchestrate/agent_builder/tools/flow_tool.py +83 -0
- ibm_watsonx_orchestrate/agent_builder/tools/openapi_tool.py +41 -3
- ibm_watsonx_orchestrate/agent_builder/tools/python_tool.py +2 -1
- ibm_watsonx_orchestrate/agent_builder/tools/types.py +14 -1
- ibm_watsonx_orchestrate/cli/commands/agents/agents_command.py +18 -1
- ibm_watsonx_orchestrate/cli/commands/agents/agents_controller.py +122 -17
- ibm_watsonx_orchestrate/cli/commands/channels/webchat/channels_webchat_controller.py +104 -22
- ibm_watsonx_orchestrate/cli/commands/connections/connections_command.py +26 -18
- ibm_watsonx_orchestrate/cli/commands/connections/connections_controller.py +56 -58
- ibm_watsonx_orchestrate/cli/commands/environment/environment_command.py +29 -4
- ibm_watsonx_orchestrate/cli/commands/environment/environment_controller.py +74 -8
- ibm_watsonx_orchestrate/cli/commands/environment/types.py +1 -0
- ibm_watsonx_orchestrate/cli/commands/evaluations/evaluations_command.py +224 -0
- ibm_watsonx_orchestrate/cli/commands/evaluations/evaluations_controller.py +158 -0
- ibm_watsonx_orchestrate/cli/commands/knowledge_bases/knowledge_bases_command.py +2 -2
- ibm_watsonx_orchestrate/cli/commands/knowledge_bases/knowledge_bases_controller.py +2 -2
- ibm_watsonx_orchestrate/cli/commands/models/model_provider_mapper.py +31 -25
- ibm_watsonx_orchestrate/cli/commands/models/models_command.py +6 -6
- ibm_watsonx_orchestrate/cli/commands/models/models_controller.py +17 -8
- ibm_watsonx_orchestrate/cli/commands/server/server_command.py +162 -27
- ibm_watsonx_orchestrate/cli/commands/server/types.py +2 -1
- ibm_watsonx_orchestrate/cli/commands/toolkit/toolkit_controller.py +9 -6
- ibm_watsonx_orchestrate/cli/commands/tools/tools_controller.py +37 -22
- ibm_watsonx_orchestrate/cli/config.py +2 -0
- ibm_watsonx_orchestrate/cli/main.py +6 -0
- ibm_watsonx_orchestrate/client/agents/agent_client.py +83 -9
- ibm_watsonx_orchestrate/client/agents/assistant_agent_client.py +3 -3
- ibm_watsonx_orchestrate/client/agents/external_agent_client.py +2 -2
- ibm_watsonx_orchestrate/client/base_api_client.py +11 -10
- ibm_watsonx_orchestrate/client/connections/connections_client.py +49 -14
- ibm_watsonx_orchestrate/client/connections/utils.py +4 -2
- ibm_watsonx_orchestrate/client/credentials.py +4 -0
- ibm_watsonx_orchestrate/client/local_service_instance.py +1 -1
- ibm_watsonx_orchestrate/client/model_policies/model_policies_client.py +2 -2
- ibm_watsonx_orchestrate/client/service_instance.py +42 -1
- ibm_watsonx_orchestrate/client/tools/tempus_client.py +8 -3
- ibm_watsonx_orchestrate/client/utils.py +37 -2
- ibm_watsonx_orchestrate/docker/compose-lite.yml +425 -81
- ibm_watsonx_orchestrate/docker/default.env +53 -15
- ibm_watsonx_orchestrate/docker/proxy-config-single.yaml +12 -0
- ibm_watsonx_orchestrate/{experimental/flow_builder → flow_builder}/flows/__init__.py +3 -2
- ibm_watsonx_orchestrate/flow_builder/flows/decorators.py +77 -0
- ibm_watsonx_orchestrate/{experimental/flow_builder → flow_builder}/flows/events.py +6 -1
- ibm_watsonx_orchestrate/{experimental/flow_builder → flow_builder}/flows/flow.py +85 -92
- ibm_watsonx_orchestrate/{experimental/flow_builder → flow_builder}/types.py +15 -6
- ibm_watsonx_orchestrate/flow_builder/utils.py +215 -0
- ibm_watsonx_orchestrate/run/connections.py +4 -4
- {ibm_watsonx_orchestrate-1.5.1.dist-info → ibm_watsonx_orchestrate-1.7.0a0.dist-info}/METADATA +2 -1
- {ibm_watsonx_orchestrate-1.5.1.dist-info → ibm_watsonx_orchestrate-1.7.0a0.dist-info}/RECORD +68 -61
- ibm_watsonx_orchestrate/experimental/flow_builder/flows/decorators.py +0 -144
- ibm_watsonx_orchestrate/experimental/flow_builder/utils.py +0 -115
- /ibm_watsonx_orchestrate/{experimental/flow_builder → flow_builder}/__init__.py +0 -0
- /ibm_watsonx_orchestrate/{experimental/flow_builder → flow_builder}/data_map.py +0 -0
- /ibm_watsonx_orchestrate/{experimental/flow_builder → flow_builder}/flows/constants.py +0 -0
- /ibm_watsonx_orchestrate/{experimental/flow_builder → flow_builder}/node.py +0 -0
- /ibm_watsonx_orchestrate/{experimental/flow_builder → flow_builder}/resources/flow_status.openapi.yml +0 -0
- {ibm_watsonx_orchestrate-1.5.1.dist-info → ibm_watsonx_orchestrate-1.7.0a0.dist-info}/WHEEL +0 -0
- {ibm_watsonx_orchestrate-1.5.1.dist-info → ibm_watsonx_orchestrate-1.7.0a0.dist-info}/entry_points.txt +0 -0
- {ibm_watsonx_orchestrate-1.5.1.dist-info → ibm_watsonx_orchestrate-1.7.0a0.dist-info}/licenses/LICENSE +0 -0
@@ -1,115 +0,0 @@
|
|
1
|
-
import inspect
|
2
|
-
import json
|
3
|
-
from pathlib import Path
|
4
|
-
import re
|
5
|
-
import logging
|
6
|
-
import importlib.resources
|
7
|
-
import yaml
|
8
|
-
|
9
|
-
from pydantic import BaseModel
|
10
|
-
from typing import types
|
11
|
-
|
12
|
-
from langchain_core.utils.json_schema import dereference_refs
|
13
|
-
import typer
|
14
|
-
|
15
|
-
from ibm_watsonx_orchestrate.agent_builder.connections.types import ConnectionEnvironment, ConnectionPreference, ConnectionSecurityScheme
|
16
|
-
from ibm_watsonx_orchestrate.agent_builder.tools.openapi_tool import create_openapi_json_tools_from_content
|
17
|
-
from ibm_watsonx_orchestrate.agent_builder.tools.types import JsonSchemaObject
|
18
|
-
from ibm_watsonx_orchestrate.cli.commands.connections.connections_controller import add_connection, configure_connection, set_credentials_connection
|
19
|
-
from ibm_watsonx_orchestrate.client.connections.utils import get_connections_client
|
20
|
-
from ibm_watsonx_orchestrate.client.tools.tempus_client import TempusClient
|
21
|
-
from ibm_watsonx_orchestrate.client.utils import instantiate_client, is_local_dev
|
22
|
-
|
23
|
-
logger = logging.getLogger(__name__)
|
24
|
-
|
25
|
-
def get_valid_name(name: str) -> str:
|
26
|
-
|
27
|
-
return re.sub('\\W|^(?=\\d)','_', name)
|
28
|
-
|
29
|
-
def _get_json_schema_obj(parameter_name: str, type_def: type[BaseModel] | None) -> JsonSchemaObject:
|
30
|
-
if not type_def or type_def is None or type_def == inspect._empty:
|
31
|
-
return None
|
32
|
-
|
33
|
-
if issubclass(type_def, BaseModel):
|
34
|
-
input_schema_json = type_def.model_json_schema()
|
35
|
-
input_schema_json = dereference_refs(input_schema_json)
|
36
|
-
input_schema_obj = JsonSchemaObject(**input_schema_json)
|
37
|
-
if input_schema_obj.required is None:
|
38
|
-
input_schema_obj.required = []
|
39
|
-
return input_schema_obj
|
40
|
-
|
41
|
-
if isinstance(type_def, type):
|
42
|
-
schema_type = 'object'
|
43
|
-
if type_def == str:
|
44
|
-
schema_type = 'string'
|
45
|
-
elif type_def == int:
|
46
|
-
schema_type = 'integer'
|
47
|
-
elif type_def == float:
|
48
|
-
schema_type = 'number'
|
49
|
-
elif type_def == bool:
|
50
|
-
schema_type = 'boolean'
|
51
|
-
else:
|
52
|
-
schema_type = 'string'
|
53
|
-
# TODO: inspect the list item type and use that as the item type
|
54
|
-
return JsonSchemaObject(type=schema_type, properties={}, required=[])
|
55
|
-
|
56
|
-
raise ValueError(
|
57
|
-
f"Parameter {parameter_name} must be of type BaseModel or a primitive type.")
|
58
|
-
|
59
|
-
async def import_flow_model(model):
|
60
|
-
|
61
|
-
if not is_local_dev():
|
62
|
-
raise typer.BadParameter(f"Flow tools are only supported in local environment.")
|
63
|
-
|
64
|
-
if model is None:
|
65
|
-
raise typer.BadParameter(f"No model provided.")
|
66
|
-
|
67
|
-
tools = []
|
68
|
-
|
69
|
-
flow_id = model["spec"]["name"]
|
70
|
-
|
71
|
-
tempus_client: TempusClient = instantiate_client(TempusClient)
|
72
|
-
|
73
|
-
flow_open_api = tempus_client.create_update_flow_model(flow_id=flow_id, model=model)
|
74
|
-
|
75
|
-
logger.info(f"Flow model `{flow_id}` deployed successfully.")
|
76
|
-
|
77
|
-
connections_client = get_connections_client()
|
78
|
-
|
79
|
-
app_id = "flow_tools_app"
|
80
|
-
logger.info(f"Creating connection for flow model...")
|
81
|
-
existing_app = connections_client.get(app_id=app_id)
|
82
|
-
if not existing_app:
|
83
|
-
# logger.info(f"Creating app `{app_id}`.")
|
84
|
-
add_connection(app_id=app_id)
|
85
|
-
# else:
|
86
|
-
# logger.info(f"App `{app_id}` already exists.")
|
87
|
-
|
88
|
-
# logger.info(f"Creating connection for app...")
|
89
|
-
configure_connection(
|
90
|
-
type=ConnectionPreference.MEMBER,
|
91
|
-
app_id=app_id,
|
92
|
-
token=connections_client.api_key,
|
93
|
-
environment=ConnectionEnvironment.DRAFT,
|
94
|
-
security_scheme=ConnectionSecurityScheme.BEARER_TOKEN,
|
95
|
-
shared=False
|
96
|
-
)
|
97
|
-
|
98
|
-
set_credentials_connection(app_id=app_id, environment=ConnectionEnvironment.DRAFT, token=connections_client.api_key)
|
99
|
-
|
100
|
-
connections = connections_client.get_draft_by_app_id(app_id=app_id)
|
101
|
-
|
102
|
-
# logger.info(f"Connection `{connections.connection_id}` created successfully.")
|
103
|
-
|
104
|
-
tools = await create_openapi_json_tools_from_content(flow_open_api, connections.connection_id)
|
105
|
-
|
106
|
-
logger.info(f"Generating 'get_flow_status' tool spec...")
|
107
|
-
# Temporary code to deploy a status tool until we have full async support
|
108
|
-
with importlib.resources.open_text('ibm_watsonx_orchestrate.experimental.flow_builder.resources', 'flow_status.openapi.yml', encoding='utf-8') as f:
|
109
|
-
get_status_openapi = f.read()
|
110
|
-
|
111
|
-
get_flow_status_spec = yaml.safe_load(get_status_openapi)
|
112
|
-
tools.extend(await create_openapi_json_tools_from_content(get_flow_status_spec, connections.connection_id))
|
113
|
-
|
114
|
-
|
115
|
-
return tools
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|