Skip to content

Commit a8bb056

Browse files
jameszyaoSimsonW
authored andcommitted
feat: update api schema
1 parent 3c4caac commit a8bb056

36 files changed

+1449
-1430
lines changed

‎./workflows/release-publish.yml

+50-51
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,72 @@ name: publish-and-release
33
on:
44
create:
55
tags:
6-
- 'v*'
6+
- "v*"
77
push:
8-
branches: [ "master", "dev" ]
8+
branches: ["master", "dev"]
99

1010
jobs:
1111
publish-to-pypi:
1212
runs-on: ubuntu-latest
1313
steps:
14+
- uses: actions/checkout@master
1415

15-
- uses: actions/checkout@master
16+
- name: Set up Python 3.10
17+
uses: actions/setup-python@v1
18+
with:
19+
python-version: "3.10.13"
1620

17-
- name: Set up Python 3.10
18-
uses: actions/setup-python@v1
19-
with:
20-
python-version: '3.10.13'
21+
- name: Install build
22+
run: >-
23+
pip install -r requirements.txt &&
24+
python setup.py sdist
2125
22-
- name: Install build
23-
run: >-
24-
pip install -r requirements.txt &&
25-
python setup.py sdist
26+
- name: Publish distribution 📦 to Test PyPI
27+
if: startsWith(.ref, 'refs/dev')
28+
uses: pypa/gh-action-pypi-publish@master
29+
with:
30+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
31+
repository_url: https://test.pypi.org/legacy/
32+
skip_existing: true
2633

27-
- name: Publish distribution 📦 to Test PyPI
28-
if: startsWith(.ref, 'refs/dev')
29-
uses: pypa/gh-action-pypi-publish@master
30-
with:
31-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
32-
repository_url: https://test.pypi.org/legacy/
33-
skip_existing: true
34-
35-
- name: Publish distribution 📦 to PyPI
36-
if: startsWith(.ref, 'refs/tags/')
37-
uses: pypa/gh-action-pypi-publish@master
38-
with:
39-
password: ${{ secrets.PYPI_API_TOKEN }}
34+
- name: Publish distribution 📦 to PyPI
35+
if: startsWith(.ref, 'refs/tags/')
36+
uses: pypa/gh-action-pypi-publish@master
37+
with:
38+
password: ${{ secrets.PYPI_API_TOKEN }}
4039

4140
-release:
4241
name: -release
4342
needs:
44-
- publish-to-pypi
43+
- publish-to-pypi
4544
runs-on: ubuntu-latest
4645
permissions:
4746
contents: write
4847
id-token: write
4948
steps:
50-
- name: Download all the dists
51-
uses: actions/download-artifact@v3
52-
with:
53-
name: python-package-distributions
54-
path: dist/
55-
- name: Sign the dists with Sigstore
56-
uses: sigstore/[email protected]
57-
with:
58-
inputs: >-
59-
./dist/*.tar.gz
60-
./dist/*.whl
61-
- name: Create Release
62-
env:
63-
_TOKEN: ${{ .token }}
64-
run: >-
65-
gh release create
66-
'${{ .ref_name }}'
67-
--repo '${{ .repository }}'
68-
--notes ""
69-
- name: Upload artifact signatures to Release
70-
env:
71-
_TOKEN: ${{ .token }}
72-
run: >-
73-
gh release upload
74-
'${{ .ref_name }}' dist/**
75-
--repo '${{ .repository }}'
49+
- name: Download all the dists
50+
uses: actions/download-artifact@v3
51+
with:
52+
name: python-package-distributions
53+
path: dist/
54+
- name: Sign the dists with Sigstore
55+
uses: sigstore/[email protected]
56+
with:
57+
inputs: >-
58+
./dist/*.tar.gz
59+
./dist/*.whl
60+
- name: Create Release
61+
env:
62+
_TOKEN: ${{ .token }}
63+
run: >-
64+
gh release create
65+
'${{ .ref_name }}'
66+
--repo '${{ .repository }}'
67+
--notes ""
68+
- name: Upload artifact signatures to Release
69+
env:
70+
_TOKEN: ${{ .token }}
71+
run: >-
72+
gh release upload
73+
'${{ .ref_name }}' dist/**
74+
--repo '${{ .repository }}'

‎.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ target/
6767

6868
.DS_Store
6969
.venv
70+
71+
# test
72+
test/.pytest_cache/
73+
test/log/
74+
75+
**/allure-report

‎.pre-commit-config.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: https://.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
9+
- repo: https://.com/psf/black
10+
rev: 23.12.1
11+
hooks:
12+
- id: black
13+
args: ["-l", "120"]
14+
language_version: python3
15+
16+
- repo: https://.com/myint/autoflake
17+
rev: v2.2.1
18+
hooks:
19+
- id: autoflake
20+
args: ["--in-place", "--remove-all-unused-imports"]
21+
exclude: "__init__.py$"
22+
23+
- repo: https://.com/pre-commit/mirrors-prettier
24+
rev: "v4.0.0-alpha.8" # Use the ref you want to point at
25+
hooks:
26+
- id: prettier
27+
args: ["--write"]

