Skip to main content

⭐️ Features

  • Access to latest AI Engine features

  • Simple and intuitive API

📦 Getting Started

  
poetry add ai-engine-sdk  
# or 
pip install ai-engine-sdk  

Using the Chat API

Before you start to integrate the AI Engine into your app, you might want to get familiar with agent functions.

Creating the AIEngine client object

To find out how to generate an apiKey check out the documentation regarding Agentverse API keys.

from ai_engine_sdk import AiEngine  
ai_engine: AiEngine = AiEngine(api_key)  
  

Querying the id of the function group where our to-be-used function(s) belong

function_groups: list[FunctionGroup] = await ai_engine.get_function_groups()  
  
public_group = next(  
    (g for g in function_groups if g.name == "Fetch Verified"), None  
)  

If you would like to use the functions in your own My Functions function group, you can use this filter instead:

my_group = next(  
    (g for g in function_groups if g.name == "My Functions"), None  
)  

Sharing function groups

Purpose:

Allow to other users to use functions, under a concrete function-group, without replicating that function or allowing them alter those functions or funtion-group data.

How to:

If you wish to give access to a certain function-group (use, not alter the data/state of it), you can use the following method in the following way:

# assuming `ai_engine` is a valid instance of AiEngine

what_function_group_identifier_i_want_share="normally-this-is-an-uuid4"
user_email_i_want_to_share_the_function_group_with = "random@domain.com"
await ai_engine.share_function_group(
	function_group_id=what_function_group_identifier_i_want_share,
	target_user_email=user_email_i_want_to_share_the_function_group_with
)

Now, if you were requesting the available function-groups for the user with email assigned to the target_user_email argument, the function-group with the id assigned to function_group_id.

You can check that by using the AiEngine.get_function_groups method.

Creating a session with the AI Engine using the functionGroupId fetched before

session = await ai_engine.create_session(function_group=public_group.uuid)  

Starting the conversation with an arbitrary objective

await session.start(objective)

Querying new messages

You might want to query new messages regularly ...

while True:  
    messages: list[ApiBaseMessage] = await session.get_messages()
    # throttling
    sleep(3)

Execution a function on demand.

This is the first message that should be sent to the AI Engine for execution the function/s of your choice.
The main difference in here it is the AI Engine won't search, therefore decide for you, what is the apt function to fulfill your needs.

It contains the list of function-ids you want to execute and a function group (for secondary function picks).

Currently only supported by Next Generation personality. Don't use this if you already sent 'start' message.

# init the AI Engine client
from ai_engine_sdk import AiEngine  
ai_engine: AiEngine = AiEngine(api_key)  
# Create (do not start) a Session
session = await ai_engine.create_session(function_group=function_group.uuid)  

# Execute function. You will receive no response.
await session.execute_function(function_ids=[function_uuid], objective="", context="")

# In order to get some feedback, gather the messages as regular.
while True:  
    messages: list[ApiBaseMessage] = await session.get_messages()
    # throttling
    sleep(3)

Checking the type of the new message

There are 5 different types of messages which are generated by the AI Engine and the SDK implements methods for checking the type of the respective new Message:

  • task selection message: is_task_selection_message - this message is generated for example in the case when the AI engine recommends functions based on the initial objective or in the case when the AI Engine finds multiple options to provide as an input for a function.

  • AI Engine message: is_ai_engine_message - this message type doesn't expect the user to reply to, this is for notifying the user about something

  • confirmation message: is_confirmation_message - when the AI Engine has managed to acquire all the inputs for the agent belonging to the to-be-executed function (= it has managed to build the context), it sends this type of message to the user

  • agent message: is_agent_message - this is a regular question that the user has to reply to with a string

  • stop message: is_stop_message - this is the message which is sent when the session has stopped and the AI Engine doesn't wait for any replies from the user

Replying to the different type of messages

All message types (except for the AI engine message and stop message) expect a response from the user and the SDK implements methods for sending reply in response to those different type of messages respectively.

The first argument of all these reply methods is the Message object to which we want to send back the response.

The SDK methods you can use to reply to:

  • task selection message: session.submit_task_selection

  • agent message: session.submit_response

  • confirmation message: session.submit_confirmation or session.reject_confirmation - depending on if the user wants to confirm or reject the context generated by the AI engine respectively

Deleting session with AI engine

After finishing the conversation with AI Engine you can delete the session like this:

await session.delete()

If you would like to check out a complete example on how to integrate AI Engine into your app, feel free to checkout examples/run_example.py.

🔨 Useful scripts

Create function groups and share them with other user

Use cases:

  • Test in different environments the function-group creation and sharing.

List function groups by user

List the function belonging to the user owning the AV_API_TOKEN.

Use cases:

Share function group

Share an existing function group by providing the id (you can fetch via 'list function groups'

✨ Contributing

All contributions are welcome! Remember, contribution includes not only code, but any help with docs or issues raised by other developers. See our contribution guidelines for more details.

❓ Issues, Questions, and Discussions

We use GitHub Issues for tracking requests and bugs.

Metadata

Release files for ai-engine-sdk 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai-engine-sdk 0.1.3
File Size Uploaded Provenance Actions
ai_engine_sdk-0.1.3.tar.gz 15.8 kB Without provenance Details for ai_engine_sdk-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ai-engine-sdk 0.1.3
File Interpreter ABI Platform Actions
ai_engine_sdk-0.1.3-py3-none-any.whl Python 3 none any Details for ai_engine_sdk-0.1.3-py3-none-any.whl

Total release size: 32.3 kB

Release files / ai_engine_sdk-0.1.3.tar.gz

Download URL ai_engine_sdk-0.1.3.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d10a5a57f11abd9cdc63ce35a08b338f3295b0dd3e32f8e41fa7dacf8c1609dd
BLAKE2b-256 checksum
How to use checksums
1c8429e714dac4ee16a0b996a96ded965026dbe614f1f409dc36be1ba271d463
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.5

Release files / ai_engine_sdk-0.1.3-py3-none-any.whl

Download URL ai_engine_sdk-0.1.3-py3-none-any.whl
Size 16.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9789a217843e43da730a6c15e5e33571ac01a211badbc4f585b2c891c4cca42
BLAKE2b-256 checksum
How to use checksums
ba34f9f74b491df80ec7882cfdae6e9ddd1f146c2accfd54fe7269bb739c2bdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.5

Security for ai-engine-sdk 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page