Skip to content

Dev: update client schema #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 0 additions & 75 deletions .github/workflows/release-publish.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ target/

.DS_Store
.venv

# test
test/.pytest_cache/
test/log/

**/allure-report
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml

- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
args: ["-l", "120"]
language_version: python3

- repo: https://github.com/myint/autoflake
rev: v2.2.1
hooks:
- id: autoflake
args: ["--in-place", "--remove-all-unused-imports"]
exclude: "__init__.py$"

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8" # Use the ref you want to point at
hooks:
- id: prettier
args: ["--write"]
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prune test
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# TaskingAI-client

The TaskingAI Python client for creating and managing AI-driven applications.

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

## Installation

Install the latest released version using pip:

```shell
pip3 install taskingai
```
Expand All @@ -15,19 +17,21 @@ pip3 install taskingai
Here's how you can quickly start building and managing AI-driven applications using the TaskingAI client.

### Assistants

Explore the ease of creating and customizing your own AI assistants with TaskingAI to enhance user interactions.

```python
import taskingai
from taskingai.assistant import *
from taskingai.assistant.memory import AssistantNaiveMemory

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

# Create an assistant
assistant = create_assistant(
model_id="YOUR_MODEL_ID",
name="My Assistant",
description="An assistant that understands numbers.",
memory=AssistantNaiveMemory(),
system_prompt_template=["You are a professional assistant."],
)
print(f"Assistant created: {assistant.id}")
Expand All @@ -49,7 +53,9 @@ print("Assistant deleted successfully.")
```

### Retrieval

Leverage TaskingAI's retrieval capabilities to store, manage, and extract information, making your applications smarter and more responsive.

```python
import taskingai
from taskingai.retrieval import *
Expand All @@ -62,9 +68,10 @@ collection = create_collection(
print(f"Collection created: {collection.id}")

# Add a record to the collection
record = create_text_record(
record = create_record(
collection_id=collection.id,
text="Example text for machine learning."
content="Example text for machine learning.",
text_splitter=TokenTextSplitter(chunk_size=200, chunk_overlap=20),
)
print(f"Record added to collection: {record.id}")

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

### Tools

Utilize TaskingAI's tools to create actions that enable your assistant to interact with external APIs and services, enriching the user experience.

```python
import taskingai
from taskingai.tool import *
Expand Down Expand Up @@ -121,8 +130,3 @@ print("Action deleted.")
## Contributing

We welcome contributions of all kinds. Please read our [Contributing Guidelines](./CONTRIBUTING.md) for more information on how to get started.

## Security

For any security concerns or issues, please reach out to us directly at [email protected].

17 changes: 5 additions & 12 deletions examples/assistant/chat_with_assistant.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
" }\n",
"}\n",
"actions: List[Action] = taskingai.tool.bulk_create_actions(\n",
" schema=NUMBERS_API_SCHEMA,\n",
" openapi_schema=NUMBERS_API_SCHEMA,\n",
" authentication=ActionAuthentication(\n",
" type=ActionAuthenticationType.NONE,\n",
" )\n",
Expand Down Expand Up @@ -250,14 +250,15 @@
"messages = taskingai.assistant.list_messages(\n",
" assistant_id=assistant.assistant_id,\n",
" chat_id=chat.chat_id,\n",
" order=\"asc\"\n",
")\n",
"for message in messages:\n",
" print(f\"{message.role}: {message.content.text}\")"
],
"metadata": {
"collapsed": false
},
"id": "34bae46ba56752bb"
"id": "e94e3adb0d15373b"
},
{
"cell_type": "code",
Expand All @@ -278,19 +279,11 @@
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"# list messages\n",
"messages = taskingai.assistant.list_messages(\n",
" assistant_id=assistant.assistant_id,\n",
" chat_id=chat.chat_id,\n",
")\n",
"for message in messages:\n",
" print(f\"{message.role}: {message.content.text}\")"
],
"source": [],
"metadata": {
"collapsed": false
},
"id": "e94e3adb0d15373b"
"id": "9cfed1128acbdd30"
}
],
"metadata": {
Expand Down
34 changes: 18 additions & 16 deletions examples/crud/retrieval_crud.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"outputs": [],
"source": [
"import taskingai\n",
"import time\n",
"# Load TaskingAI API Key from environment variable"
]
},
Expand All @@ -29,7 +28,7 @@
"execution_count": null,
"outputs": [],
"source": [
"from taskingai.retrieval import Collection, Record\n",
"from taskingai.retrieval import Collection, Record, TokenTextSplitter\n",
"\n",
"# choose an available text_embedding model from your project\n",
"embedding_model_id = \"YOUR_MODEL_ID\""
Expand All @@ -49,6 +48,19 @@
},
"id": "a6874f1ff8ec5a9c"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"collections = taskingai.retrieval.list_collections()\n",
"print(collections)"
],
"metadata": {
"collapsed": false
},
"id": "81ec82280d5c8c64"
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -146,25 +158,14 @@
},
"id": "1b7688a3cf40c241"
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"collapsed": false
},
"id": "dbc3aafe16758b4c"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"# create a new collection\n",
"collection: Collection = create_collection()\n",
"print(collection)\n",
"\n",
"# wait for the collection creation to finish\n",
"time.sleep(3)"
"print(collection)"
],
"metadata": {
"collapsed": false
Expand All @@ -177,9 +178,10 @@
"outputs": [],
"source": [
"# create a new text record\n",
"record: Record = taskingai.retrieval.create_text_record(\n",
"record: Record = taskingai.retrieval.create_record(\n",
" collection_id=collection.collection_id,\n",
" 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",
" 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",
" text_splitter=TokenTextSplitter(chunk_size=200, chunk_overlap=20)\n",
")\n",
"print(f\"created record: {record.record_id} for collection: {collection.collection_id}\\n\")"
],
Expand Down
12 changes: 2 additions & 10 deletions examples/crud/tool_crud.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
" }\n",
"}\n",
"actions: List[Action] = taskingai.tool.bulk_create_actions(\n",
" schema=NUMBERS_API_SCHEMA,\n",
" openapi_schema=NUMBERS_API_SCHEMA,\n",
" authentication=ActionAuthentication(\n",
" type=ActionAuthenticationType.NONE,\n",
" )\n",
Expand Down Expand Up @@ -139,7 +139,7 @@
"NUMBERS_API_SCHEMA[\"paths\"][\"/{number}\"][\"get\"][\"summary\"] = \"Get fun fact about a number)\"\n",
"action: Action = taskingai.tool.update_action(\n",
" action_id=action_id,\n",
" schema=NUMBERS_API_SCHEMA\n",
" openapi_schema=NUMBERS_API_SCHEMA\n",
")\n",
"\n",
"print(f\"updated action: {action}\\n\")"
Expand Down Expand Up @@ -197,14 +197,6 @@
"collapsed": false
},
"id": "5a1a36d15055918f"
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"collapsed": false
},
"id": "b1736bf2e80c2dd6"
}
],
"metadata": {
Expand Down
Loading