Skip to content

Commit cb20701

Browse files
jameszyaoSimsonW
authored andcommitted
feat: add tools and retrievals
1 parent 2491b43 commit cb20701

File tree

14 files changed

+502
-452
lines changed

14 files changed

+502
-452
lines changed

taskingai/assistant/assistant.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
AssistantGetResponse, AssistantListResponse
88

99
__all__ = [
10+
"Assistant",
1011
"get_assistant",
1112
"list_assistants",
1213
"create_assistant",
@@ -33,7 +34,7 @@ def list_assistants(
3334
:param before: The cursor to get the previous page of assistants.
3435
:return: The list of assistants.
3536
"""
36-
37+
# todo: verify only one of offset, after and before is not None
3738
api_instance = get_assistant_api_instance()
3839
# only add non-None parameters
3940
params = {
@@ -70,7 +71,7 @@ def create_assistant(
7071
system_prompt_template: Optional[List[str]] = None,
7172
tools: Optional[List[AssistantTool]] = None,
7273
retrievals: Optional[List[AssistantRetrieval]] = None,
73-
metadata: Optional[Dict] = None,
74+
metadata: Optional[Dict[str, str]] = None,
7475
) -> Assistant:
7576
"""
7677
Create an assistant.
@@ -82,7 +83,7 @@ def create_assistant(
8283
:param tools: The assistant tools.
8384
:param retrievals: The assistant retrievals.
8485
:param metadata: The assistant metadata. It can store up to 16 key-value pairs where each key's length is less than 64 and value's length is less than 512.
85-
:return: The assistant object.
86+
:return: The created assistant object.
8687
"""
8788

8889
api_instance = get_assistant_api_instance()
@@ -108,7 +109,7 @@ def update_assistant(
108109
system_prompt_template: Optional[List[str]] = None,
109110
tools: Optional[List[AssistantTool]] = None,
110111
retrievals: Optional[List[AssistantRetrieval]] = None,
111-
metadata: Optional[Dict] = None,
112+
metadata: Optional[Dict[str, str]] = None,
112113
) -> Assistant:
113114
"""
114115
Update an assistant.
@@ -121,7 +122,7 @@ def update_assistant(
121122
:param tools: The assistant tools.
122123
:param retrievals: The assistant retrievals.
123124
:param metadata: The assistant metadata. It can store up to 16 key-value pairs where each key's length is less than 64 and value's length is less than 512.
124-
:return: The assistant object.
125+
:return: The updated assistant object.
125126
"""
126127

127128
api_instance = get_assistant_api_instance()

taskingai/assistant/chat.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
ChatGetResponse, ChatListResponse
88

99
__all__ = [
10+
"Chat",
1011
"get_chat",
1112
"list_chats",
1213
"create_chat",
@@ -24,7 +25,7 @@ def list_chats(
2425
) -> List[Chat]:
2526
"""
2627
List chats.
27-
28+
:param assistant_id: The ID of the assistant.
2829
:param order: The order of the chats. It can be "asc" or "desc".
2930
:param limit: The maximum number of chats to return.
3031
:param after: The cursor to get the next page of chats.
@@ -68,14 +69,14 @@ def get_chat(assistant_id: str, chat_id: str) -> Chat:
6869

6970
def create_chat(
7071
assistant_id: str,
71-
metadata: Optional[Dict] = None,
72+
metadata: Optional[Dict[str, str]] = None,
7273
) -> Chat:
7374
"""
7475
Create a chat.
7576
7677
:param assistant_id: The ID of the assistant.
7778
:param metadata: The chat metadata. It can store up to 16 key-value pairs where each key's length is less than 64 and value's length is less than 512.
78-
:return: The assistant object.
79+
:return: The created chat object.
7980
"""
8081

8182
api_instance = get_assistant_api_instance()
@@ -93,15 +94,15 @@ def create_chat(
9394
def update_chat(
9495
assistant_id: str,
9596
chat_id: str,
96-
metadata: Dict,
97+
metadata: Dict[str, str],
9798
) -> Chat:
9899
"""
99100
Update a chat.
100101
101102
:param assistant_id: The ID of the assistant.
102103
:param chat_id: The ID of the chat.
103104
:param metadata: The assistant metadata. It can store up to 16 key-value pairs where each key's length is less than 64 and value's length is less than 512.
104-
:return: The assistant object.
105+
:return: The updated chat object.
105106
"""
106107

107108
api_instance = get_assistant_api_instance()

taskingai/assistant/message.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
MessageGetResponse, MessageListResponse, MessageGenerateRequest
88

99
__all__ = [
10+
"Message",
1011
"get_message",
1112
"list_messages",
1213
"create_user_message",
@@ -26,6 +27,8 @@ def list_messages(
2627
"""
2728
List messages.
2829
30+
:param assistant_id: The ID of the assistant.
31+
:param chat_id: The ID of the chat.
2932
:param order: The order of the messages. It can be "asc" or "desc".
3033
:param limit: The maximum number of messages to return.
3134
:param after: The cursor to get the next page of messages.
@@ -78,7 +81,7 @@ def create_user_message(
7881
assistant_id: str,
7982
chat_id: str,
8083
text: str,
81-
metadata: Optional[Dict] = None,
84+
metadata: Optional[Dict[str, str]] = None,
8285
) -> Message:
8386
"""
8487
Create a message.
@@ -87,7 +90,7 @@ def create_user_message(
8790
:param chat_id: The ID of the chat.
8891
:param text: The text content of the message.
8992
:param metadata: The message metadata. It can store up to 16 key-value pairs where each key's length is less than 64 and value's length is less than 512.
90-
:return: The assistant object.
93+
:return: The created message object.
9194
"""
9295

9396
api_instance = get_assistant_api_instance()
@@ -108,15 +111,15 @@ def create_user_message(
108111
def update_message(
109112
assistant_id: str,
110113
message_id: str,
111-
metadata: Dict,
114+
metadata: Dict[str, str],
112115
) -> Message:
113116
"""
114117
Update a message.
115118
116119
:param assistant_id: The ID of the assistant.
117120
:param message_id: The ID of the message.
118121
:param metadata: The assistant metadata. It can store up to 16 key-value pairs where each key's length is less than 64 and value's length is less than 512.
119-
:return: The assistant object.
122+
:return: The updated message object.
120123
"""
121124

122125
api_instance = get_assistant_api_instance()
@@ -145,7 +148,7 @@ def generate_assistant_message(
145148
:param chat_id: The ID of the chat.
146149
:param text: The text content of the message.
147150
:param metadata: The message metadata. It can store up to 16 key-value pairs where each key's length is less than 64 and value's length is less than 512.
148-
:return: The assistant object.
151+
:return: The generated message object.
149152
"""
150153

151154
api_instance = get_assistant_api_instance()

taskingai/client/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
from taskingai.client.configuration import Configuration
2121
# import models into sdk package
2222
from taskingai.client.models.action import Action
23-
from taskingai.client.models.action_authentication_input import ActionAuthenticationInput
24-
from taskingai.client.models.action_authentication_output import ActionAuthenticationOutput
23+
from taskingai.client.models.action_authentication import ActionAuthentication
2524
from taskingai.client.models.action_authentication_type import ActionAuthenticationType
2625
from taskingai.client.models.action_create_request import ActionCreateRequest
2726
from taskingai.client.models.action_create_response import ActionCreateResponse
@@ -62,8 +61,7 @@
6261
from taskingai.client.models.chunk_query_request import ChunkQueryRequest
6362
from taskingai.client.models.chunk_query_response import ChunkQueryResponse
6463
from taskingai.client.models.collection import Collection
65-
from taskingai.client.models.collection_config_input import CollectionConfigInput
66-
from taskingai.client.models.collection_config_output import CollectionConfigOutput
64+
from taskingai.client.models.collection_config import CollectionConfig
6765
from taskingai.client.models.collection_create_request import CollectionCreateRequest
6866
from taskingai.client.models.collection_create_response import CollectionCreateResponse
6967
from taskingai.client.models.collection_get_response import CollectionGetResponse

taskingai/client/api/retrieval_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def create_record(self, body, collection_id, **kwargs): # noqa: E501
133133
Create a new record in a collection. # noqa: E501
134134
This method makes a synchronous HTTP request by default. To make an
135135
asynchronous HTTP request, please pass async_req=True
136-
>>> thread = api.create_record(body, collection_id, async_req=True)
136+
>>> thread = api.create_text_record(body, collection_id, async_req=True)
137137
>>> result = thread.get()
138138
139139
:param async_req bool

taskingai/client/models/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
# import models into model package
1313
from taskingai.client.models.action import Action
14-
from taskingai.client.models.action_authentication_input import ActionAuthenticationInput
15-
from taskingai.client.models.action_authentication_output import ActionAuthenticationOutput
14+
from taskingai.client.models.action_authentication import ActionAuthentication
1615
from taskingai.client.models.action_authentication_type import ActionAuthenticationType
1716
from taskingai.client.models.action_create_request import ActionCreateRequest
1817
from taskingai.client.models.action_create_response import ActionCreateResponse
@@ -53,8 +52,7 @@
5352
from taskingai.client.models.chunk_query_request import ChunkQueryRequest
5453
from taskingai.client.models.chunk_query_response import ChunkQueryResponse
5554
from taskingai.client.models.collection import Collection
56-
from taskingai.client.models.collection_config_input import CollectionConfigInput
57-
from taskingai.client.models.collection_config_output import CollectionConfigOutput
55+
from taskingai.client.models.collection_config import CollectionConfig
5856
from taskingai.client.models.collection_create_request import CollectionCreateRequest
5957
from taskingai.client.models.collection_create_response import CollectionCreateResponse
6058
from taskingai.client.models.collection_get_response import CollectionGetResponse

taskingai/client/models/action_authentication_input.py renamed to taskingai/client/models/action_authentication.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import six
1313

14-
class ActionAuthenticationInput(object):
14+
class ActionAuthentication(object):
1515
"""NOTE: This class is auto generated by the swagger code generator program.
1616
1717
Do not edit the class manually.
@@ -36,7 +36,7 @@ class ActionAuthenticationInput(object):
3636
}
3737

3838
def __init__(self, type=None, secret=None, content=None): # noqa: E501
39-
"""ActionAuthenticationInput - a model defined in Swagger""" # noqa: E501
39+
"""ActionAuthentication - a model defined in Swagger""" # noqa: E501
4040
self._type = None
4141
self._secret = None
4242
self._content = None
@@ -49,20 +49,20 @@ def __init__(self, type=None, secret=None, content=None): # noqa: E501
4949

5050
@property
5151
def type(self):
52-
"""Gets the type of this ActionAuthenticationInput. # noqa: E501
52+
"""Gets the type of this ActionAuthentication. # noqa: E501
5353
5454
55-
:return: The type of this ActionAuthenticationInput. # noqa: E501
55+
:return: The type of this ActionAuthentication. # noqa: E501
5656
:rtype: ActionAuthenticationType
5757
"""
5858
return self._type
5959

6060
@type.setter
6161
def type(self, type):
62-
"""Sets the type of this ActionAuthenticationInput.
62+
"""Sets the type of this ActionAuthentication.
6363
6464
65-
:param type: The type of this ActionAuthenticationInput. # noqa: E501
65+
:param type: The type of this ActionAuthentication. # noqa: E501
6666
:type: ActionAuthenticationType
6767
"""
6868
if type is None:
@@ -72,41 +72,41 @@ def type(self, type):
7272

7373
@property
7474
def secret(self):
75-
"""Gets the secret of this ActionAuthenticationInput. # noqa: E501
75+
"""Gets the secret of this ActionAuthentication. # noqa: E501
7676
7777
78-
:return: The secret of this ActionAuthenticationInput. # noqa: E501
78+
:return: The secret of this ActionAuthentication. # noqa: E501
7979
:rtype: object
8080
"""
8181
return self._secret
8282

8383
@secret.setter
8484
def secret(self, secret):
85-
"""Sets the secret of this ActionAuthenticationInput.
85+
"""Sets the secret of this ActionAuthentication.
8686
8787
88-
:param secret: The secret of this ActionAuthenticationInput. # noqa: E501
88+
:param secret: The secret of this ActionAuthentication. # noqa: E501
8989
:type: object
9090
"""
9191

9292
self._secret = secret
9393

9494
@property
9595
def content(self):
96-
"""Gets the content of this ActionAuthenticationInput. # noqa: E501
96+
"""Gets the content of this ActionAuthentication. # noqa: E501
9797
9898
99-
:return: The content of this ActionAuthenticationInput. # noqa: E501
99+
:return: The content of this ActionAuthentication. # noqa: E501
100100
:rtype: object
101101
"""
102102
return self._content
103103

104104
@content.setter
105105
def content(self, content):
106-
"""Sets the content of this ActionAuthenticationInput.
106+
"""Sets the content of this ActionAuthentication.
107107
108108
109-
:param content: The content of this ActionAuthenticationInput. # noqa: E501
109+
:param content: The content of this ActionAuthentication. # noqa: E501
110110
:type: object
111111
"""
112112

@@ -133,7 +133,7 @@ def to_dict(self):
133133
))
134134
else:
135135
result[attr] = value
136-
if issubclass(ActionAuthenticationInput, dict):
136+
if issubclass(ActionAuthentication, dict):
137137
for key, value in self.items():
138138
result[key] = value
139139

@@ -149,7 +149,7 @@ def __repr__(self):
149149

150150
def __eq__(self, other):
151151
"""Returns true if both objects are equal"""
152-
if not isinstance(other, ActionAuthenticationInput):
152+
if not isinstance(other, ActionAuthentication):
153153
return False
154154

155155
return self.__dict__ == other.__dict__

0 commit comments

Comments
 (0)