‎MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
prune test

‎README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# TaskingAI-client
2+
23
The TaskingAI Python client for creating and managing AI-driven applications.
34

45
For more information, see the docs at [TaskingAI Documentation](https://docs.tasking.ai/)
56

67
## Installation
78

89
Install the latest released version using pip:
10+
911
```shell
1012
pip3 install taskingai
1113
```
@@ -15,19 +17,21 @@ pip3 install taskingai
1517
Here's how you can quickly start building and managing AI-driven applications using the TaskingAI client.
1618

1719
### Assistants
20+
1821
Explore the ease of creating and customizing your own AI assistants with TaskingAI to enhance user interactions.
22+
1923
```python
2024
import taskingai
2125
from taskingai.assistant import *
26+
from taskingai.assistant.memory import AssistantNaiveMemory
2227

2328
# Initialize your API key if you haven't already set it in the environment
2429
taskingai.init(api_key="YOUR_API_KEY")
2530

2631
# Create an assistant
2732
assistant = create_assistant(
2833
model_id="YOUR_MODEL_ID",
29-
name="My Assistant",
30-
description="An assistant that understands numbers.",
34+
memory=AssistantNaiveMemory(),
3135
system_prompt_template=["You are a professional assistant."],
3236
)
3337
print(f"Assistant created: {assistant.id}")
@@ -49,7 +53,9 @@ print("Assistant deleted successfully.")
4953
```
5054

5155
### Retrieval
56+
5257
Leverage TaskingAI's retrieval capabilities to store, manage, and extract information, making your applications smarter and more responsive.
58+
5359
```python
5460
import taskingai
5561
from taskingai.retrieval import *
@@ -62,9 +68,10 @@ collection = create_collection(
6268
print(f"Collection created: {collection.id}")
6369

6470
# Add a record to the collection
65-
record = create_text_record(
71+
record = create_record(
6672
collection_id=collection.id,
67-
text="Example text for machine learning."
73+
content="Example text for machine learning.",
74+
text_splitter=TokenTextSplitter(chunk_size=200, chunk_overlap=20),
6875
)
6976
print(f"Record added to collection: {record.id}")
7077

@@ -88,7 +95,9 @@ print("Collection deleted.")
8895
```
8996

9097
### Tools
98+
9199
Utilize TaskingAI's tools to create actions that enable your assistant to interact with external APIs and services, enriching the user experience.
100+
92101
```python
93102
import taskingai
94103
from taskingai.tool import *
@@ -121,8 +130,3 @@ print("Action deleted.")
121130
## Contributing
122131

123132
We welcome contributions of all kinds. Please read our [Contributing Guidelines](./CONTRIBUTING.md) for more information on how to get started.
124-
125-
## Security
126-
127-
For any security concerns or issues, please reach out to us directly at [email protected].
128-

‎examples/assistant/chat_with_assistant.ipynb

+5-12
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
" }\n",
9292
"}\n",
9393
"actions: List[Action] = taskingai.tool.bulk_create_actions(\n",
94-
" schema=NUMBERS_API_SCHEMA,\n",
94+
" openapi_schema=NUMBERS_API_SCHEMA,\n",
9595
" authentication=ActionAuthentication(\n",
9696
" type=ActionAuthenticationType.NONE,\n",
9797
" )\n",
@@ -250,14 +250,15 @@
250250
"messages = taskingai.assistant.list_messages(\n",
251251
" assistant_id=assistant.assistant_id,\n",
252252
" chat_id=chat.chat_id,\n",
253+
" order=\"asc\"\n",
253254
")\n",
254255
"for message in messages:\n",
255256
" print(f\"{message.role}: {message.content.text}\")"
256257
],
257258
"metadata": {
258259
"collapsed": false
259260
},
260-
"id": "34bae46ba56752bb"
261+
"id": "e94e3adb0d15373b"
261262
},
262263
{
263264
"cell_type": "code",
@@ -278,19 +279,11 @@
278279
"cell_type": "code",
279280
"execution_count": null,
280281
"outputs": [],
281-
"source": [
282-
"# list messages\n",
283-
"messages = taskingai.assistant.list_messages(\n",
284-
" assistant_id=assistant.assistant_id,\n",
285-
" chat_id=chat.chat_id,\n",
286-
")\n",
287-
"for message in messages:\n",
288-
" print(f\"{message.role}: {message.content.text}\")"
289-
],
282+
"source": [],
290283
"metadata": {
291284
"collapsed": false
292285
},
293-
"id": "e94e3adb0d15373b"
286+
"id": "9cfed1128acbdd30"
294287
}
295288
],
296289
"metadata": {

‎examples/crud/retrieval_crud.ipynb

+18-16
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"outputs": [],
1111
"source": [
1212
"import taskingai\n",
13-
"import time\n",
1413
"# Load TaskingAI API Key from environment variable"
1514
]
1615
},
@@ -29,7 +28,7 @@
2928
"execution_count": null,
3029
"outputs": [],
3130
"source": [
32-
"from taskingai.retrieval import Collection, Record\n",
31+
"from taskingai.retrieval import Collection, Record, TokenTextSplitter\n",
3332
"\n",
3433
"# choose an available text_embedding model from your project\n",
3534
"embedding_model_id = \"YOUR_MODEL_ID\""
@@ -49,6 +48,19 @@
4948
},
5049
"id": "a6874f1ff8ec5a9c"
5150
},
51+
{
52+
"cell_type": "code",
53+
"execution_count": null,
54+
"outputs": [],
55+
"source": [
56+
"collections = taskingai.retrieval.list_collections()\n",
57+
"print(collections)"
58+
],
59+
"metadata": {
60+
"collapsed": false
61+
},
62+
"id": "81ec82280d5c8c64"
63+
},
5264
{
5365
"cell_type": "code",
5466
"execution_count": null,
@@ -146,25 +158,14 @@
146158
},
147159
"id": "1b7688a3cf40c241"
148160
},
149-
{
150-
"cell_type": "markdown",
151-
"source": [],
152-
"metadata": {
153-
"collapsed": false
154-
},
155-
"id": "dbc3aafe16758b4c"
156-
},
157161
{
158162
"cell_type": "code",
159163
"execution_count": null,
160164
"outputs": [],
161165
"source": [
162166
"# create a new collection\n",
163167
"collection: Collection = create_collection()\n",
164-
"print(collection)\n",
165-
"\n",
166-
"# wait for the collection creation to finish\n",
167-
"time.sleep(3)"
168+
"print(collection)"
168169
],
169170
"metadata": {
170171
"collapsed": false
@@ -177,9 +178,10 @@
177178
"outputs": [],
178179
"source": [
179180
"# create a new text record\n",
180-
"record: Record = taskingai.retrieval.create_text_record(\n",
181+
"record: Record = taskingai.retrieval.create_record(\n",
181182
" collection_id=collection.collection_id,\n",
182-
" text=\"Machine learning is a subfield of artificial intelligence (AI) that involves the development of algorithms that allow computers to learn from and make decisions or predictions based on data. The term \\\"machine learning\\\" was coined by Arthur Samuel in 1959. In other words, machine learning enables a system to automatically learn and improve from experience without being explicitly programmed. This is achieved by feeding the system massive amounts of data, which it uses to learn patterns and make inferences. There are three main types of machine learning: 1. Supervised Learning: This is where the model is given labeled training data and the goal of learning is to generalize from the training data to unseen situations in a principled way. 2. Unsupervised Learning: This involves training on a dataset without explicit labels. The goal might be to discover inherent groupings or patterns within the data. 3. Reinforcement Learning: In this type, an agent learns to perform actions based on reward/penalty feedback to achieve a goal. It's commonly used in robotics, gaming, and navigation. Deep learning, a subset of machine learning, uses neural networks with many layers (\\\"deep\\\" structures) and has been responsible for many recent breakthroughs in AI, including speech recognition, image recognition, and natural language processing. It's important to note that machine learning is a rapidly developing field, with new techniques and applications emerging regularly.\"\n",
183+
" content=\"Machine learning is a subfield of artificial intelligence (AI) that involves the development of algorithms that allow computers to learn from and make decisions or predictions based on data. The term \\\"machine learning\\\" was coined by Arthur Samuel in 1959. In other words, machine learning enables a system to automatically learn and improve from experience without being explicitly programmed. This is achieved by feeding the system massive amounts of data, which it uses to learn patterns and make inferences. There are three main types of machine learning: 1. Supervised Learning: This is where the model is given labeled training data and the goal of learning is to generalize from the training data to unseen situations in a principled way. 2. Unsupervised Learning: This involves training on a dataset without explicit labels. The goal might be to discover inherent groupings or patterns within the data. 3. Reinforcement Learning: In this type, an agent learns to perform actions based on reward/penalty feedback to achieve a goal. It's commonly used in robotics, gaming, and navigation. Deep learning, a subset of machine learning, uses neural networks with many layers (\\\"deep\\\" structures) and has been responsible for many recent breakthroughs in AI, including speech recognition, image recognition, and natural language processing. It's important to note that machine learning is a rapidly developing field, with new techniques and applications emerging regularly.\",\n",
184+
" text_splitter=TokenTextSplitter(chunk_size=200, chunk_overlap=20)\n",
183185
")\n",
184186
"print(f\"created record: {record.record_id} for collection: {collection.collection_id}\\n\")"
185187
],

0 commit comments

Comments
 (0)