Skip to main content

TaskingAI

Project description

TaskingAI-client

The official TaskingAI Python client.

For more information, see the docs at TaskingAI Documentation

Prerequisites

The TaskingAI client is compatible with Python 3.8 and above.

Installation

Use pip to install the TaskingAI Python client.

# Install the latest version
pip install taskingai

# Install a specific version
pip install taskingai==0.2.2

Usage

Initialization

Before you can use the TaskingAI SDK, you must have your TaskingAI project set up and running. For community version, visit TaskingAI Community to get started. For cloud version, visit TaskingAI Cloud to sign up first.

You need to initialize the TaskingAI Python client with an API key you obtain from the TaskingAI console. You can set the API key as an environment variable or pass it directly to the init function.

Using environment variables (Recommended)

Set it as an environment variable on your local system, and the SDK will automatically load the key without passing the api_key parameter in the init function.

export TASKINGAI_API_KEY=$YOUR_API_KEY

When you run your Python script, the SDK will automatically pick up the API key from the environment variable.

import taskingai
# taskingai.init()
# No need to initialize the SDK with the API key

Passing the API key directly

You can also specify an API key to the SDK by passing it as a parameter to the init function:

import taskingai
taskingai.init(api_key="YOUR_API_KEY")

If you use community version, you can set the base URL to the TaskingAI server by passing it to the init function:

import taskingai
taskingai.init(api_key="YOUR_API_KEY", host="http://localhost:8080")

Assistants

The Assistant system in TaskingAI represents a sophisticated framework designed to create and manage AI agents with customizable functionalities.

Here is an example of how to create, update, and delete an assistant:

import taskingai

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

# Create an assistant
asst = taskingai.assistant.create_assistant(
    model_id="YOUR_MODEL_ID",
    memory={"type": "naive"},
    system_prompt_template=["You are a professional assistant."],
)
print(f"Assistant created: {asst.assistant_id}")

# Get details about the assistant
assistant_details = taskingai.assistant.get_assistant(assistant_id=asst.assistant_id)
print(f"Assistant details: {assistant_details}")

# Update the assistant's description
taskingai.assistant.update_assistant(
    assistant_id=asst.assistant_id,
    description="Updated description"
)
print(f"Assistant updated.")

# Delete the assistant when done
taskingai.assistant.delete_assistant(assistant_id=asst.assistant_id)
print("Assistant deleted successfully.")

Retrieval

TaskingAI offers comprehensive tools for the retrieval system, ranging from straightforward to intricate setups. Here is an example of how to create, add, retrieve, and delete a record in a collection:

import taskingai

# Create a collection for storing and retrieving data
coll = taskingai.retrieval.create_collection(
    embedding_model_id="YOUR_EMBEDDING_MODEL_ID",
    capacity=1000
)
print(f"Collection created: {coll.collection_id}")

# Add a record to the collection
record = taskingai.retrieval.create_record(
    collection_id=coll.collection_id,
    type="text",
    content="Machine learning is ...",
    text_splitter={"type": "token", "chunk_size": 200, "chunk_overlap": 20}
)
print(f"Record added to collection: {record.record_id}")

# Retrieve the record from the collection
retrieved_record = taskingai.retrieval.get_record(
    collection_id=coll.collection_id,
    record_id=record.record_id
)
print(f"Record retrieved: {retrieved_record.content}")

# Delete the record
taskingai.retrieval.delete_record(
    collection_id=coll.collection_id,
    record_id=record.record_id
)
print("Record deleted.")

# Delete the collection
taskingai.retrieval.delete_collection(collection_id=coll.collection_id)
print("Collection deleted.")

Tools

The Tools module in TaskingAI is an essential suite designed to augment the capabilities of TaskingAI agents. Here is an example of how to create, run, and delete a tool action:

import taskingai

# Define a schema for the tool action
OPENAPI_SCHEMA = {
    # Schema definition goes here
}

# Create a tool action based on the defined schema
actions = taskingai.tool.bulk_create_actions(
    openapi_schema=OPENAPI_SCHEMA,
    authentication={"type": "none"},
)
action = actions[0]
print(f"Action created: {action.action_id}")

# Run the action for a test purpose
result = taskingai.tool.run_action(
    action_id=action.action_id,
    parameters={"number": 42}
)
print(f"Action result: {result}")

# Delete the action when done
taskingai.tool.delete_action(action_id=action.action_id)
print("Action deleted.")

Contributing

We welcome contributions of all kinds. Please read our Contributing Guidelines for more information on how to get started.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

taskingai-0.2.3.tar.gz (45.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

taskingai-0.2.3-py3-none-any.whl (134.1 kB view details)

Uploaded Python 3

File details

Details for the file taskingai-0.2.3.tar.gz.

File metadata

  • Download URL: taskingai-0.2.3.tar.gz
  • Upload date:
  • Size: 45.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for taskingai-0.2.3.tar.gz
Algorithm Hash digest
SHA256 311c440fef8eef3c029dcbc3111d377efb44df273ad3b0aa59de6a3a99b5bc88
MD5 01bc7736fe4e6f6e336a90071b66616e
BLAKE2b-256 c89c4a620ca3c954b4accd3607f401605d7fcd456f9b08b639effea95f3d9cee

See more details on using hashes here.

File details

Details for the file taskingai-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: taskingai-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 134.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for taskingai-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 17339207e3975f9b8b703634713cddc00e811632f7e9caee7a19f602b5eddf51
MD5 1d316be99724ee02cefc7afb76f720d6
BLAKE2b-256 e7673586986d751c103129264e07cc466634d7ac733e498f974c906d6f7fdbe9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page