Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.9%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Basic Info
  • Host: GitHub
  • Owner: fetchai
  • License: other
  • Language: Python
  • Default Branch: master
  • Size: 188 KB
Statistics
  • Stars: 3
  • Watchers: 3
  • Forks: 9
  • Open Issues: 5
  • Releases: 0
Created about 2 years ago · Last pushed over 1 year ago
Metadata Files
Readme Contributing License Code of conduct Citation Codeowners Security

README.md

⭐️ Features

  • Access to latest AI Engine features

  • Simple and intuitive API

📦 Getting Started

```bash

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.

```python
from aienginesdk import AiEngine
aiengine: AiEngine = AiEngine(apikey)

```

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

```python
functiongroups: list[FunctionGroup] = await aiengine.getfunctiongroups()

publicgroup = 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:

python 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:

```python

assuming ai_engine is a valid instance of AiEngine

whatfunctiongroupidentifieriwantshare="normally-this-is-an-uuid4" useremailiwanttosharethefunctiongroupwith = "random@domain.com" await aiengine.sharefunctiongroup( functiongroupid=whatfunctiongroupidentifieriwantshare, targetuseremail=useremailiwanttosharethefunctiongroup_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

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

Starting the conversation with an arbitrary objective

python await session.start(objective)

Querying new messages

You might want to query new messages regularly ... python 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.

```python

init the AI Engine client

from aienginesdk import AiEngine
aiengine: AiEngine = AiEngine(apikey)

Create (do not start) a Session

session = await aiengine.createsession(functiongroup=functiongroup.uuid)

Execute function. You will receive no response.

await session.executefunction(functionids=[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: istaskselection_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: isaiengine_message - this message type doesn't expect the user to reply to, this is for notifying the user about something

  • confirmation message: isconfirmationmessage - 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: isagentmessage - this is a regular question that the user has to reply to with a string

  • stop message: isstopmessage - 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.submittaskselection

  • agent message: session.submit_response

  • confirmation message: session.submitconfirmation or session.rejectconfirmation - 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:

```python

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 AVAPITOKEN. #### 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.

Owner

  • Name: Fetch.AI
  • Login: fetchai
  • Kind: organization

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this SDK in your research or project, please cite it as follows:"
title: Fetch.ai AI Engine SDK in Python
authors:
  - family-names: Fetch.ai
date-released: "2024-06-06"
url: "https://github.com/fetchai/ai-engine-sdk-python"
license: "Apache-2.0"

GitHub Events

Total
  • Issues event: 1
  • Watch event: 3
  • Delete event: 2
  • Member event: 1
  • Issue comment event: 1
  • Push event: 2
  • Pull request review event: 2
  • Pull request event: 4
  • Fork event: 1
  • Create event: 2
Last Year
  • Issues event: 1
  • Watch event: 3
  • Delete event: 2
  • Member event: 1
  • Issue comment event: 1
  • Push event: 2
  • Pull request review event: 2
  • Pull request event: 4
  • Fork event: 1
  • Create event: 2

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 36 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
pypi.org: ai-engine-sdk
  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 36 Last month
Rankings
Dependent packages count: 10.8%
Average: 35.8%
Dependent repos count: 60.8%
Maintainers (1)
Last synced: 11 months ago

Dependencies

poetry.lock pypi
  • aiohttp 3.9.5
  • aiosignal 1.3.1
  • annotated-types 0.7.0
  • attrs 23.2.0
  • frozenlist 1.4.1
  • idna 3.7
  • multidict 6.0.5
  • pydantic 2.7.3
  • pydantic-core 2.18.4
  • typing-extensions 4.12.2
  • yarl 1.9.4
pyproject.toml pypi
  • aiohttp ^3.9.5
  • pydantic ^2.7.3
  • python ~3.11
.github/workflows/ci-sdk-tests.yaml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
  • snok/install-poetry v1 composite