weco 0.1.9__py3-none-any.whl → 0.1.10__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.
- weco/client.py +19 -13
- weco/functional.py +13 -2
- {weco-0.1.9.dist-info → weco-0.1.10.dist-info}/METADATA +1 -1
- weco-0.1.10.dist-info/RECORD +10 -0
- {weco-0.1.9.dist-info → weco-0.1.10.dist-info}/WHEEL +1 -1
- weco-0.1.9.dist-info/RECORD +0 -10
- {weco-0.1.9.dist-info → weco-0.1.10.dist-info}/LICENSE +0 -0
- {weco-0.1.9.dist-info → weco-0.1.10.dist-info}/top_level.txt +0 -0
weco/client.py
CHANGED
|
@@ -247,18 +247,12 @@ class WecoAI:
|
|
|
247
247
|
"""
|
|
248
248
|
return self._build(task_description=task_description, multimodal=multimodal, is_async=False)
|
|
249
249
|
|
|
250
|
-
def _upload_image(self,
|
|
250
|
+
def _upload_image(self, image_info: Dict[str, Any]) -> str:
|
|
251
251
|
"""
|
|
252
252
|
Uploads an image to an S3 bucket and returns the URL of the uploaded image.
|
|
253
253
|
|
|
254
254
|
Parameters
|
|
255
255
|
----------
|
|
256
|
-
fn_name : str
|
|
257
|
-
The name of the function for which the image is being uploaded.
|
|
258
|
-
version_number : int
|
|
259
|
-
The version number of the function for which the image is being uploaded.
|
|
260
|
-
upload_id: str
|
|
261
|
-
A unique identifier for the image upload.
|
|
262
256
|
image_info : Dict[str, Any]
|
|
263
257
|
A dictionary containing the image metadata.
|
|
264
258
|
|
|
@@ -291,7 +285,7 @@ class WecoAI:
|
|
|
291
285
|
|
|
292
286
|
# Request a presigned URL from the server
|
|
293
287
|
endpoint = "upload_link"
|
|
294
|
-
request_data = {"
|
|
288
|
+
request_data = {"file_type": file_type}
|
|
295
289
|
# This needs to be a synchronous request since we need the presigned URL to upload the image
|
|
296
290
|
response = self._make_request(endpoint=endpoint, data=request_data, is_async=False)
|
|
297
291
|
|
|
@@ -394,7 +388,8 @@ class WecoAI:
|
|
|
394
388
|
self,
|
|
395
389
|
is_async: bool,
|
|
396
390
|
fn_name: str,
|
|
397
|
-
|
|
391
|
+
version: Union[str, int],
|
|
392
|
+
version_number: int,
|
|
398
393
|
text_input: Optional[str],
|
|
399
394
|
images_input: Optional[List[str]],
|
|
400
395
|
return_reasoning: Optional[bool],
|
|
@@ -407,6 +402,8 @@ class WecoAI:
|
|
|
407
402
|
Whether to perform an asynchronous request.
|
|
408
403
|
fn_name : str
|
|
409
404
|
The name of the function to query.
|
|
405
|
+
version : Union[str, int]
|
|
406
|
+
The version alias or number of the function to query.
|
|
410
407
|
version_number : int, optional
|
|
411
408
|
The version number of the function to query.
|
|
412
409
|
text_input : str, optional
|
|
@@ -431,10 +428,9 @@ class WecoAI:
|
|
|
431
428
|
|
|
432
429
|
# Create links for all images that are not public URLs and upload images
|
|
433
430
|
image_urls = []
|
|
434
|
-
upload_id = generate_random_base16_code()
|
|
435
431
|
for i, info in enumerate(image_info):
|
|
436
432
|
if info["source"] == "url" or info["source"] == "base64" or info["source"] == "local":
|
|
437
|
-
url = self._upload_image(
|
|
433
|
+
url = self._upload_image(image_info=info)
|
|
438
434
|
else:
|
|
439
435
|
raise ValueError(f"Image at index {i} must be a public URL or a path to a local image file.")
|
|
440
436
|
image_urls.append(url)
|
|
@@ -443,9 +439,10 @@ class WecoAI:
|
|
|
443
439
|
endpoint = "query"
|
|
444
440
|
data = {
|
|
445
441
|
"name": fn_name,
|
|
442
|
+
"version": version,
|
|
443
|
+
"version_number": version_number,
|
|
446
444
|
"text": text_input,
|
|
447
445
|
"images": image_urls,
|
|
448
|
-
"version_number": version_number,
|
|
449
446
|
"return_reasoning": return_reasoning,
|
|
450
447
|
}
|
|
451
448
|
request = self._make_request(endpoint=endpoint, data=data, is_async=is_async)
|
|
@@ -464,6 +461,7 @@ class WecoAI:
|
|
|
464
461
|
async def aquery(
|
|
465
462
|
self,
|
|
466
463
|
fn_name: str,
|
|
464
|
+
version: Optional[Union[str, int]] = -1,
|
|
467
465
|
version_number: Optional[int] = -1,
|
|
468
466
|
text_input: Optional[str] = "",
|
|
469
467
|
images_input: Optional[List[str]] = [],
|
|
@@ -475,6 +473,8 @@ class WecoAI:
|
|
|
475
473
|
----------
|
|
476
474
|
fn_name : str
|
|
477
475
|
The name of the function to query.
|
|
476
|
+
version : Union[str, int], optional
|
|
477
|
+
The version alias or number of the function to query. If not provided, the latest version will be used. Pass -1 to use the latest version.
|
|
478
478
|
version_number : int, optional
|
|
479
479
|
The version number of the function to query. If not provided, the latest version will be used. Pass -1 to use the latest version.
|
|
480
480
|
text_input : str, optional
|
|
@@ -492,6 +492,7 @@ class WecoAI:
|
|
|
492
492
|
"""
|
|
493
493
|
return await self._query(
|
|
494
494
|
fn_name=fn_name,
|
|
495
|
+
version=version,
|
|
495
496
|
version_number=version_number,
|
|
496
497
|
text_input=text_input,
|
|
497
498
|
images_input=images_input,
|
|
@@ -502,6 +503,7 @@ class WecoAI:
|
|
|
502
503
|
def query(
|
|
503
504
|
self,
|
|
504
505
|
fn_name: str,
|
|
506
|
+
version: Optional[Union[str, int]] = -1,
|
|
505
507
|
version_number: Optional[int] = -1,
|
|
506
508
|
text_input: Optional[str] = "",
|
|
507
509
|
images_input: Optional[List[str]] = [],
|
|
@@ -530,6 +532,7 @@ class WecoAI:
|
|
|
530
532
|
"""
|
|
531
533
|
return self._query(
|
|
532
534
|
fn_name=fn_name,
|
|
535
|
+
version=version,
|
|
533
536
|
version_number=version_number,
|
|
534
537
|
text_input=text_input,
|
|
535
538
|
images_input=images_input,
|
|
@@ -541,6 +544,7 @@ class WecoAI:
|
|
|
541
544
|
self,
|
|
542
545
|
fn_name: str,
|
|
543
546
|
batch_inputs: List[Dict[str, Any]],
|
|
547
|
+
version: Optional[Union[str, int]] = -1,
|
|
544
548
|
version_number: Optional[int] = -1,
|
|
545
549
|
return_reasoning: Optional[bool] = False,
|
|
546
550
|
) -> List[Dict[str, Any]]:
|
|
@@ -554,6 +558,8 @@ class WecoAI:
|
|
|
554
558
|
A list of inputs for the functions to query. The input must be a dictionary containing the data to be processed. e.g.,
|
|
555
559
|
when providing for a text input, the dictionary should be {"text_input": "input text"}, for an image input, the dictionary should be {"images_input": ["url1", "url2", ...]}
|
|
556
560
|
and for a combination of text and image inputs, the dictionary should be {"text_input": "input text", "images_input": ["url1", "url2", ...]}.
|
|
561
|
+
version : Union[str, int], optional
|
|
562
|
+
The version alias or number of the function to query. If not provided, the latest version will be used. Pass -1 to use the latest version.
|
|
557
563
|
version_number : int, optional
|
|
558
564
|
The version number of the function to query. If not provided, the latest version will be used. Pass -1 to use the latest version.
|
|
559
565
|
return_reasoning : bool, optional
|
|
@@ -570,7 +576,7 @@ class WecoAI:
|
|
|
570
576
|
tasks = list(
|
|
571
577
|
map(
|
|
572
578
|
lambda fn_input: self.aquery(
|
|
573
|
-
fn_name=fn_name, version_number=version_number, return_reasoning=return_reasoning, **fn_input
|
|
579
|
+
fn_name=fn_name, version=version, version_number=version_number, return_reasoning=return_reasoning, **fn_input
|
|
574
580
|
),
|
|
575
581
|
batch_inputs,
|
|
576
582
|
)
|
weco/functional.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, Dict, List, Optional
|
|
1
|
+
from typing import Any, Dict, List, Optional, Union
|
|
2
2
|
|
|
3
3
|
from .client import WecoAI
|
|
4
4
|
|
|
@@ -49,6 +49,7 @@ async def abuild(task_description: str, multimodal: bool = False, api_key: str =
|
|
|
49
49
|
|
|
50
50
|
def query(
|
|
51
51
|
fn_name: str,
|
|
52
|
+
version: Optional[Union[str, int]] = -1,
|
|
52
53
|
version_number: Optional[int] = -1,
|
|
53
54
|
text_input: Optional[str] = "",
|
|
54
55
|
images_input: Optional[List[str]] = [],
|
|
@@ -61,6 +62,8 @@ def query(
|
|
|
61
62
|
----------
|
|
62
63
|
fn_name : str
|
|
63
64
|
The name of the function to query.
|
|
65
|
+
version : str | int, optional
|
|
66
|
+
The version alias or number of the function to query. If not provided, the latest version is used. Default is -1 for the same behavior.
|
|
64
67
|
version_number : int, optional
|
|
65
68
|
The version number of the function to query. If not provided, the latest version is used. Default is -1 for the same behavior.
|
|
66
69
|
text_input : str, optional
|
|
@@ -81,6 +84,7 @@ def query(
|
|
|
81
84
|
client = WecoAI(api_key=api_key)
|
|
82
85
|
response = client.query(
|
|
83
86
|
fn_name=fn_name,
|
|
87
|
+
version=version,
|
|
84
88
|
version_number=version_number,
|
|
85
89
|
text_input=text_input,
|
|
86
90
|
images_input=images_input,
|
|
@@ -91,6 +95,7 @@ def query(
|
|
|
91
95
|
|
|
92
96
|
async def aquery(
|
|
93
97
|
fn_name: str,
|
|
98
|
+
version: Optional[Union[str, int]] = -1,
|
|
94
99
|
version_number: Optional[int] = -1,
|
|
95
100
|
text_input: Optional[str] = "",
|
|
96
101
|
images_input: Optional[List[str]] = [],
|
|
@@ -103,6 +108,8 @@ async def aquery(
|
|
|
103
108
|
----------
|
|
104
109
|
fn_name : str
|
|
105
110
|
The name of the function to query.
|
|
111
|
+
version: str | int, optional
|
|
112
|
+
The version number or alias of the function to query. If not provided, the latest version is used. Default is -1 for the same behavior.
|
|
106
113
|
version_number : int, optional
|
|
107
114
|
The version number of the function to query. If not provided, the latest version is used. Default is -1 for the same behavior.
|
|
108
115
|
text_input : str, optional
|
|
@@ -123,6 +130,7 @@ async def aquery(
|
|
|
123
130
|
client = WecoAI(api_key=api_key)
|
|
124
131
|
response = await client.aquery(
|
|
125
132
|
fn_name=fn_name,
|
|
133
|
+
version=version,
|
|
126
134
|
version_number=version_number,
|
|
127
135
|
text_input=text_input,
|
|
128
136
|
images_input=images_input,
|
|
@@ -134,6 +142,7 @@ async def aquery(
|
|
|
134
142
|
def batch_query(
|
|
135
143
|
fn_name: str,
|
|
136
144
|
batch_inputs: List[Dict[str, Any]],
|
|
145
|
+
version: Optional[Union[str, int]] = -1,
|
|
137
146
|
version_number: Optional[int] = -1,
|
|
138
147
|
return_reasoning: Optional[bool] = False,
|
|
139
148
|
api_key: Optional[str] = None,
|
|
@@ -153,6 +162,8 @@ def batch_query(
|
|
|
153
162
|
A list of inputs for the functions to query. The input must be a dictionary containing the data to be processed. e.g.,
|
|
154
163
|
when providing for a text input, the dictionary should be {"text_input": "input text"}, for an image input, the dictionary should be {"images_input": ["url1", "url2", ...]}
|
|
155
164
|
and for a combination of text and image inputs, the dictionary should be {"text_input": "input text", "images_input": ["url1", "url2", ...]}.
|
|
165
|
+
version : str | int, optional
|
|
166
|
+
The version number or alias of the function to query. If not provided, the latest version is used. Default is -1 for the same behavior.
|
|
156
167
|
version_number : int, optional
|
|
157
168
|
The version number of the function to query. If not provided, the latest version is used. Default is -1 for the same behavior.
|
|
158
169
|
return_reasoning : bool, optional
|
|
@@ -168,6 +179,6 @@ def batch_query(
|
|
|
168
179
|
"""
|
|
169
180
|
client = WecoAI(api_key=api_key)
|
|
170
181
|
responses = client.batch_query(
|
|
171
|
-
fn_name=fn_name, version_number=version_number, batch_inputs=batch_inputs, return_reasoning=return_reasoning
|
|
182
|
+
fn_name=fn_name, version=version, version_number=version_number, batch_inputs=batch_inputs, return_reasoning=return_reasoning
|
|
172
183
|
)
|
|
173
184
|
return responses
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
weco/__init__.py,sha256=qiKpnrm6t0n0bpAtXEKJO1Yz2xYXnJJRZBWt-cH7DdU,168
|
|
2
|
+
weco/client.py,sha256=iJanKlSKlcg3x6V7rA0Bw7Px2nGy87766rePvGn-KzI,23013
|
|
3
|
+
weco/constants.py,sha256=eoAq-9qN2aZrqyIWdrb3V1zomV5kp80PfxxoPoQNMNI,167
|
|
4
|
+
weco/functional.py,sha256=CgQsBKppRmT1lAloEdTEbE1gOeCciK-H6RTUR6DDrrc,7706
|
|
5
|
+
weco/utils.py,sha256=UUSw6ocqWdlSmIXVcH66DAL4NuLU2rFOyviD8aTWsv0,4371
|
|
6
|
+
weco-0.1.10.dist-info/LICENSE,sha256=NvpxfBuSajszAczWBGKxhHe4gsvil1H63zmu8xXZdL0,1064
|
|
7
|
+
weco-0.1.10.dist-info/METADATA,sha256=-6joUA_QvFIHrrXSe0LqbXbypW1PTW4d8keLneJ9fu0,5717
|
|
8
|
+
weco-0.1.10.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
|
9
|
+
weco-0.1.10.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
|
|
10
|
+
weco-0.1.10.dist-info/RECORD,,
|
weco-0.1.9.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
weco/__init__.py,sha256=qiKpnrm6t0n0bpAtXEKJO1Yz2xYXnJJRZBWt-cH7DdU,168
|
|
2
|
-
weco/client.py,sha256=mW0FRv6_ZEl1h12HfQ9Gfag84Nlzs6RFrXRNcW5vMBo,22782
|
|
3
|
-
weco/constants.py,sha256=eoAq-9qN2aZrqyIWdrb3V1zomV5kp80PfxxoPoQNMNI,167
|
|
4
|
-
weco/functional.py,sha256=v_YsR2jomckwDKRt-ZZtqC8-JmHJZ12tB6fJyCa6sYk,6964
|
|
5
|
-
weco/utils.py,sha256=UUSw6ocqWdlSmIXVcH66DAL4NuLU2rFOyviD8aTWsv0,4371
|
|
6
|
-
weco-0.1.9.dist-info/LICENSE,sha256=NvpxfBuSajszAczWBGKxhHe4gsvil1H63zmu8xXZdL0,1064
|
|
7
|
-
weco-0.1.9.dist-info/METADATA,sha256=70IQjezjRB-dTf3jg0Owr892snZOHL_RY0rpwpXcvxo,5716
|
|
8
|
-
weco-0.1.9.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
|
|
9
|
-
weco-0.1.9.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
|
|
10
|
-
weco-0.1.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|