weco 0.1.10__py3-none-any.whl → 0.2.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.
- weco/__init__.py +4 -4
- weco/api.py +89 -0
- weco/cli.py +333 -0
- weco/panels.py +359 -0
- weco/utils.py +114 -175
- weco-0.2.0.dist-info/METADATA +129 -0
- weco-0.2.0.dist-info/RECORD +11 -0
- {weco-0.1.10.dist-info → weco-0.2.0.dist-info}/WHEEL +1 -1
- weco-0.2.0.dist-info/entry_points.txt +2 -0
- {weco-0.1.10.dist-info → weco-0.2.0.dist-info/licenses}/LICENSE +2 -1
- weco/client.py +0 -586
- weco/constants.py +0 -4
- weco/functional.py +0 -184
- weco-0.1.10.dist-info/METADATA +0 -125
- weco-0.1.10.dist-info/RECORD +0 -10
- {weco-0.1.10.dist-info → weco-0.2.0.dist-info}/top_level.txt +0 -0
weco/functional.py
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
from typing import Any, Dict, List, Optional, Union
|
|
2
|
-
|
|
3
|
-
from .client import WecoAI
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def build(task_description: str, multimodal: bool = False, api_key: str = None) -> tuple[str, int, str]:
|
|
7
|
-
"""Builds a specialized function synchronously given a task description.
|
|
8
|
-
|
|
9
|
-
Parameters
|
|
10
|
-
----------
|
|
11
|
-
task_description : str
|
|
12
|
-
A description of the task for which the function is being built.
|
|
13
|
-
multimodal : bool, optional
|
|
14
|
-
A flag to indicate if the function should be multimodal. Default is False.
|
|
15
|
-
api_key : str
|
|
16
|
-
The API key for the WecoAI service. If not provided, the API key must be set using the environment variable - WECO_API_KEY.
|
|
17
|
-
|
|
18
|
-
Returns
|
|
19
|
-
-------
|
|
20
|
-
tuple[str, str]
|
|
21
|
-
A tuple containing the name and description of the function.
|
|
22
|
-
"""
|
|
23
|
-
client = WecoAI(api_key=api_key)
|
|
24
|
-
response = client.build(task_description=task_description, multimodal=multimodal)
|
|
25
|
-
return response
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
async def abuild(task_description: str, multimodal: bool = False, api_key: str = None) -> tuple[str, int, str]:
|
|
29
|
-
"""Builds a specialized function asynchronously given a task description.
|
|
30
|
-
|
|
31
|
-
Parameters
|
|
32
|
-
----------
|
|
33
|
-
task_description : str
|
|
34
|
-
A description of the task for which the function is being built.
|
|
35
|
-
multimodal : bool, optional
|
|
36
|
-
A flag to indicate if the function should be multimodal. Default is False.
|
|
37
|
-
api_key : str
|
|
38
|
-
The API key for the WecoAI service. If not provided, the API key must be set using the environment variable - WECO_API_KEY.
|
|
39
|
-
|
|
40
|
-
Returns
|
|
41
|
-
-------
|
|
42
|
-
tuple[str, str]
|
|
43
|
-
A tuple containing the name, version number and description of the function.
|
|
44
|
-
"""
|
|
45
|
-
client = WecoAI(api_key=api_key)
|
|
46
|
-
response = await client.abuild(task_description=task_description, multimodal=multimodal)
|
|
47
|
-
return response
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def query(
|
|
51
|
-
fn_name: str,
|
|
52
|
-
version: Optional[Union[str, int]] = -1,
|
|
53
|
-
version_number: Optional[int] = -1,
|
|
54
|
-
text_input: Optional[str] = "",
|
|
55
|
-
images_input: Optional[List[str]] = [],
|
|
56
|
-
return_reasoning: Optional[bool] = False,
|
|
57
|
-
api_key: Optional[str] = None,
|
|
58
|
-
) -> Dict[str, Any]:
|
|
59
|
-
"""Queries a function synchronously with the given function ID and input.
|
|
60
|
-
|
|
61
|
-
Parameters
|
|
62
|
-
----------
|
|
63
|
-
fn_name : str
|
|
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.
|
|
67
|
-
version_number : int, optional
|
|
68
|
-
The version number of the function to query. If not provided, the latest version is used. Default is -1 for the same behavior.
|
|
69
|
-
text_input : str, optional
|
|
70
|
-
The text input to the function.
|
|
71
|
-
images_input : List[str], optional
|
|
72
|
-
A list of image URLs or base64 encoded images to be used as input to the function.
|
|
73
|
-
return_reasoning : bool, optional
|
|
74
|
-
A flag to indicate if the reasoning should be returned. Default is False.
|
|
75
|
-
api_key : str
|
|
76
|
-
The API key for the WecoAI service. If not provided, the API key must be set using the environment variable - WECO_API_KEY.
|
|
77
|
-
|
|
78
|
-
Returns
|
|
79
|
-
-------
|
|
80
|
-
dict
|
|
81
|
-
A dictionary containing the output of the function, the number of input tokens, the number of output tokens,
|
|
82
|
-
and the latency in milliseconds.
|
|
83
|
-
"""
|
|
84
|
-
client = WecoAI(api_key=api_key)
|
|
85
|
-
response = client.query(
|
|
86
|
-
fn_name=fn_name,
|
|
87
|
-
version=version,
|
|
88
|
-
version_number=version_number,
|
|
89
|
-
text_input=text_input,
|
|
90
|
-
images_input=images_input,
|
|
91
|
-
return_reasoning=return_reasoning,
|
|
92
|
-
)
|
|
93
|
-
return response
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
async def aquery(
|
|
97
|
-
fn_name: str,
|
|
98
|
-
version: Optional[Union[str, int]] = -1,
|
|
99
|
-
version_number: Optional[int] = -1,
|
|
100
|
-
text_input: Optional[str] = "",
|
|
101
|
-
images_input: Optional[List[str]] = [],
|
|
102
|
-
return_reasoning: Optional[bool] = False,
|
|
103
|
-
api_key: Optional[str] = None,
|
|
104
|
-
) -> Dict[str, Any]:
|
|
105
|
-
"""Queries a function asynchronously with the given function ID and input.
|
|
106
|
-
|
|
107
|
-
Parameters
|
|
108
|
-
----------
|
|
109
|
-
fn_name : str
|
|
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.
|
|
113
|
-
version_number : int, optional
|
|
114
|
-
The version number of the function to query. If not provided, the latest version is used. Default is -1 for the same behavior.
|
|
115
|
-
text_input : str, optional
|
|
116
|
-
The text input to the function.
|
|
117
|
-
images_input : List[str], optional
|
|
118
|
-
A list of image URLs to be used as input to the function.
|
|
119
|
-
return_reasoning : bool, optional
|
|
120
|
-
A flag to indicate if the reasoning should be returned. Default is False.
|
|
121
|
-
api_key : str
|
|
122
|
-
The API key for the WecoAI service. If not provided, the API key must be set using the environment variable - WECO_API_KEY.
|
|
123
|
-
|
|
124
|
-
Returns
|
|
125
|
-
-------
|
|
126
|
-
dict
|
|
127
|
-
A dictionary containing the output of the function, the number of input tokens, the number of output tokens,
|
|
128
|
-
and the latency in milliseconds.
|
|
129
|
-
"""
|
|
130
|
-
client = WecoAI(api_key=api_key)
|
|
131
|
-
response = await client.aquery(
|
|
132
|
-
fn_name=fn_name,
|
|
133
|
-
version=version,
|
|
134
|
-
version_number=version_number,
|
|
135
|
-
text_input=text_input,
|
|
136
|
-
images_input=images_input,
|
|
137
|
-
return_reasoning=return_reasoning,
|
|
138
|
-
)
|
|
139
|
-
return response
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def batch_query(
|
|
143
|
-
fn_name: str,
|
|
144
|
-
batch_inputs: List[Dict[str, Any]],
|
|
145
|
-
version: Optional[Union[str, int]] = -1,
|
|
146
|
-
version_number: Optional[int] = -1,
|
|
147
|
-
return_reasoning: Optional[bool] = False,
|
|
148
|
-
api_key: Optional[str] = None,
|
|
149
|
-
) -> List[Dict[str, Any]]:
|
|
150
|
-
"""Synchronously queries multiple functions using asynchronous calls internally.
|
|
151
|
-
|
|
152
|
-
This method uses the asynchronous queries to submit all queries concurrently
|
|
153
|
-
and waits for all responses to be received before returning the results.
|
|
154
|
-
|
|
155
|
-
Parameters
|
|
156
|
-
----------
|
|
157
|
-
fn_name : str | List[str]
|
|
158
|
-
The name of the function or a list of function names to query.
|
|
159
|
-
Note that if a single function name is provided, it will be used for all queries.
|
|
160
|
-
If a list of function names is provided, the length must match the number of queries.
|
|
161
|
-
batch_inputs : List[str]
|
|
162
|
-
A list of inputs for the functions to query. The input must be a dictionary containing the data to be processed. e.g.,
|
|
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", ...]}
|
|
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.
|
|
167
|
-
version_number : int, optional
|
|
168
|
-
The version number of the function to query. If not provided, the latest version is used. Default is -1 for the same behavior.
|
|
169
|
-
return_reasoning : bool, optional
|
|
170
|
-
A flag to indicate if the reasoning should be returned. Default is False.
|
|
171
|
-
api_key : str, optional
|
|
172
|
-
The API key for the WecoAI service. If not provided, the API key must be set using the environment variable - WECO_API_KEY.
|
|
173
|
-
|
|
174
|
-
Returns
|
|
175
|
-
-------
|
|
176
|
-
List[Dict[str, Any]]
|
|
177
|
-
A list of dictionaries, each containing the output of a function query,
|
|
178
|
-
in the same order as the input queries.
|
|
179
|
-
"""
|
|
180
|
-
client = WecoAI(api_key=api_key)
|
|
181
|
-
responses = client.batch_query(
|
|
182
|
-
fn_name=fn_name, version=version, version_number=version_number, batch_inputs=batch_inputs, return_reasoning=return_reasoning
|
|
183
|
-
)
|
|
184
|
-
return responses
|
weco-0.1.10.dist-info/METADATA
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: weco
|
|
3
|
-
Version: 0.1.10
|
|
4
|
-
Summary: A client facing API for interacting with the WeCo AI function builder service.
|
|
5
|
-
Author-email: WeCo AI Team <dhruv@weco.ai>
|
|
6
|
-
License: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/WecoAI/weco-python
|
|
8
|
-
Keywords: AI,LLM,machine learning,data science,function builder,AI function
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
-
Requires-Python: >=3.8
|
|
13
|
-
Description-Content-Type: text/markdown
|
|
14
|
-
License-File: LICENSE
|
|
15
|
-
Requires-Dist: asyncio
|
|
16
|
-
Requires-Dist: httpx[http2]
|
|
17
|
-
Requires-Dist: pillow
|
|
18
|
-
Provides-Extra: dev
|
|
19
|
-
Requires-Dist: flake8 ; extra == 'dev'
|
|
20
|
-
Requires-Dist: flake8-pyproject ; extra == 'dev'
|
|
21
|
-
Requires-Dist: black ; extra == 'dev'
|
|
22
|
-
Requires-Dist: isort ; extra == 'dev'
|
|
23
|
-
Requires-Dist: pytest-asyncio ; extra == 'dev'
|
|
24
|
-
Requires-Dist: pytest-xdist ; extra == 'dev'
|
|
25
|
-
Requires-Dist: build ; extra == 'dev'
|
|
26
|
-
Requires-Dist: setuptools-scm ; extra == 'dev'
|
|
27
|
-
|
|
28
|
-
<div align="center" style="display: flex; align-items: center; justify-content: center;">
|
|
29
|
-
<img src="assets/weco.svg" alt="WeCo AI" style="height: 50px; margin-right: 10px;">
|
|
30
|
-
<a href="https://git.io/typing-svg"><img src="https://readme-typing-svg.demolab.com?font=Georgia&size=32&duration=4000&pause=400&color=FD4578&vCenter=true&multiline=false&width=200&height=50&lines=WeCo+Client" alt="Typing SVG" /></a>
|
|
31
|
-
</div>
|
|
32
|
-
|
|
33
|
-

