ibm-watsonx-orchestrate 1.0.0__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 +28 -0
- ibm_watsonx_orchestrate/agent_builder/__init__.py +0 -0
- ibm_watsonx_orchestrate/agent_builder/agents/__init__.py +5 -0
- ibm_watsonx_orchestrate/agent_builder/agents/agent.py +27 -0
- ibm_watsonx_orchestrate/agent_builder/agents/assistant_agent.py +28 -0
- ibm_watsonx_orchestrate/agent_builder/agents/external_agent.py +28 -0
- ibm_watsonx_orchestrate/agent_builder/agents/types.py +204 -0
- ibm_watsonx_orchestrate/agent_builder/connections/__init__.py +27 -0
- ibm_watsonx_orchestrate/agent_builder/connections/connections.py +123 -0
- ibm_watsonx_orchestrate/agent_builder/connections/types.py +260 -0
- ibm_watsonx_orchestrate/agent_builder/knowledge_bases/knowledge_base.py +27 -0
- ibm_watsonx_orchestrate/agent_builder/knowledge_bases/knowledge_base_requests.py +59 -0
- ibm_watsonx_orchestrate/agent_builder/knowledge_bases/types.py +243 -0
- ibm_watsonx_orchestrate/agent_builder/tools/__init__.py +4 -0
- ibm_watsonx_orchestrate/agent_builder/tools/base_tool.py +36 -0
- ibm_watsonx_orchestrate/agent_builder/tools/openapi_tool.py +332 -0
- ibm_watsonx_orchestrate/agent_builder/tools/python_tool.py +195 -0
- ibm_watsonx_orchestrate/agent_builder/tools/types.py +162 -0
- ibm_watsonx_orchestrate/agent_builder/utils/__init__.py +0 -0
- ibm_watsonx_orchestrate/agent_builder/utils/pydantic_utils.py +149 -0
- ibm_watsonx_orchestrate/cli/__init__.py +0 -0
- ibm_watsonx_orchestrate/cli/commands/__init__.py +0 -0
- ibm_watsonx_orchestrate/cli/commands/agents/agents_command.py +192 -0
- ibm_watsonx_orchestrate/cli/commands/agents/agents_controller.py +660 -0
- ibm_watsonx_orchestrate/cli/commands/channels/channels_command.py +15 -0
- ibm_watsonx_orchestrate/cli/commands/channels/channels_controller.py +16 -0
- ibm_watsonx_orchestrate/cli/commands/channels/types.py +15 -0
- ibm_watsonx_orchestrate/cli/commands/channels/webchat/channels_webchat_command.py +32 -0
- ibm_watsonx_orchestrate/cli/commands/channels/webchat/channels_webchat_controller.py +141 -0
- ibm_watsonx_orchestrate/cli/commands/chat/chat_command.py +43 -0
- ibm_watsonx_orchestrate/cli/commands/connections/connections_command.py +307 -0
- ibm_watsonx_orchestrate/cli/commands/connections/connections_controller.py +517 -0
- ibm_watsonx_orchestrate/cli/commands/environment/environment_command.py +78 -0
- ibm_watsonx_orchestrate/cli/commands/environment/environment_controller.py +189 -0
- ibm_watsonx_orchestrate/cli/commands/environment/types.py +9 -0
- ibm_watsonx_orchestrate/cli/commands/knowledge_bases/knowledge_bases_command.py +79 -0
- ibm_watsonx_orchestrate/cli/commands/knowledge_bases/knowledge_bases_controller.py +201 -0
- ibm_watsonx_orchestrate/cli/commands/login/login_command.py +17 -0
- ibm_watsonx_orchestrate/cli/commands/models/models_command.py +128 -0
- ibm_watsonx_orchestrate/cli/commands/server/server_command.py +623 -0
- ibm_watsonx_orchestrate/cli/commands/settings/__init__.py +0 -0
- ibm_watsonx_orchestrate/cli/commands/settings/observability/__init__.py +0 -0
- ibm_watsonx_orchestrate/cli/commands/settings/observability/langfuse/__init__.py +0 -0
- ibm_watsonx_orchestrate/cli/commands/settings/observability/langfuse/langfuse_command.py +175 -0
- ibm_watsonx_orchestrate/cli/commands/settings/observability/observability_command.py +11 -0
- ibm_watsonx_orchestrate/cli/commands/settings/settings_command.py +10 -0
- ibm_watsonx_orchestrate/cli/commands/tools/tools_command.py +85 -0
- ibm_watsonx_orchestrate/cli/commands/tools/tools_controller.py +564 -0
- ibm_watsonx_orchestrate/cli/commands/tools/types.py +10 -0
- ibm_watsonx_orchestrate/cli/config.py +226 -0
- ibm_watsonx_orchestrate/cli/main.py +32 -0
- ibm_watsonx_orchestrate/client/__init__.py +0 -0
- ibm_watsonx_orchestrate/client/agents/agent_client.py +46 -0
- ibm_watsonx_orchestrate/client/agents/assistant_agent_client.py +38 -0
- ibm_watsonx_orchestrate/client/agents/external_agent_client.py +38 -0
- ibm_watsonx_orchestrate/client/analytics/__init__.py +0 -0
- ibm_watsonx_orchestrate/client/analytics/llm/__init__.py +0 -0
- ibm_watsonx_orchestrate/client/analytics/llm/analytics_llm_client.py +50 -0
- ibm_watsonx_orchestrate/client/base_api_client.py +113 -0
- ibm_watsonx_orchestrate/client/base_service_instance.py +10 -0
- ibm_watsonx_orchestrate/client/client.py +71 -0
- ibm_watsonx_orchestrate/client/client_errors.py +359 -0
- ibm_watsonx_orchestrate/client/connections/__init__.py +10 -0
- ibm_watsonx_orchestrate/client/connections/connections_client.py +162 -0
- ibm_watsonx_orchestrate/client/connections/utils.py +27 -0
- ibm_watsonx_orchestrate/client/credentials.py +123 -0
- ibm_watsonx_orchestrate/client/knowledge_bases/knowledge_base_client.py +46 -0
- ibm_watsonx_orchestrate/client/local_service_instance.py +91 -0
- ibm_watsonx_orchestrate/client/service_instance.py +73 -0
- ibm_watsonx_orchestrate/client/tools/tool_client.py +41 -0
- ibm_watsonx_orchestrate/client/utils.py +95 -0
- ibm_watsonx_orchestrate/docker/compose-lite.yml +595 -0
- ibm_watsonx_orchestrate/docker/default.env +125 -0
- ibm_watsonx_orchestrate/docker/sdk/ibm_watsonx_orchestrate-0.6.0-py3-none-any.whl +0 -0
- ibm_watsonx_orchestrate/docker/sdk/ibm_watsonx_orchestrate-0.6.0.tar.gz +0 -0
- ibm_watsonx_orchestrate/docker/start-up.sh +61 -0
- ibm_watsonx_orchestrate/docker/tempus/common-config.yaml +1 -0
- ibm_watsonx_orchestrate/run/__init__.py +0 -0
- ibm_watsonx_orchestrate/run/connections.py +40 -0
- ibm_watsonx_orchestrate/utils/__init__.py +0 -0
- ibm_watsonx_orchestrate/utils/logging/__init__.py +0 -0
- ibm_watsonx_orchestrate/utils/logging/logger.py +26 -0
- ibm_watsonx_orchestrate/utils/logging/logging.yaml +18 -0
- ibm_watsonx_orchestrate/utils/utils.py +15 -0
- ibm_watsonx_orchestrate-1.0.0.dist-info/METADATA +34 -0
- ibm_watsonx_orchestrate-1.0.0.dist-info/RECORD +89 -0
- ibm_watsonx_orchestrate-1.0.0.dist-info/WHEEL +4 -0
- ibm_watsonx_orchestrate-1.0.0.dist-info/entry_points.txt +2 -0
- ibm_watsonx_orchestrate-1.0.0.dist-info/licenses/LICENSE +22 -0
@@ -0,0 +1,175 @@
|
|
1
|
+
import yaml
|
2
|
+
import json
|
3
|
+
import logging
|
4
|
+
from typing import Annotated
|
5
|
+
from json import loads
|
6
|
+
|
7
|
+
import typer
|
8
|
+
from yaml.representer import Representer
|
9
|
+
|
10
|
+
from ibm_watsonx_orchestrate.agent_builder.agents import SpecVersion
|
11
|
+
from ibm_watsonx_orchestrate.client.analytics.llm.analytics_llm_client import AnalyticsLLMClient, AnalyticsLLMConfig, \
|
12
|
+
AnalyticsLLMResponse
|
13
|
+
from ibm_watsonx_orchestrate.client.base_api_client import ClientAPIException
|
14
|
+
from ibm_watsonx_orchestrate.client.utils import instantiate_client
|
15
|
+
from ibm_watsonx_orchestrate.utils.utils import yaml_safe_load
|
16
|
+
|
17
|
+
settings_observability_langfuse_app = typer.Typer(no_args_is_help=True)
|
18
|
+
|
19
|
+
logger = logging.getLogger(__name__)
|
20
|
+
|
21
|
+
def _validate_langfuse_input(**kwargs) -> AnalyticsLLMConfig:
|
22
|
+
config = {}
|
23
|
+
if kwargs['config_file'] is not None:
|
24
|
+
file = kwargs['config_file']
|
25
|
+
with open(file, 'r') as fp:
|
26
|
+
if file.endswith('.yaml') or file.endswith('.yml'):
|
27
|
+
content = yaml_safe_load(fp)
|
28
|
+
elif file.endswith('.json'):
|
29
|
+
content = json.load(fp)
|
30
|
+
else:
|
31
|
+
raise ValueError('file must end in .json, .yaml, or .yml')
|
32
|
+
|
33
|
+
config.update(content)
|
34
|
+
|
35
|
+
keys = ['url', 'project_id', 'api_key', 'mask_pii', 'kind', 'spec_version', 'host_health_uri']
|
36
|
+
for key in keys:
|
37
|
+
if kwargs.get(key) is not None:
|
38
|
+
config[key] = kwargs[key]
|
39
|
+
|
40
|
+
if config.get('project_id') is None:
|
41
|
+
logger.warning('The --project-id was not specified, defaulting to "default"')
|
42
|
+
|
43
|
+
if config.get('api_key', None) is None:
|
44
|
+
logger.error(f"The --api-key argument is required when an api_key is not specified via a config file")
|
45
|
+
exit(1)
|
46
|
+
|
47
|
+
if config.get('url', None) is None:
|
48
|
+
logger.error(f"The --url argument is required when a url field is not specified via a config file")
|
49
|
+
exit(1)
|
50
|
+
|
51
|
+
if config.get('host_health_uri', None) is None:
|
52
|
+
logger.error(f"The --health-url argument is required when a host_health_uri field is not specified via a config file")
|
53
|
+
exit(1)
|
54
|
+
|
55
|
+
if kwargs.get('config_json'):
|
56
|
+
config["config_json"] = kwargs["config_json"]
|
57
|
+
|
58
|
+
res = AnalyticsLLMConfig(
|
59
|
+
project_id=config.get('project_id', 'default'),
|
60
|
+
host_uri=config.get('url'),
|
61
|
+
api_key=config.get('api_key'),
|
62
|
+
tool_identifier="langfuse",
|
63
|
+
mask_pii=config.get('mask_pii', False),
|
64
|
+
config_json=config.get("config_json", {}),
|
65
|
+
host_health_uri=config.get('host_health_uri')
|
66
|
+
)
|
67
|
+
|
68
|
+
return res
|
69
|
+
|
70
|
+
|
71
|
+
def _reformat_output(cfg: AnalyticsLLMConfig) -> dict:
|
72
|
+
config = {}
|
73
|
+
config['spec_version'] = str(SpecVersion.V1.value)
|
74
|
+
config['kind'] = 'langfuse'
|
75
|
+
config['active'] = cfg.active
|
76
|
+
config['mask_pii'] = cfg.mask_pii
|
77
|
+
if cfg.config_json:
|
78
|
+
config.update(cfg.config_json)
|
79
|
+
|
80
|
+
return config
|
81
|
+
|
82
|
+
@settings_observability_langfuse_app.command(name="get", help="Get the current configuration settings for langfuse")
|
83
|
+
def get_langfuse(
|
84
|
+
output: Annotated[
|
85
|
+
str,
|
86
|
+
typer.Option("--output", "-o",
|
87
|
+
help="File to output the results to (file extension can be either .yml, .yaml, or .json)"),
|
88
|
+
] = None,
|
89
|
+
):
|
90
|
+
client: AnalyticsLLMClient = instantiate_client(AnalyticsLLMClient)
|
91
|
+
config = _reformat_output(client.get())
|
92
|
+
|
93
|
+
if output:
|
94
|
+
with open(output, 'w') as f:
|
95
|
+
if output.endswith('.yaml') or output.endswith('.yml'):
|
96
|
+
yaml.safe_dump(config, f, sort_keys=False)
|
97
|
+
logger.info(f"Langfuse configuration written to {output}")
|
98
|
+
elif output.endswith('.json'):
|
99
|
+
json.dump(config, f, indent=2)
|
100
|
+
logger.info(f"Langfuse configuration written to {output}")
|
101
|
+
else:
|
102
|
+
raise ValueError('--output file must end in .json, .yaml, or .yml')
|
103
|
+
else:
|
104
|
+
print(yaml.safe_dump(config, sort_keys=False))
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
@settings_observability_langfuse_app.command(name="configure", help='Configure an integration with langfuse')
|
109
|
+
def configure_langfuse(
|
110
|
+
url: Annotated[
|
111
|
+
str,
|
112
|
+
typer.Option("--url", "-u",
|
113
|
+
help="URL of the langfuse instance (required if not specified in --config-file)"
|
114
|
+
),
|
115
|
+
] = None,
|
116
|
+
host_health_uri: Annotated[
|
117
|
+
str,
|
118
|
+
typer.Option("--health-uri",
|
119
|
+
help="Health URI of the langfuse instance (required if not specified in --config-file)"
|
120
|
+
),
|
121
|
+
] = None,
|
122
|
+
project_id: Annotated[
|
123
|
+
str,
|
124
|
+
typer.Option(
|
125
|
+
"--project-id", "-p",
|
126
|
+
help="The langfuse project id (required if not specified in --config-file)"
|
127
|
+
)
|
128
|
+
] = None,
|
129
|
+
api_key: Annotated[
|
130
|
+
str,
|
131
|
+
typer.Option("--api-key", help="The langfuse api key (required if not specified in --config-file)"),
|
132
|
+
] = None,
|
133
|
+
mask_pii: Annotated[ # not currently supported by the runtime
|
134
|
+
bool,
|
135
|
+
typer.Option(
|
136
|
+
"--mask-pii",
|
137
|
+
help="Whether or not PII should be masked from traces before sending them to langfuse",
|
138
|
+
hidden=True
|
139
|
+
),
|
140
|
+
] = None,
|
141
|
+
config_file: Annotated[
|
142
|
+
str,
|
143
|
+
typer.Option('--config-file',
|
144
|
+
help="A config file for the langfuse integration (can be fetched using orchestrate settings )")
|
145
|
+
] = None,
|
146
|
+
config_json: Annotated[
|
147
|
+
str,
|
148
|
+
typer.Option('--config-json',
|
149
|
+
help="A config json object for the langfuse integration")
|
150
|
+
] = None
|
151
|
+
):
|
152
|
+
config_json_dict = json.loads(config_json) if config_json else {}
|
153
|
+
client: AnalyticsLLMClient = instantiate_client(AnalyticsLLMClient)
|
154
|
+
config = _validate_langfuse_input(
|
155
|
+
url=url,
|
156
|
+
project_id=project_id,
|
157
|
+
tool_identifier='langfuse',
|
158
|
+
api_key=api_key,
|
159
|
+
mask_pii=mask_pii,
|
160
|
+
config_file=config_file,
|
161
|
+
host_health_uri=host_health_uri,
|
162
|
+
config_json=config_json_dict
|
163
|
+
)
|
164
|
+
|
165
|
+
try:
|
166
|
+
client.update(config)
|
167
|
+
logger.info(f"Langfuse integration updated")
|
168
|
+
except ClientAPIException as e:
|
169
|
+
logger.error(f"Failed to update langfuse integration")
|
170
|
+
logger.error(AnalyticsLLMResponse.model_validate(e.response.text).status)
|
171
|
+
parsed_error = loads(e.response.text)
|
172
|
+
logger.error(AnalyticsLLMResponse.model_validate(parsed_error).status)
|
173
|
+
|
174
|
+
|
175
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import typer
|
2
|
+
|
3
|
+
from ibm_watsonx_orchestrate.cli.commands.settings.observability.langfuse.langfuse_command import \
|
4
|
+
settings_observability_langfuse_app
|
5
|
+
|
6
|
+
settings_observability_app = typer.Typer(no_args_is_help=True)
|
7
|
+
settings_observability_app.add_typer(
|
8
|
+
settings_observability_langfuse_app,
|
9
|
+
name="langfuse",
|
10
|
+
help="Fetch or configure a langfuse integration"
|
11
|
+
)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import typer
|
2
|
+
|
3
|
+
from ibm_watsonx_orchestrate.cli.commands.settings.observability.observability_command import settings_observability_app
|
4
|
+
|
5
|
+
settings_app = typer.Typer(no_args_is_help=True)
|
6
|
+
settings_app.add_typer(
|
7
|
+
settings_observability_app,
|
8
|
+
name="observability",
|
9
|
+
help="Configures an external observability platform (such as langfuse)"
|
10
|
+
)
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import typer
|
2
|
+
from typing import List
|
3
|
+
from typing_extensions import Annotated
|
4
|
+
from ibm_watsonx_orchestrate.cli.commands.tools.tools_controller import ToolsController, ToolKind
|
5
|
+
tools_app= typer.Typer(no_args_is_help=True)
|
6
|
+
|
7
|
+
@tools_app.command(name="import", help='Import a tool into the active environment')
|
8
|
+
def tool_import(
|
9
|
+
kind: Annotated[
|
10
|
+
ToolKind,
|
11
|
+
typer.Option("--kind", "-k", help="Import Source Format"),
|
12
|
+
],
|
13
|
+
file: Annotated[
|
14
|
+
str,
|
15
|
+
typer.Option(
|
16
|
+
"--file",
|
17
|
+
"-f",
|
18
|
+
help="Path to Python or OpenAPI spec YAML file. Required for kind openapi or python",
|
19
|
+
),
|
20
|
+
] = None,
|
21
|
+
# skillset_id: Annotated[
|
22
|
+
# str, typer.Option("--skillset_id", help="ID of skill set in WXO")
|
23
|
+
# ] = None,
|
24
|
+
# skill_id: Annotated[
|
25
|
+
# str, typer.Option("--skill_id", help="ID of skill in WXO")
|
26
|
+
# ] = None,
|
27
|
+
# skill_operation_path: Annotated[
|
28
|
+
# str, typer.Option("--skill_operation_path", help="Skill operation path in WXO")
|
29
|
+
# ] = None,
|
30
|
+
app_id: Annotated[
|
31
|
+
List[str], typer.Option(
|
32
|
+
'--app-id', '-a',
|
33
|
+
help='The app id of the connection to associate with this tool. A application connection represents the server authentication credentials needed to connection to this tool (for example Api Keys, Basic, Bearer or OAuth credentials).'
|
34
|
+
)
|
35
|
+
] = None,
|
36
|
+
requirements_file: Annotated[
|
37
|
+
str,
|
38
|
+
typer.Option(
|
39
|
+
"--requirements-file",
|
40
|
+
"-r",
|
41
|
+
help="Path to Python requirements.txt file. Required for kind python",
|
42
|
+
),
|
43
|
+
] = None,
|
44
|
+
package_root: Annotated[
|
45
|
+
str,
|
46
|
+
typer.Option("--package-root", "-p", help="""When specified, the package root will be treated
|
47
|
+
as the current working directory from which the module specified by --file will be invoked. All files and dependencies
|
48
|
+
included in this folder will be included within the uploaded package. Local dependencies can either be imported
|
49
|
+
relative to this package root folder or imported using relative imports from the --file. This only applies when the
|
50
|
+
--kind=python. If not specified it is assumed only a single python file is being uploaded."""),
|
51
|
+
] = None,
|
52
|
+
):
|
53
|
+
tools_controller = ToolsController(kind, file, requirements_file)
|
54
|
+
tools = tools_controller.import_tool(
|
55
|
+
kind=kind,
|
56
|
+
file=file,
|
57
|
+
# skillset_id=skillset_id,
|
58
|
+
# skill_id=skill_id,
|
59
|
+
# skill_operation_path=skill_operation_path,
|
60
|
+
app_id=app_id,
|
61
|
+
requirements_file=requirements_file,
|
62
|
+
package_root=package_root
|
63
|
+
)
|
64
|
+
|
65
|
+
tools_controller.publish_or_update_tools(tools, package_root=package_root)
|
66
|
+
|
67
|
+
@tools_app.command(name="list", help='List the imported tools in the active environment')
|
68
|
+
def list_tools(
|
69
|
+
verbose: Annotated[
|
70
|
+
bool,
|
71
|
+
typer.Option("--verbose", "-v", help="List full details of all tools as json"),
|
72
|
+
] = False,
|
73
|
+
):
|
74
|
+
tools_controller = ToolsController()
|
75
|
+
tools_controller.list_tools(verbose=verbose)
|
76
|
+
|
77
|
+
@tools_app.command(name="remove", help='Remove a tool from the active environment')
|
78
|
+
def remove_tool(
|
79
|
+
name: Annotated[
|
80
|
+
str,
|
81
|
+
typer.Option("--name", "-n", help="Name of the tool you wish to remove"),
|
82
|
+
],
|
83
|
+
):
|
84
|
+
tools_controller = ToolsController()
|
85
|
+
tools_controller.remove_tool(name=name)
|