letta-client 0.1.10__py3-none-any.whl → 0.1.13__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 letta-client might be problematic. Click here for more details.
- letta_client/__init__.py +6 -1
- letta_client/agents/__init__.py +4 -0
- letta_client/agents/client.py +174 -34
- letta_client/agents/templates/client.py +6 -6
- letta_client/agents/types/__init__.py +4 -0
- letta_client/agents/types/agents_search_request_search_item.py +19 -1
- letta_client/agents/types/agents_search_request_search_item_tags.py +20 -0
- letta_client/base_client.py +176 -0
- letta_client/client.py +39 -156
- letta_client/core/client_wrapper.py +1 -1
- letta_client/tag/__init__.py +2 -0
- letta_client/tag/client.py +169 -0
- letta_client/tools/client.py +0 -30
- letta_client/types/letta_schemas_tool_tool.py +0 -5
- letta_client/types/tool_create.py +0 -5
- {letta_client-0.1.10.dist-info → letta_client-0.1.13.dist-info}/METADATA +1 -1
- {letta_client-0.1.10.dist-info → letta_client-0.1.13.dist-info}/RECORD +18 -14
- {letta_client-0.1.10.dist-info → letta_client-0.1.13.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from .environment import LettaEnvironment
|
|
5
|
+
import httpx
|
|
6
|
+
from .core.client_wrapper import SyncClientWrapper
|
|
7
|
+
from .tools.client import ToolsClient
|
|
8
|
+
from .sources.client import SourcesClient
|
|
9
|
+
from .agents.client import AgentsClient
|
|
10
|
+
from .models.client import ModelsClient
|
|
11
|
+
from .blocks.client import BlocksClient
|
|
12
|
+
from .jobs.client import JobsClient
|
|
13
|
+
from .health.client import HealthClient
|
|
14
|
+
from .providers.client import ProvidersClient
|
|
15
|
+
from .runs.client import RunsClient
|
|
16
|
+
from .tag.client import TagClient
|
|
17
|
+
from .core.client_wrapper import AsyncClientWrapper
|
|
18
|
+
from .tools.client import AsyncToolsClient
|
|
19
|
+
from .sources.client import AsyncSourcesClient
|
|
20
|
+
from .agents.client import AsyncAgentsClient
|
|
21
|
+
from .models.client import AsyncModelsClient
|
|
22
|
+
from .blocks.client import AsyncBlocksClient
|
|
23
|
+
from .jobs.client import AsyncJobsClient
|
|
24
|
+
from .health.client import AsyncHealthClient
|
|
25
|
+
from .providers.client import AsyncProvidersClient
|
|
26
|
+
from .runs.client import AsyncRunsClient
|
|
27
|
+
from .tag.client import AsyncTagClient
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class LettaBase:
|
|
31
|
+
"""
|
|
32
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
33
|
+
|
|
34
|
+
Parameters
|
|
35
|
+
----------
|
|
36
|
+
base_url : typing.Optional[str]
|
|
37
|
+
The base url to use for requests from the client.
|
|
38
|
+
|
|
39
|
+
environment : LettaEnvironment
|
|
40
|
+
The environment to use for requests from the client. from .environment import LettaEnvironment
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
Defaults to LettaEnvironment.LETTA_CLOUD
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
token : typing.Optional[str]
|
|
49
|
+
timeout : typing.Optional[float]
|
|
50
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
51
|
+
|
|
52
|
+
follow_redirects : typing.Optional[bool]
|
|
53
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
54
|
+
|
|
55
|
+
httpx_client : typing.Optional[httpx.Client]
|
|
56
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
57
|
+
|
|
58
|
+
Examples
|
|
59
|
+
--------
|
|
60
|
+
from letta_client import Letta
|
|
61
|
+
|
|
62
|
+
client = Letta(
|
|
63
|
+
token="YOUR_TOKEN",
|
|
64
|
+
)
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
def __init__(
|
|
68
|
+
self,
|
|
69
|
+
*,
|
|
70
|
+
base_url: typing.Optional[str] = None,
|
|
71
|
+
environment: LettaEnvironment = LettaEnvironment.LETTA_CLOUD,
|
|
72
|
+
token: typing.Optional[str] = None,
|
|
73
|
+
timeout: typing.Optional[float] = None,
|
|
74
|
+
follow_redirects: typing.Optional[bool] = True,
|
|
75
|
+
httpx_client: typing.Optional[httpx.Client] = None,
|
|
76
|
+
):
|
|
77
|
+
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
|
78
|
+
self._client_wrapper = SyncClientWrapper(
|
|
79
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
80
|
+
token=token,
|
|
81
|
+
httpx_client=httpx_client
|
|
82
|
+
if httpx_client is not None
|
|
83
|
+
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
84
|
+
if follow_redirects is not None
|
|
85
|
+
else httpx.Client(timeout=_defaulted_timeout),
|
|
86
|
+
timeout=_defaulted_timeout,
|
|
87
|
+
)
|
|
88
|
+
self.tools = ToolsClient(client_wrapper=self._client_wrapper)
|
|
89
|
+
self.sources = SourcesClient(client_wrapper=self._client_wrapper)
|
|
90
|
+
self.agents = AgentsClient(client_wrapper=self._client_wrapper)
|
|
91
|
+
self.models = ModelsClient(client_wrapper=self._client_wrapper)
|
|
92
|
+
self.blocks = BlocksClient(client_wrapper=self._client_wrapper)
|
|
93
|
+
self.jobs = JobsClient(client_wrapper=self._client_wrapper)
|
|
94
|
+
self.health = HealthClient(client_wrapper=self._client_wrapper)
|
|
95
|
+
self.providers = ProvidersClient(client_wrapper=self._client_wrapper)
|
|
96
|
+
self.runs = RunsClient(client_wrapper=self._client_wrapper)
|
|
97
|
+
self.tag = TagClient(client_wrapper=self._client_wrapper)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class AsyncLettaBase:
|
|
101
|
+
"""
|
|
102
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
103
|
+
|
|
104
|
+
Parameters
|
|
105
|
+
----------
|
|
106
|
+
base_url : typing.Optional[str]
|
|
107
|
+
The base url to use for requests from the client.
|
|
108
|
+
|
|
109
|
+
environment : LettaEnvironment
|
|
110
|
+
The environment to use for requests from the client. from .environment import LettaEnvironment
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
Defaults to LettaEnvironment.LETTA_CLOUD
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
token : typing.Optional[str]
|
|
119
|
+
timeout : typing.Optional[float]
|
|
120
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
121
|
+
|
|
122
|
+
follow_redirects : typing.Optional[bool]
|
|
123
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
124
|
+
|
|
125
|
+
httpx_client : typing.Optional[httpx.AsyncClient]
|
|
126
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
127
|
+
|
|
128
|
+
Examples
|
|
129
|
+
--------
|
|
130
|
+
from letta_client import AsyncLetta
|
|
131
|
+
|
|
132
|
+
client = AsyncLetta(
|
|
133
|
+
token="YOUR_TOKEN",
|
|
134
|
+
)
|
|
135
|
+
"""
|
|
136
|
+
|
|
137
|
+
def __init__(
|
|
138
|
+
self,
|
|
139
|
+
*,
|
|
140
|
+
base_url: typing.Optional[str] = None,
|
|
141
|
+
environment: LettaEnvironment = LettaEnvironment.LETTA_CLOUD,
|
|
142
|
+
token: typing.Optional[str] = None,
|
|
143
|
+
timeout: typing.Optional[float] = None,
|
|
144
|
+
follow_redirects: typing.Optional[bool] = True,
|
|
145
|
+
httpx_client: typing.Optional[httpx.AsyncClient] = None,
|
|
146
|
+
):
|
|
147
|
+
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
|
148
|
+
self._client_wrapper = AsyncClientWrapper(
|
|
149
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
150
|
+
token=token,
|
|
151
|
+
httpx_client=httpx_client
|
|
152
|
+
if httpx_client is not None
|
|
153
|
+
else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
154
|
+
if follow_redirects is not None
|
|
155
|
+
else httpx.AsyncClient(timeout=_defaulted_timeout),
|
|
156
|
+
timeout=_defaulted_timeout,
|
|
157
|
+
)
|
|
158
|
+
self.tools = AsyncToolsClient(client_wrapper=self._client_wrapper)
|
|
159
|
+
self.sources = AsyncSourcesClient(client_wrapper=self._client_wrapper)
|
|
160
|
+
self.agents = AsyncAgentsClient(client_wrapper=self._client_wrapper)
|
|
161
|
+
self.models = AsyncModelsClient(client_wrapper=self._client_wrapper)
|
|
162
|
+
self.blocks = AsyncBlocksClient(client_wrapper=self._client_wrapper)
|
|
163
|
+
self.jobs = AsyncJobsClient(client_wrapper=self._client_wrapper)
|
|
164
|
+
self.health = AsyncHealthClient(client_wrapper=self._client_wrapper)
|
|
165
|
+
self.providers = AsyncProvidersClient(client_wrapper=self._client_wrapper)
|
|
166
|
+
self.runs = AsyncRunsClient(client_wrapper=self._client_wrapper)
|
|
167
|
+
self.tag = AsyncTagClient(client_wrapper=self._client_wrapper)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: LettaEnvironment) -> str:
|
|
171
|
+
if base_url is not None:
|
|
172
|
+
return base_url
|
|
173
|
+
elif environment is not None:
|
|
174
|
+
return environment.value
|
|
175
|
+
else:
|
|
176
|
+
raise Exception("Please pass in either base_url or environment to construct the client")
|
letta_client/client.py
CHANGED
|
@@ -1,172 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
from textwrap import dedent
|
|
2
|
+
import inspect
|
|
3
3
|
import typing
|
|
4
|
-
from .environment import LettaEnvironment
|
|
5
|
-
import httpx
|
|
6
|
-
from .core.client_wrapper import SyncClientWrapper
|
|
7
|
-
from .tools.client import ToolsClient
|
|
8
|
-
from .sources.client import SourcesClient
|
|
9
|
-
from .agents.client import AgentsClient
|
|
10
|
-
from .models.client import ModelsClient
|
|
11
|
-
from .blocks.client import BlocksClient
|
|
12
|
-
from .jobs.client import JobsClient
|
|
13
|
-
from .health.client import HealthClient
|
|
14
|
-
from .providers.client import ProvidersClient
|
|
15
|
-
from .runs.client import RunsClient
|
|
16
|
-
from .core.client_wrapper import AsyncClientWrapper
|
|
17
|
-
from .tools.client import AsyncToolsClient
|
|
18
|
-
from .sources.client import AsyncSourcesClient
|
|
19
|
-
from .agents.client import AsyncAgentsClient
|
|
20
|
-
from .models.client import AsyncModelsClient
|
|
21
|
-
from .blocks.client import AsyncBlocksClient
|
|
22
|
-
from .jobs.client import AsyncJobsClient
|
|
23
|
-
from .health.client import AsyncHealthClient
|
|
24
|
-
from .providers.client import AsyncProvidersClient
|
|
25
|
-
from .runs.client import AsyncRunsClient
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class Letta:
|
|
29
|
-
"""
|
|
30
|
-
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
31
|
-
|
|
32
|
-
Parameters
|
|
33
|
-
----------
|
|
34
|
-
base_url : typing.Optional[str]
|
|
35
|
-
The base url to use for requests from the client.
|
|
36
|
-
|
|
37
|
-
environment : LettaEnvironment
|
|
38
|
-
The environment to use for requests from the client. from .environment import LettaEnvironment
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Defaults to LettaEnvironment.LETTA_CLOUD
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
token : typing.Optional[str]
|
|
47
|
-
timeout : typing.Optional[float]
|
|
48
|
-
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
49
|
-
|
|
50
|
-
follow_redirects : typing.Optional[bool]
|
|
51
|
-
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
52
4
|
|
|
53
|
-
|
|
54
|
-
|
|
5
|
+
from .base_client import LettaBase, AsyncLettaBase
|
|
6
|
+
from .core.request_options import RequestOptions
|
|
7
|
+
from .tools.client import ToolsClient as ToolsClientBase
|
|
8
|
+
from .types.letta_schemas_tool_tool import LettaSchemasToolTool
|
|
55
9
|
|
|
56
|
-
Examples
|
|
57
|
-
--------
|
|
58
|
-
from letta_client import Letta
|
|
59
10
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)
|
|
63
|
-
"""
|
|
11
|
+
# this is used as the default value for optional parameters
|
|
12
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
64
13
|
|
|
65
|
-
def __init__(
|
|
66
|
-
self,
|
|
67
|
-
*,
|
|
68
|
-
base_url: typing.Optional[str] = None,
|
|
69
|
-
environment: LettaEnvironment = LettaEnvironment.LETTA_CLOUD,
|
|
70
|
-
token: typing.Optional[str] = None,
|
|
71
|
-
timeout: typing.Optional[float] = None,
|
|
72
|
-
follow_redirects: typing.Optional[bool] = True,
|
|
73
|
-
httpx_client: typing.Optional[httpx.Client] = None,
|
|
74
|
-
):
|
|
75
|
-
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
|
76
|
-
self._client_wrapper = SyncClientWrapper(
|
|
77
|
-
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
78
|
-
token=token,
|
|
79
|
-
httpx_client=httpx_client
|
|
80
|
-
if httpx_client is not None
|
|
81
|
-
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
82
|
-
if follow_redirects is not None
|
|
83
|
-
else httpx.Client(timeout=_defaulted_timeout),
|
|
84
|
-
timeout=_defaulted_timeout,
|
|
85
|
-
)
|
|
86
|
-
self.tools = ToolsClient(client_wrapper=self._client_wrapper)
|
|
87
|
-
self.sources = SourcesClient(client_wrapper=self._client_wrapper)
|
|
88
|
-
self.agents = AgentsClient(client_wrapper=self._client_wrapper)
|
|
89
|
-
self.models = ModelsClient(client_wrapper=self._client_wrapper)
|
|
90
|
-
self.blocks = BlocksClient(client_wrapper=self._client_wrapper)
|
|
91
|
-
self.jobs = JobsClient(client_wrapper=self._client_wrapper)
|
|
92
|
-
self.health = HealthClient(client_wrapper=self._client_wrapper)
|
|
93
|
-
self.providers = ProvidersClient(client_wrapper=self._client_wrapper)
|
|
94
|
-
self.runs = RunsClient(client_wrapper=self._client_wrapper)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
class AsyncLetta:
|
|
98
|
-
"""
|
|
99
|
-
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
100
|
-
|
|
101
|
-
Parameters
|
|
102
|
-
----------
|
|
103
|
-
base_url : typing.Optional[str]
|
|
104
|
-
The base url to use for requests from the client.
|
|
105
14
|
|
|
106
|
-
|
|
107
|
-
The environment to use for requests from the client. from .environment import LettaEnvironment
|
|
15
|
+
class Letta(LettaBase):
|
|
108
16
|
|
|
17
|
+
def __init__(self, *args, **kwargs):
|
|
18
|
+
super().__init__(*args, **kwargs)
|
|
19
|
+
self.tools = ExtendedToolsClient(client_wrapper=self._client_wrapper)
|
|
109
20
|
|
|
110
21
|
|
|
111
|
-
|
|
22
|
+
class AsyncLetta(AsyncLettaBase):
|
|
112
23
|
|
|
24
|
+
def __init__(self, *args, **kwargs):
|
|
25
|
+
super().__init__(*args, **kwargs)
|
|
26
|
+
self.tools = ExtendedToolsClient(client_wrapper=self._client_wrapper)
|
|
113
27
|
|
|
114
28
|
|
|
115
|
-
|
|
116
|
-
timeout : typing.Optional[float]
|
|
117
|
-
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
29
|
+
class ToolsClient(ToolsClientBase):
|
|
118
30
|
|
|
119
|
-
|
|
120
|
-
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
121
|
-
|
|
122
|
-
httpx_client : typing.Optional[httpx.AsyncClient]
|
|
123
|
-
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
124
|
-
|
|
125
|
-
Examples
|
|
126
|
-
--------
|
|
127
|
-
from letta_client import AsyncLetta
|
|
128
|
-
|
|
129
|
-
client = AsyncLetta(
|
|
130
|
-
token="YOUR_TOKEN",
|
|
131
|
-
)
|
|
132
|
-
"""
|
|
133
|
-
|
|
134
|
-
def __init__(
|
|
31
|
+
def create_from_function(
|
|
135
32
|
self,
|
|
136
33
|
*,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
34
|
+
function: typing.Callable,
|
|
35
|
+
name: typing.Optional[str] = OMIT,
|
|
36
|
+
description: typing.Optional[str] = OMIT,
|
|
37
|
+
tags: typing.Optional[typing.Sequence[str]] = OMIT,
|
|
38
|
+
source_type: typing.Optional[str] = OMIT,
|
|
39
|
+
json_schema: typing.Optional[
|
|
40
|
+
typing.Dict[str, typing.Optional[typing.Any]]
|
|
41
|
+
] = OMIT,
|
|
42
|
+
return_char_limit: typing.Optional[int] = OMIT,
|
|
43
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
44
|
+
) -> LettaSchemasToolTool:
|
|
45
|
+
source_code = dedent(inspect.getsource(function))
|
|
46
|
+
return self.create(
|
|
47
|
+
source_code=source_code,
|
|
48
|
+
name=name,
|
|
49
|
+
description=description,
|
|
50
|
+
tags=tags,
|
|
51
|
+
source_type=source_type,
|
|
52
|
+
json_schema=json_schema,
|
|
53
|
+
return_char_limit=return_char_limit,
|
|
54
|
+
request_options=request_options,
|
|
154
55
|
)
|
|
155
|
-
self.tools = AsyncToolsClient(client_wrapper=self._client_wrapper)
|
|
156
|
-
self.sources = AsyncSourcesClient(client_wrapper=self._client_wrapper)
|
|
157
|
-
self.agents = AsyncAgentsClient(client_wrapper=self._client_wrapper)
|
|
158
|
-
self.models = AsyncModelsClient(client_wrapper=self._client_wrapper)
|
|
159
|
-
self.blocks = AsyncBlocksClient(client_wrapper=self._client_wrapper)
|
|
160
|
-
self.jobs = AsyncJobsClient(client_wrapper=self._client_wrapper)
|
|
161
|
-
self.health = AsyncHealthClient(client_wrapper=self._client_wrapper)
|
|
162
|
-
self.providers = AsyncProvidersClient(client_wrapper=self._client_wrapper)
|
|
163
|
-
self.runs = AsyncRunsClient(client_wrapper=self._client_wrapper)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: LettaEnvironment) -> str:
|
|
167
|
-
if base_url is not None:
|
|
168
|
-
return base_url
|
|
169
|
-
elif environment is not None:
|
|
170
|
-
return environment.value
|
|
171
|
-
else:
|
|
172
|
-
raise Exception("Please pass in either base_url or environment to construct the client")
|
|
@@ -16,7 +16,7 @@ class BaseClientWrapper:
|
|
|
16
16
|
headers: typing.Dict[str, str] = {
|
|
17
17
|
"X-Fern-Language": "Python",
|
|
18
18
|
"X-Fern-SDK-Name": "letta-client",
|
|
19
|
-
"X-Fern-SDK-Version": "0.1.
|
|
19
|
+
"X-Fern-SDK-Version": "0.1.13",
|
|
20
20
|
}
|
|
21
21
|
if self.token is not None:
|
|
22
22
|
headers["Authorization"] = f"Bearer {self.token}"
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from ..core.client_wrapper import SyncClientWrapper
|
|
4
|
+
import typing
|
|
5
|
+
from ..core.request_options import RequestOptions
|
|
6
|
+
from ..core.unchecked_base_model import construct_type
|
|
7
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
8
|
+
from ..types.http_validation_error import HttpValidationError
|
|
9
|
+
from json.decoder import JSONDecodeError
|
|
10
|
+
from ..core.api_error import ApiError
|
|
11
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TagClient:
|
|
15
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
16
|
+
self._client_wrapper = client_wrapper
|
|
17
|
+
|
|
18
|
+
def list_tags(
|
|
19
|
+
self,
|
|
20
|
+
*,
|
|
21
|
+
cursor: typing.Optional[str] = None,
|
|
22
|
+
limit: typing.Optional[int] = None,
|
|
23
|
+
query_text: typing.Optional[str] = None,
|
|
24
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
25
|
+
) -> typing.List[str]:
|
|
26
|
+
"""
|
|
27
|
+
Get a list of all tags in the database
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
cursor : typing.Optional[str]
|
|
32
|
+
|
|
33
|
+
limit : typing.Optional[int]
|
|
34
|
+
|
|
35
|
+
query_text : typing.Optional[str]
|
|
36
|
+
|
|
37
|
+
request_options : typing.Optional[RequestOptions]
|
|
38
|
+
Request-specific configuration.
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
-------
|
|
42
|
+
typing.List[str]
|
|
43
|
+
Successful Response
|
|
44
|
+
|
|
45
|
+
Examples
|
|
46
|
+
--------
|
|
47
|
+
from letta_client import Letta
|
|
48
|
+
|
|
49
|
+
client = Letta(
|
|
50
|
+
token="YOUR_TOKEN",
|
|
51
|
+
)
|
|
52
|
+
client.tag.list_tags()
|
|
53
|
+
"""
|
|
54
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
55
|
+
"v1/tags/",
|
|
56
|
+
method="GET",
|
|
57
|
+
params={
|
|
58
|
+
"cursor": cursor,
|
|
59
|
+
"limit": limit,
|
|
60
|
+
"query_text": query_text,
|
|
61
|
+
},
|
|
62
|
+
request_options=request_options,
|
|
63
|
+
)
|
|
64
|
+
try:
|
|
65
|
+
if 200 <= _response.status_code < 300:
|
|
66
|
+
return typing.cast(
|
|
67
|
+
typing.List[str],
|
|
68
|
+
construct_type(
|
|
69
|
+
type_=typing.List[str], # type: ignore
|
|
70
|
+
object_=_response.json(),
|
|
71
|
+
),
|
|
72
|
+
)
|
|
73
|
+
if _response.status_code == 422:
|
|
74
|
+
raise UnprocessableEntityError(
|
|
75
|
+
typing.cast(
|
|
76
|
+
HttpValidationError,
|
|
77
|
+
construct_type(
|
|
78
|
+
type_=HttpValidationError, # type: ignore
|
|
79
|
+
object_=_response.json(),
|
|
80
|
+
),
|
|
81
|
+
)
|
|
82
|
+
)
|
|
83
|
+
_response_json = _response.json()
|
|
84
|
+
except JSONDecodeError:
|
|
85
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
86
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class AsyncTagClient:
|
|
90
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
91
|
+
self._client_wrapper = client_wrapper
|
|
92
|
+
|
|
93
|
+
async def list_tags(
|
|
94
|
+
self,
|
|
95
|
+
*,
|
|
96
|
+
cursor: typing.Optional[str] = None,
|
|
97
|
+
limit: typing.Optional[int] = None,
|
|
98
|
+
query_text: typing.Optional[str] = None,
|
|
99
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
100
|
+
) -> typing.List[str]:
|
|
101
|
+
"""
|
|
102
|
+
Get a list of all tags in the database
|
|
103
|
+
|
|
104
|
+
Parameters
|
|
105
|
+
----------
|
|
106
|
+
cursor : typing.Optional[str]
|
|
107
|
+
|
|
108
|
+
limit : typing.Optional[int]
|
|
109
|
+
|
|
110
|
+
query_text : typing.Optional[str]
|
|
111
|
+
|
|
112
|
+
request_options : typing.Optional[RequestOptions]
|
|
113
|
+
Request-specific configuration.
|
|
114
|
+
|
|
115
|
+
Returns
|
|
116
|
+
-------
|
|
117
|
+
typing.List[str]
|
|
118
|
+
Successful Response
|
|
119
|
+
|
|
120
|
+
Examples
|
|
121
|
+
--------
|
|
122
|
+
import asyncio
|
|
123
|
+
|
|
124
|
+
from letta_client import AsyncLetta
|
|
125
|
+
|
|
126
|
+
client = AsyncLetta(
|
|
127
|
+
token="YOUR_TOKEN",
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
async def main() -> None:
|
|
132
|
+
await client.tag.list_tags()
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
asyncio.run(main())
|
|
136
|
+
"""
|
|
137
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
138
|
+
"v1/tags/",
|
|
139
|
+
method="GET",
|
|
140
|
+
params={
|
|
141
|
+
"cursor": cursor,
|
|
142
|
+
"limit": limit,
|
|
143
|
+
"query_text": query_text,
|
|
144
|
+
},
|
|
145
|
+
request_options=request_options,
|
|
146
|
+
)
|
|
147
|
+
try:
|
|
148
|
+
if 200 <= _response.status_code < 300:
|
|
149
|
+
return typing.cast(
|
|
150
|
+
typing.List[str],
|
|
151
|
+
construct_type(
|
|
152
|
+
type_=typing.List[str], # type: ignore
|
|
153
|
+
object_=_response.json(),
|
|
154
|
+
),
|
|
155
|
+
)
|
|
156
|
+
if _response.status_code == 422:
|
|
157
|
+
raise UnprocessableEntityError(
|
|
158
|
+
typing.cast(
|
|
159
|
+
HttpValidationError,
|
|
160
|
+
construct_type(
|
|
161
|
+
type_=HttpValidationError, # type: ignore
|
|
162
|
+
object_=_response.json(),
|
|
163
|
+
),
|
|
164
|
+
)
|
|
165
|
+
)
|
|
166
|
+
_response_json = _response.json()
|
|
167
|
+
except JSONDecodeError:
|
|
168
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
169
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|