weco 0.1.3__tar.gz → 0.1.5__tar.gz

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.
@@ -1,9 +1,9 @@
1
- name: Publish Python 🐍 distribution 📦 to PyPI
1
+ name: Publish Python Package
2
2
 
3
3
  on:
4
4
  push:
5
5
  branches:
6
- - main
6
+ - 'main'
7
7
 
8
8
  release:
9
9
  types: [published]
@@ -32,7 +32,7 @@ jobs:
32
32
 
33
33
  publish-to-pypi:
34
34
  name: >-
35
- Publish Python 🐍 distribution 📦 to PyPI
35
+ Publish Python 🐍 distribution PyPI
36
36
  needs:
37
37
  - build
38
38
  runs-on: ubuntu-latest
@@ -43,17 +43,17 @@ jobs:
43
43
  id-token: write
44
44
 
45
45
  steps:
46
- - name: Download all the dists
46
+ - name: Download the dists
47
47
  uses: actions/download-artifact@v3
48
48
  with:
49
49
  name: python-package-distributions
50
50
  path: dist/
51
- - name: Publish distribution 📦 to PyPI
51
+ - name: Publish to PyPI
52
52
  uses: pypa/gh-action-pypi-publish@release/v1
53
53
 
54
54
  github-release:
55
55
  name: >-
56
- Sign Python 🐍 distribution 📦 and create GitHub Release
56
+ Create GitHub Release
57
57
  needs:
58
58
  - publish-to-pypi
59
59
  runs-on: ubuntu-latest
@@ -63,12 +63,12 @@ jobs:
63
63
  id-token: write
64
64
 
65
65
  steps:
66
- - name: Download all the dists
66
+ - name: Download dists
67
67
  uses: actions/download-artifact@v3
68
68
  with:
69
69
  name: python-package-distributions
70
70
  path: dist/
71
- - name: Sign the dists with Sigstore
71
+ - name: Sign dists with Sigstore
72
72
  uses: sigstore/gh-action-sigstore-python@v2.1.1
73
73
  with:
74
74
  inputs: >-
@@ -78,9 +78,8 @@ jobs:
78
78
  env:
79
79
  GITHUB_TOKEN: ${{ github.token }}
80
80
  run: >-
81
- LATEST_TAG=$(git describe --tags --abbrev=0)
82
81
  gh release create
83
- "$LATEST_TAG"
82
+ '${{ github.event.release.tag_name }}'
84
83
  --repo '${{ github.repository }}'
85
84
  --notes ""
86
85
  - name: Upload artifact signatures to GitHub Release
@@ -91,5 +90,5 @@ jobs:
91
90
  # sigstore-produced signatures and certificates.
92
91
  run: >-
93
92
  gh release upload
