optimizely-opal.opal-tools-sdk 0.1.0.dev0__py3-none-any.whl → 0.1.1.dev0__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.
Potentially problematic release.
This version of optimizely-opal.opal-tools-sdk might be problematic. Click here for more details.
- optimizely_opal_opal_tools_sdk-0.1.1.dev0.dist-info/METADATA +138 -0
- {optimizely_opal_opal_tools_sdk-0.1.0.dev0.dist-info → optimizely_opal_opal_tools_sdk-0.1.1.dev0.dist-info}/RECORD +4 -4
- optimizely_opal_opal_tools_sdk-0.1.0.dev0.dist-info/METADATA +0 -24
- {optimizely_opal_opal_tools_sdk-0.1.0.dev0.dist-info → optimizely_opal_opal_tools_sdk-0.1.1.dev0.dist-info}/WHEEL +0 -0
- {optimizely_opal_opal_tools_sdk-0.1.0.dev0.dist-info → optimizely_opal_opal_tools_sdk-0.1.1.dev0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: optimizely-opal.opal-tools-sdk
|
|
3
|
+
Version: 0.1.1.dev0
|
|
4
|
+
Summary: SDK for creating Opal-compatible tools services
|
|
5
|
+
Home-page: https://github.com/optimizely/opal-tools-sdk
|
|
6
|
+
Author: Optimizely
|
|
7
|
+
Author-email: Optimizely <opal-team@optimizely.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/optimizely/opal-tools-sdk
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/optimizely/opal-tools-sdk/issues
|
|
11
|
+
Keywords: opal,tools,sdk,ai,llm
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
Requires-Dist: fastapi>=0.100.0
|
|
19
|
+
Requires-Dist: pydantic>=2.0.0
|
|
20
|
+
Requires-Dist: httpx>=0.24.1
|
|
21
|
+
Dynamic: author
|
|
22
|
+
Dynamic: home-page
|
|
23
|
+
Dynamic: requires-python
|
|
24
|
+
|
|
25
|
+
# Opal Tools SDK for Python
|
|
26
|
+
|
|
27
|
+
This SDK simplifies the creation of tools services compatible with the Opal Tools Management Service.
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- Easy definition of tool functions with decorators
|
|
32
|
+
- Automatic generation of discovery endpoints
|
|
33
|
+
- Parameter validation and type checking
|
|
34
|
+
- Authentication helpers
|
|
35
|
+
- FastAPI integration
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install optimizely-opal.opal-tools-sdk
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Note: While the package is installed as `optimizely-opal.opal-tools-sdk`, you'll still import it in your code as `opal_tools_sdk`:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
# Import using the package name
|
|
47
|
+
from opal_tools_sdk import ToolsService, tool
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Usage
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from opal_tools_sdk import ToolsService, tool
|
|
54
|
+
from pydantic import BaseModel
|
|
55
|
+
from fastapi import FastAPI
|
|
56
|
+
|
|
57
|
+
app = FastAPI()
|
|
58
|
+
tools_service = ToolsService(app)
|
|
59
|
+
|
|
60
|
+
class WeatherParameters(BaseModel):
|
|
61
|
+
location: str
|
|
62
|
+
units: str = "metric"
|
|
63
|
+
|
|
64
|
+
@tool("get_weather", "Gets current weather for a location")
|
|
65
|
+
async def get_weather(parameters: WeatherParameters):
|
|
66
|
+
# Implementation...
|
|
67
|
+
return {"temperature": 22, "condition": "sunny"}
|
|
68
|
+
|
|
69
|
+
# Discovery endpoint is automatically created at /discovery
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Authentication
|
|
73
|
+
|
|
74
|
+
The SDK provides two ways to require authentication for your tools:
|
|
75
|
+
|
|
76
|
+
### 1. Using the `@requires_auth` decorator
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from opal_tools_sdk import ToolsService, tool
|
|
80
|
+
from opal_tools_sdk.auth import requires_auth
|
|
81
|
+
from pydantic import BaseModel
|
|
82
|
+
from fastapi import FastAPI
|
|
83
|
+
|
|
84
|
+
app = FastAPI()
|
|
85
|
+
tools_service = ToolsService(app)
|
|
86
|
+
|
|
87
|
+
class CalendarParameters(BaseModel):
|
|
88
|
+
date: str
|
|
89
|
+
timezone: str = "UTC"
|
|
90
|
+
|
|
91
|
+
# Single authentication requirement
|
|
92
|
+
@requires_auth(provider="google", scope_bundle="calendar", required=True)
|
|
93
|
+
@tool("get_calendar_events", "Gets calendar events for a date")
|
|
94
|
+
async def get_calendar_events(parameters: CalendarParameters, auth_data=None):
|
|
95
|
+
# The auth_data parameter contains authentication information
|
|
96
|
+
token = auth_data.get("credentials", {}).get("token", "")
|
|
97
|
+
|
|
98
|
+
# Use the token to make authenticated requests
|
|
99
|
+
# ...
|
|
100
|
+
|
|
101
|
+
return {"events": ["Meeting at 10:00", "Lunch at 12:00"]}
|
|
102
|
+
|
|
103
|
+
# Multiple authentication requirements (tool can work with either provider)
|
|
104
|
+
@requires_auth(provider="google", scope_bundle="calendar", required=True)
|
|
105
|
+
@requires_auth(provider="microsoft", scope_bundle="outlook", required=True)
|
|
106
|
+
@tool("get_calendar_availability", "Check calendar availability")
|
|
107
|
+
async def get_calendar_availability(parameters: CalendarParameters, auth_data=None):
|
|
108
|
+
provider = auth_data.get("provider", "")
|
|
109
|
+
token = auth_data.get("credentials", {}).get("token", "")
|
|
110
|
+
|
|
111
|
+
if provider == "google":
|
|
112
|
+
# Use Google Calendar API
|
|
113
|
+
pass
|
|
114
|
+
elif provider == "microsoft":
|
|
115
|
+
# Use Microsoft Outlook API
|
|
116
|
+
pass
|
|
117
|
+
|
|
118
|
+
return {"available": True, "provider_used": provider}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### 2. Specifying auth requirements in the `@tool` decorator
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
@tool(
|
|
125
|
+
"get_email",
|
|
126
|
+
"Gets emails from the user's inbox",
|
|
127
|
+
auth_requirements=[
|
|
128
|
+
{"provider": "google", "scope_bundle": "gmail", "required": True}
|
|
129
|
+
]
|
|
130
|
+
)
|
|
131
|
+
async def get_email(parameters: EmailParameters, auth_data=None):
|
|
132
|
+
# Implementation...
|
|
133
|
+
return {"emails": ["Email 1", "Email 2"]}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Documentation
|
|
137
|
+
|
|
138
|
+
See full documentation for more examples and configuration options.
|
|
@@ -4,7 +4,7 @@ opal_tools_sdk/auth.py,sha256=9aMiZv6n6_iu7hQA0sKg4hgNr5DzYFFuP0SWUoZf_Vw,1520
|
|
|
4
4
|
opal_tools_sdk/decorators.py,sha256=a_CJcA11RW8eAt2xRGXZane_HvTZqR7wfhn-6WFgjOY,5057
|
|
5
5
|
opal_tools_sdk/models.py,sha256=fa2hhnZ2GTz6xqhGTNyqyIQj_rBE1UFQxsJ4KfApCiU,2123
|
|
6
6
|
opal_tools_sdk/service.py,sha256=tVaQKFpTX778UUWoczlM2WHSiUXqdYtYSKgTdqTH1Z0,6756
|
|
7
|
-
optimizely_opal_opal_tools_sdk-0.1.
|
|
8
|
-
optimizely_opal_opal_tools_sdk-0.1.
|
|
9
|
-
optimizely_opal_opal_tools_sdk-0.1.
|
|
10
|
-
optimizely_opal_opal_tools_sdk-0.1.
|
|
7
|
+
optimizely_opal_opal_tools_sdk-0.1.1.dev0.dist-info/METADATA,sha256=4aDxdgUB-3Z0Je3TgjzFDtgQ9tRVpPdcRAQks0XA5j8,4115
|
|
8
|
+
optimizely_opal_opal_tools_sdk-0.1.1.dev0.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
|
9
|
+
optimizely_opal_opal_tools_sdk-0.1.1.dev0.dist-info/top_level.txt,sha256=nCJ5PxF0rgoV6yNJvvuUaZPx4D3EWkl7gpu-6xafH1E,15
|
|
10
|
+
optimizely_opal_opal_tools_sdk-0.1.1.dev0.dist-info/RECORD,,
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: optimizely-opal.opal-tools-sdk
|
|
3
|
-
Version: 0.1.0.dev0
|
|
4
|
-
Summary: SDK for creating Opal-compatible tools services
|
|
5
|
-
Home-page: https://github.com/optimizely/opal-tools-sdk
|
|
6
|
-
Author: Optimizely
|
|
7
|
-
Author-email: opal-team@optimizely.com
|
|
8
|
-
Keywords: opal,tools,sdk,ai,llm
|
|
9
|
-
Classifier: Development Status :: 3 - Alpha
|
|
10
|
-
Classifier: Intended Audience :: Developers
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
-
Requires-Python: >=3.10
|
|
14
|
-
Requires-Dist: fastapi>=0.100.0
|
|
15
|
-
Requires-Dist: pydantic>=2.0.0
|
|
16
|
-
Requires-Dist: httpx>=0.24.1
|
|
17
|
-
Dynamic: author
|
|
18
|
-
Dynamic: author-email
|
|
19
|
-
Dynamic: classifier
|
|
20
|
-
Dynamic: home-page
|
|
21
|
-
Dynamic: keywords
|
|
22
|
-
Dynamic: requires-dist
|
|
23
|
-
Dynamic: requires-python
|
|
24
|
-
Dynamic: summary
|
|
File without changes
|