Skip to main content

No project description provided

Project description

⭐️ 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 instead then you can use this filter instead:

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

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)

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 (expect for the AI engine message and stop message) expects 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.

✨ 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.

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

ai_engine_sdk-0.1.1.tar.gz (12.2 kB view hashes)

Uploaded Source

Built Distribution

ai_engine_sdk-0.1.1-py3-none-any.whl (13.2 kB view hashes)

Uploaded Python 3

Supported by

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