|
|
34
|
-
[](https://opensource.org/licenses/MIT)
|
|
35
|
-
|
|
36
|
-
<!-- TODO: Update examples -->
|
|
37
|
-
# $f$(👷♂️)
|
|
38
|
-
|
|
39
|
-
<a href="https://colab.research.google.com/github/WecoAI/weco-python/blob/main/examples/cookbook.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab" width=110 height=20/></a>
|
|
40
|
-
<a target="_blank" href="https://lightning.ai/new?repo_url=https%3A%2F%2Fgithub.com%2FWecoAI%2Fweco-python%2Fblob%2Fmain%2Fexamples%2Fcookbook.ipynb"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open in Studio" width=100 height=20/></a>
|
|
41
|
-
|
|
42
|
-
A client facing API for interacting with the [WeCo AI](https://www.weco.ai/) function builder [service](https://weco-app.vercel.app/function)!
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Use this API to build *complex* systems *fast*. We lower the barrier of entry to software engineer, data science and machine learning by providing an interface to prototype difficult solutions quickly in just a few lines of code.
|
|
46
|
-
|
|
47
|
-
## Installation
|
|
48
|
-
|
|
49
|
-
Install the `weco` package simply by calling this in your terminal of choice:
|
|
50
|
-
```bash
|
|
51
|
-
pip install weco
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Features
|
|
55
|
-
- Synchronous & Asynchronous client.
|
|
56
|
-
- Batch API
|
|
57
|
-
- Multimodality (Language & Vision)
|
|
58
|
-
- Interpretability (view the reasoning behind outputs)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
## What We Offer
|
|
62
|
-
|
|
63
|
-
- The **build** function enables quick and easy prototyping of new functions via LLMs through just natural language. We encourage users to do this through our [web console](https://weco-app.vercel.app/function) for maximum control and ease of use, however, you can also do this through our API as shown in [here](examples/cookbook.ipynb).
|
|
64
|
-
- The **query** function allows you to test and use the newly created function in your own code.
|
|
65
|
-
|
|
66
|
-
We provide both services in two ways:
|
|
67
|
-
- `weco.WecoAI` client to be used when you want to maintain the same client service across a portion of code. This is better for dense service usage.
|
|
68
|
-
- `weco.query` and `weco.build` to be used when you only require sparse usage.
|
|
69
|
-
|
|
70
|
-
## Usage
|
|
71
|
-
|
|
72
|
-
When using the WeCo API, you will need to set the API key:
|
|
73
|
-
You can find/setup your API key [here](https://weco-app.vercel.app/account) by navigating to the API key tab. Once you have your API key, you may pass it to the `weco` client using the `api_key` argument input or set it as an environment variable such as:
|
|
74
|
-
```bash
|
|
75
|
-
export WECO_API_KEY=<YOUR_WECO_API_KEY>
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Example
|
|
79
|
-
|
|
80
|
-
We create a function on the [web console](https://weco-app.vercel.app/function) for the following task:
|
|
81
|
-
> "Analyze a business idea and provide a structured evaluation. Output a JSON with 'viability_score' (0-100), 'strengths' (list), 'weaknesses' (list), and 'next_steps' (list)."
|
|
82
|
-
|
|
83
|
-
Now, you're ready to query this function anywhere in your code!
|
|
84
|
-
|
|
85
|
-
```python
|
|
86
|
-
from weco import query
|
|
87
|
-
response = query(
|
|
88
|
-
fn_name="BusinessIdeaAnalyzer-XYZ123", # Replace with your actual function name
|
|
89
|
-
text_input="A subscription service for personalized, AI-generated bedtime stories for children."
|
|
90
|
-
)
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
For more examples and an advanced user guide, check out our function builder [cookbook](examples/cookbook.ipynb).
|
|
94
|
-
|
|
95
|
-
## Happy building $f$(👷♂️)!
|
|
96
|
-
|
|
97
|
-
## Contributing
|
|
98
|
-
|
|
99
|
-
We value your contributions! If you believe you can help to improve our package enabling people to build AI with AI, please contribute!
|
|
100
|
-
|
|
101
|
-
Use the following steps as a guideline to help you make contributions:
|
|
102
|
-
|
|
103
|
-
1. Download and install package from source:
|
|
104
|
-
```bash
|
|
105
|
-
git clone https://github.com/WecoAI/weco-python.git
|
|
106
|
-
cd weco-python
|
|
107
|
-
pip install -e ".[dev]"
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
2. Create a new branch for your feature or bugfix:
|
|
111
|
-
```bash
|
|
112
|
-
git checkout -b feature/your-feature-name
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
3. Make your changes and run tests to ensure everything is working:
|
|
116
|
-
|
|
117
|
-
> **Tests can be expensive to run as they make LLM requests with the API key being used so it is the developers best interests to write small and simple tests that adds coverage for a large portion of the package.**
|
|
118
|
-
|
|
119
|
-
```bash
|
|
120
|
-
pytest -n auto tests
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
4. Commit and push your changes, then open a PR for us to view 😁
|
|
124
|
-
|
|
125
|
-
Please ensure your code follows our style guidelines (Numpy docstrings) and includes appropriate tests. We appreciate your contributions!
|
weco-0.1.10.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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,,
|
|
File without changes
|