94
- "$LATEST_TAG" dist/**
93
+ '${{ github.event.release.tag_name }}' dist/**
95
94
  --repo '${{ github.repository }}'
@@ -165,4 +165,7 @@ cython_debug/
165
165
  .DS_Store
166
166
 
167
167
  # Case Studies
168
- case_studies/
168
+ case_studies/
169
+
170
+ # Testing files
171
+ test.py
@@ -1,11 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: weco
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: A client facing API for interacting with the WeCo AI function builder service.
5
5
  Author-email: WeCo AI Team <dhruv@weco.ai>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/WecoAI/weco-python
8
- Keywords: AI,LLM,machine learning,data science,function builder
8
+ Keywords: AI,LLM,machine learning,data science,function builder,AI function
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Operating System :: OS Independent
11
11
  Classifier: License :: OSI Approved :: MIT License
@@ -14,21 +14,31 @@ Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
15
  Requires-Dist: asyncio
16
16
  Requires-Dist: httpx[http2]
17
+ Requires-Dist: pillow
17
18
  Provides-Extra: dev
18
- Requires-Dist: build; extra == "dev"
19
- Requires-Dist: setuptools_scm; extra == "dev"
20
19
  Requires-Dist: flake8; extra == "dev"
21
20
  Requires-Dist: flake8-pyproject; extra == "dev"
22
21
  Requires-Dist: black; extra == "dev"
23
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"
24
27
 
25
28
  <div align="center" style="display: flex; align-items: center; justify-content: center;">
26
29
  <img src="assets/weco.svg" alt="WeCo AI" style="height: 50px; margin-right: 10px;">
27
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>
28
31
  </div>
29
32
 
33
+ ![Python](https://img.shields.io/badge/Python-3.10.14-blue)
34
+ [![License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
35
+
36
+ <!-- TODO: Update examples -->
30
37
  # $f$(👷‍♂️)
31
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
+
32
42
  A client facing API for interacting with the [WeCo AI](https://www.weco.ai/) function builder [service](https://weco-app.vercel.app/function)!
33
43
 
34
44
 
@@ -47,6 +57,7 @@ pip install weco
47
57
  - The **query** function allows you to test and use the newly created function in your own code.
48
58
  - We offer asynchronous versions of the above clients.
49
59
  - We provide a **batch_query** functions that allows users to batch functions for various inputs as well as multiple inputs for the same function in a query. This is helpful to make a large number of queries more efficiently.
60
+ - We also offer multimodality capabilities. You can now query our client with both **language** AND **vision** inputs!
50
61
 
51
62
  We provide both services in two ways:
52
63
  - `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.
@@ -63,18 +74,48 @@ export WECO_API_KEY=<YOUR_WECO_API_KEY>
63
74
  ## Example
64
75
 
65
76
  We create a function on the [web console](https://weco-app.vercel.app/function) for the following task:
66
- > "I want to evaluate the feasibility of a machine learning task. Give me a json object with three keys - 'feasibility', 'justification', and 'suggestions'."
77
+ > "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)."
67
78
 
68
79
  Now, you're ready to query this function anywhere in your code!
69
80
 
70
81
  ```python
71
82
  from weco import query
72
83
  response = query(
73
- fn_name=fn_name,
74
- fn_input="I want to train a model to predict house prices using the Boston Housing dataset hosted on Kaggle.",
84
+ fn_name="BusinessIdeaAnalyzer-XYZ123", # Replace with your actual function name
85
+ text_input="A subscription service for personalized, AI-generated bedtime stories for children."
75
86
  )
76
87
  ```
77
88
 
78
89
  For more examples and an advanced user guide, check out our function builder [cookbook](examples/cookbook.ipynb).
79
90
 
80
91
  ## Happy building $f$(👷‍♂️)!
92
+
93
+ ## Contributing
94
+
95
+ We value your contributions! If you believe you can help to improve our package enabling people to build AI with AI, please contribute!
96
+
97
+ Use the following steps as a guideline to help you make contributions:
98
+
99
+ 1. Download and install package from source:
100
+ ```bash
101
+ git clone https://github.com/WecoAI/weco-python.git
102
+ cd weco-python
103
+ pip install -e ".[dev]"
104
+ ```
105
+
106
+ 2. Create a new branch for your feature or bugfix:
107
+ ```bash
108
+ git checkout -b feature/your-feature-name
109
+ ```
110
+
111
+ 3. Make your changes and run tests to ensure everything is working:
112
+
113
+ > **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.**
114
+
115
+ ```bash
116
+ pytest -n auto tests
117
+ ```
118
+
119
+ 4. Commit and push your changes, then open a PR for us to view 😁
120
+
121
+ Please ensure your code follows our style guidelines (Numpy docstrings) and includes appropriate tests. We appreciate your contributions!
@@ -3,8 +3,15 @@
3
3
  <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>
4
4
  </div>
5
5
 
6
+ ![Python](https://img.shields.io/badge/Python-3.10.14-blue)
7
+ [![License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ <!-- TODO: Update examples -->
6
10
  # $f$(👷‍♂️)
7
11
 
12
+ <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>
13
+ <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>
14
+
8
15
  A client facing API for interacting with the [WeCo AI](https://www.weco.ai/) function builder [service](https://weco-app.vercel.app/function)!
9
16
 
10
17
 
@@ -23,6 +30,7 @@ pip install weco
23
30
  - The **query** function allows you to test and use the newly created function in your own code.
24
31
  - We offer asynchronous versions of the above clients.
25
32
  - We provide a **batch_query** functions that allows users to batch functions for various inputs as well as multiple inputs for the same function in a query. This is helpful to make a large number of queries more efficiently.
33
+ - We also offer multimodality capabilities. You can now query our client with both **language** AND **vision** inputs!
26
34
 
27
35
  We provide both services in two ways:
28
36
  - `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.
@@ -39,18 +47,48 @@ export WECO_API_KEY=<YOUR_WECO_API_KEY>
39
47
  ## Example
40
48
 
41
49
  We create a function on the [web console](https://weco-app.vercel.app/function) for the following task:
42
- > "I want to evaluate the feasibility of a machine learning task. Give me a json object with three keys - 'feasibility', 'justification', and 'suggestions'."
50
+ > "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)."
43
51
 
44
52
  Now, you're ready to query this function anywhere in your code!
45
53
 
46
54
  ```python
47
55
  from weco import query
48
56
  response = query(
49
- fn_name=fn_name,
50
- fn_input="I want to train a model to predict house prices using the Boston Housing dataset hosted on Kaggle.",
57
+ fn_name="BusinessIdeaAnalyzer-XYZ123", # Replace with your actual function name
58
+ text_input="A subscription service for personalized, AI-generated bedtime stories for children."
51
59
  )
52
60
  ```
53
61
 
54
62
  For more examples and an advanced user guide, check out our function builder [cookbook](examples/cookbook.ipynb).
55
63
 
56
- ## Happy building $f$(👷‍♂️)!
64
+ ## Happy building $f$(👷‍♂️)!
65
+
66
+ ## Contributing
67
+
68
+ We value your contributions! If you believe you can help to improve our package enabling people to build AI with AI, please contribute!
69
+
70
+ Use the following steps as a guideline to help you make contributions:
71
+
72
+ 1. Download and install package from source:
73
+ ```bash
74
+ git clone https://github.com/WecoAI/weco-python.git
75
+ cd weco-python
76
+ pip install -e ".[dev]"
77
+ ```
78
+
79
+ 2. Create a new branch for your feature or bugfix:
80
+ ```bash
81
+ git checkout -b feature/your-feature-name
82
+ ```
83
+
84
+ 3. Make your changes and run tests to ensure everything is working:
85
+
86
+ > **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.**
87
+
88
+ ```bash
89
+ pytest -n auto tests
90
+ ```
91
+
92
+ 4. Commit and push your changes, then open a PR for us to view 😁
93
+
94
+ Please ensure your code follows our style guidelines (Numpy docstrings) and includes appropriate tests. We appreciate your contributions!
@@ -0,0 +1,358 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "<div align=\"center\" style=\"display: flex; align-items: center; justify-content: left;\">\n",
8
+ " <img src=\"../assets/weco.svg\" alt=\"WeCo AI\" style=\"height: 50px; margin-right: 10px;\">\n",
9
+ " <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=750&height=100&lines=AI+Function+Builder;\" alt=\"Typing SVG\" /></a>\n",
10
+ "</div>"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "markdown",
15
+ "metadata": {},
16
+ "source": [
17
+ "## Getting Started"
18
+ ]
19
+ },
20
+ {
21
+ "cell_type": "markdown",
22
+ "metadata": {},
23
+ "source": [
24
+ "`weco` is a client facing API for interacting with the [WeCo AI](https://www.weco.ai/) function builder [service](https://weco-app.vercel.app/function). Use this API to build *complex* systems *fast* $f$(👷‍♂️)!\n",
25
+ "\n",
26
+ "Here's a short introduction to how you can use our client. Feel free to follow along:\n",
27
+ "\n",
28
+ "<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\"/></a>\n",
29
+ "<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>"
30
+ ]
31
+ },
32
+ {
33
+ "cell_type": "markdown",
34
+ "metadata": {},
35
+ "source": [
36
+ "Install the `weco` package in your terminal of choice:"
37
+ ]
38
+ },
39
+ {
40
+ "cell_type": "code",
41
+ "execution_count": null,
42
+ "metadata": {},
43
+ "outputs": [],
44
+ "source": [
45
+ "%pip install weco"
46
+ ]
47
+ },
48
+ {
49
+ "cell_type": "markdown",
50
+ "metadata": {},
51
+ "source": [
52
+ "Export your API key which can be found [here](https://weco-app.vercel.app/account)."
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "code",
57
+ "execution_count": null,
58
+ "metadata": {},
59
+ "outputs": [],
60
+ "source": [
61
+ "%env WECO_API_KEY=<YOUR_WECO_API_KEY>"
62
+ ]
63
+ },
64
+ {
65
+ "cell_type": "markdown",
66
+ "metadata": {},
67
+ "source": [
68
+ "You can build powerful AI functions for complex tasks quickly and without friction. For example, you can create a function in the [web console](https://weco-app.vercel.app/function) with this description:\n",
69
+ "\n",
70
+ "> \"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).\"\n",
71
+ "\n",
72
+ "Once created, you can query this function anywhere in your code with just a few lines:"
73
+ ]
74
+ },
75
+ {
76
+ "cell_type": "code",
77
+ "execution_count": null,
78
+ "metadata": {},
79
+ "outputs": [],
80
+ "source": [
81
+ "from weco import query\n",
82
+ "\n",
83
+ "response = query(\n",
84
+ " fn_name=\"BusinessIdeaAnalyzer-XYZ123\", # Replace with your actual function name\n",
85
+ " text_input=\"A subscription service for personalized, AI-generated bedtime stories for children.\"\n",
86
+ ")\n",
87
+ "\n",
88
+ "print(response)"
89
+ ]
90
+ },
91
+ {
92
+ "cell_type": "markdown",
93
+ "metadata": {},
94
+ "source": [
95
+ "## Multimodality"
96
+ ]
97
+ },
98
+ {
99
+ "cell_type": "markdown",
100
+ "metadata": {},
101
+ "source": [
102
+ "Our AI functions can interpret complex visual information, follow instructions in natural language and provide practical insights. Let's explore how we can all have a chef give us personalized advice! They can look at the food we have and offer recipe suggestions even providing nutritional information.\n",
103
+ "As shown in the example above, you can provde the image input in various ways such as:\n",
104
+ "1. Base64 encoding\n",
105
+ "3. Public URL\n",
106
+ "4. Local Path"
107
+ ]
108
+ },
109
+ {
110
+ "cell_type": "code",
111
+ "execution_count": null,
112
+ "metadata": {},
113
+ "outputs": [],
114
+ "source": [
115
+ "from weco import build, query\n",
116
+ "import base64\n",
117
+ "\n",
118
+ "task_description = \"\"\"\n",
119
+ "Create a Smart Home Energy Analyzer that can process images of smart meters, home exteriors, \n",
120
+ "and indoor spaces to provide energy efficiency insights. The analyzer should:\n",
121
+ " 1. Interpret smart meter readings\n",
122
+ " 2. Assess home features relevant to energy consumption\n",
123
+ " 3. Analyze thermostat settings\n",
124
+ " 4. Provide energy-saving recommendations\n",
125
+ " 5. Evaluate renewable energy potential\n",
126
+ "\n",
127
+ "The output should include:\n",
128
+ " - 'energy_consumption': current usage and comparison to average\n",
129
+ " - 'home_analysis': visible energy features and potential issues\n",
130
+ " - 'thermostat_settings': current settings and recommendations\n",
131
+ " - 'energy_saving_recommendations': actionable suggestions with estimated savings\n",
132
+ " - 'renewable_energy_potential': assessment of current and potential renewable energy use\n",
133
+ " - 'estimated_carbon_footprint': current footprint and potential reduction\n",
134
+ "\"\"\"\n",
135
+ "\n",
136
+ "fn_name, _ = build(task_description=task_description)\n",
137
+ "\n",
138
+ "request = \"\"\"\n",
139
+ "Analyze these images of my home and smart meter to provide energy efficiency insights \n",
140
+ "and recommendations for reducing my electricity consumption.\n",
141
+ "\"\"\"\n",
142
+ "\n",
143
+ "# Base64 encoded image\n",
144
+ "with open(\"/path/to/home_exterior.jpeg\", \"rb\") as img_file:\n",
145
+ " my_home_exterior = base64.b64encode(img_file.read()).decode('utf-8')\n",
146
+ "\n",
147
+ "response = query(\n",
148
+ " fn_name=fn_name,\n",
149
+ " text_input=request,\n",
150
+ " images_input=[\n",
151
+ " \"https://example.com/my_smart_meter_reading.png\", # Public URL\n",
152
+ " f\"data:image/jpeg;base64,{my_home_exterior}\", # Base64 encoding\n",
153
+ " \"/path/to/living_room_thermostat.jpg\" # Local image path\n",
154
+ " ]\n",
155
+ ")\n",
156
+ "\n",
157
+ "print(response)"
158
+ ]
159
+ },
160
+ {
161
+ "cell_type": "markdown",
162
+ "metadata": {},
163
+ "source": [
164
+ "## Running Example"
165
+ ]
166
+ },
167
+ {
168
+ "cell_type": "markdown",
169
+ "metadata": {},
170
+ "source": [
171
+ "Consider the previous example of:\n",
172
+ "> \"I want to evaluate the feasibility of a machine learning task. Help me understand this through - 'feasibility', 'justification', and 'suggestions'.\"\n",
173
+ "\n",
174
+ "Here's how you can take advantage of our API to best suit your needs."
175
+ ]
176
+ },
177
+ {
178
+ "cell_type": "code",
179
+ "execution_count": null,
180
+ "metadata": {},
181
+ "outputs": [],
182
+ "source": [
183
+ "task_description = \"I want to evaluate the feasibility of a machine learning task. Give me a json object with three keys - 'feasibility', 'justification', and 'suggestions'.\""
184
+ ]
185
+ },
186
+ {
187
+ "cell_type": "markdown",
188
+ "metadata": {},
189
+ "source": [
190
+ "## Dense vs. Sparse Usage"
191
+ ]
192
+ },
193
+ {
194
+ "cell_type": "markdown",
195
+ "metadata": {},
196
+ "source": [
197
+ "Though we recommend building functions in the [web console](https://weco-app.vercel.app/function) for maximum control over the function I/O, you can also do this programmatically:"
198
+ ]
199
+ },
200
+ {
201
+ "cell_type": "code",
202
+ "execution_count": null,
203
+ "metadata": {},
204
+ "outputs": [],
205
+ "source": [
206
+ "from weco import build, query\n",
207
+ "\n",
208
+ "# Describe the task you want the function to perform\n",
209
+ "fn_name, fn_desc = build(task_description=task_description)\n",
210
+ "print(f\"AI Function {fn_name} built. This does the following - \\n{fn_desc}.\")\n",
211
+ "\n",
212
+ "# Query the function with a specific input\n",
213
+ "query_response = query(\n",
214
+ " fn_name=fn_name,\n",
215
+ " text_input=\"I want to train a model to predict house prices using the Boston Housing dataset hosted on Kaggle.\"\n",
216
+ ")\n",
217
+ "for key, value in query_response.items(): print(f\"{key}: {value}\")"
218
+ ]
219
+ },
220
+ {
221
+ "cell_type": "markdown",
222
+ "metadata": {},
223
+ "source": [
224
+ "We recommend to use the `weco.build` and `weco.query` when you want to build or query LLM functions sparsely, i.e., you **don't** call `weco.build` or `weco.query` in many places within your code. However, for more dense usage, we've found users prefer our `weco.WecoAI` client instance. Its easy to switch between the two as shown below:"
225
+ ]
226
+ },
227
+ {
228
+ "cell_type": "code",
229
+ "execution_count": null,
230
+ "metadata": {},
231
+ "outputs": [],
232
+ "source": [
233
+ "from weco import WecoAI\n",
234
+ "\n",
235
+ "# Connect to our service, using our client\n",
236
+ "client = WecoAI()\n",
237
+ "\n",
238
+ "# Make the same query as before\n",
239
+ "query_response = client.query(\n",
240
+ " fn_name=fn_name,\n",
241
+ " text_input=\"I want to train a model to predict house prices using the Boston Housing dataset hosted on Kaggle.\"\n",
242
+ ")\n",
243
+ "for key, value in query_response.items(): print(f\"{key}: {value}\")"
244
+ ]
245
+ },
246
+ {
247
+ "cell_type": "markdown",
248
+ "metadata": {},
249
+ "source": [
250
+ "## Batching"
251
+ ]
252
+ },
253
+ {
254
+ "cell_type": "markdown",
255
+ "metadata": {},
256
+ "source": [
257
+ "We understand that sometimes, independent of how many times in your code you call `weco` functions, you want to submit a large batch of requests for the same or different LLM functions you've created. This can be done in the following ways:"
258
+ ]
259
+ },
260
+ {
261
+ "cell_type": "code",
262
+ "execution_count": null,
263
+ "metadata": {},
264
+ "outputs": [],
265
+ "source": [
266
+ "from weco import batch_query\n",
267
+ "\n",
268
+ "# Query the same function with multiple inputs by batching them for maximum efficiency\n",
269
+ "input_1 = {\"text_input\": \"I want to train a model to predict house prices using the Boston Housing dataset hosted on Kaggle.\"}\n",
270
+ "input_2 = {\n",
271
+ " \"text_input\": \"I want to train a model to classify digits using the MNIST dataset hosted on Kaggle using a Google Colab notebook. Attached is an example of what some of the digits would look like.\",\n",
272
+ " \"images_input\": [\"https://machinelearningmastery.com/wp-content/uploads/2019/02/Plot-of-a-Subset-of-Images-from-the-MNIST-Dataset-1024x768.png\"]\n",
273
+ "}\n",
274
+ "query_responses = batch_query(\n",
275
+ " fn_names=fn_name,\n",
276
+ " batch_inputs=[input_1, input_2]\n",
277
+ ")"
278
+ ]
279
+ },
280
+ {
281
+ "cell_type": "markdown",
282
+ "metadata": {},
283
+ "source": [
284
+ "You can do the same using the `weco.WecoAI` client. If you wanted to batch different functions, you can pass a list of function names to the `batch_query()` function. Note that the names of functions would need to be ordered the same as the function inputs provided.\n",
285
+ "\n",
286
+ "In addition, `weco.batch_query` takes the input batch as an array of individual inputs formatted in the following way -\n",
287
+ "```json\n",
288
+ "{\n",
289
+ " \"text_input\": \"Your text input\",\n",
290
+ " \"images_input\": [\"image1\", \"image2\"]\n",
291
+ "}\n",
292
+ "```"
293
+ ]
294
+ },
295
+ {
296
+ "cell_type": "markdown",
297
+ "metadata": {},
298
+ "source": [
299
+ "## Async Calls"
300
+ ]
301
+ },
302
+ {
303
+ "cell_type": "markdown",
304
+ "metadata": {},
305
+ "source": [
306
+ "Until now you've been making synchronous calls to our client by we also support asynchronous programmers. This is actually how we implement batching! You can also make asynchronous calls to our service using our `weco.WecoAI` client or as shown below for the same example as before:"
307
+ ]
308
+ },
309
+ {
310
+ "cell_type": "code",
311
+ "execution_count": null,
312
+ "metadata": {},
313
+ "outputs": [],
314
+ "source": [
315
+ "from weco import abuild, aquery\n",
316
+ "\n",
317
+ "# Describe the task you want the function to perform\n",
318
+ "fn_name, fn_desc = await abuild(task_description=task_description)\n",
319
+ "print(f\"AI Function {fn_name} built. This does the following - \\n{fn_desc}.\")\n",
320
+ "\n",
321
+ "# Query the function with a specific input\n",
322
+ "query_response = await aquery(\n",
323
+ " fn_name=fn_name,\n",
324
+ " text_input=\"I want to train a model to predict house prices using the Boston Housing dataset hosted on Kaggle.\"\n",
325
+ ")\n",
326
+ "for key, value in query_response.items(): print(f\"{key}: {value}\")"
327
+ ]
328
+ },
329
+ {
330
+ "cell_type": "markdown",
331
+ "metadata": {},
332
+ "source": [
333
+ "## Happy Building $f$(👷‍♂️)!"
334
+ ]
335
+ }
336
+ ],
337
+ "metadata": {
338
+ "kernelspec": {
339
+ "display_name": "weco",
340
+ "language": "python",
341
+ "name": "python3"
342
+ },
343
+ "language_info": {
344
+ "codemirror_mode": {
345
+ "name": "ipython",
346
+ "version": 3
347
+ },
348
+ "file_extension": ".py",
349
+ "mimetype": "text/x-python",
350
+ "name": "python",
351
+ "nbconvert_exporter": "python",
352
+ "pygments_lexer": "ipython3",
353
+ "version": "3.10.14"
354
+ }
355
+ },
356
+ "nbformat": 4,
357
+ "nbformat_minor": 2
358
+ }
@@ -10,20 +10,11 @@ authors = [
10
10
  ]
11
11
  description = "A client facing API for interacting with the WeCo AI function builder service."
12
12
  readme = "README.md"
13
- version = "0.1.3"
13
+ version = "0.1.5"
14
14
  license = {text = "MIT"}
15
15
  requires-python = ">=3.8"
16
- dependencies = [
17
- "asyncio",
18
- "httpx[http2]"
19
- ]
20
- keywords = [
21
- "AI",
22
- "LLM",
23
- "machine learning",
24
- "data science",
25
- "function builder"
26
- ]
16
+ dependencies = ["asyncio", "httpx[http2]", "pillow"]
17
+ keywords = ["AI", "LLM", "machine learning", "data science", "function builder", "AI function"]
27
18
  classifiers = [
28
19
  "Programming Language :: Python :: 3",
29
20
  "Operating System :: OS Independent",
@@ -34,7 +25,7 @@ classifiers = [
34
25
  Homepage = "https://github.com/WecoAI/weco-python"
35
26
 
36
27
  [project.optional-dependencies]
37
- dev = ["build", "setuptools_scm", "flake8", "flake8-pyproject", "black", "isort"]
28
+ dev = ["flake8", "flake8-pyproject", "black", "isort", "pytest-asyncio", "pytest-xdist", "build", "setuptools_scm"]
38
29
 
39
30
  [tool.setuptools]
40
31
  packages = ["weco"]