Skip to main content

A Python SDK for Giza platform

Project description

image

AI Agents

Giza Agents is a framework for trust-minimized integration of machine learning into on-chain strategy and action, featuring mechanisms for agentic memory and reflection that improve performance over their lifecycle.

The extensible nature of Giza Agents allows developers to enshrine custom strategies using ML and other algorithms, develop novel agent functionalities and manage continuous iteration processes.

Where to start?

Check out our extensive documentation to understand the concepts and follow how-to-guides.

Installation

Start by creating a virtual environment in your project directory and activate it:

$ python -m venv .env

# Activate the virtual environment. On Linux and MacOs
$ source .env/bin/activate

# Activate Virtual environment on Windows:
$ .env/Scripts/activate

Now you’re ready to install ⚡Agents with the following command:

$ pip install giza-agents

Setup

From your terminal, create a Giza user through our CLI in order to access the Giza Platform:

$ giza users create

After creating your user, log into Giza:

$ giza users login

Optional: you can create an API Key for your user in order to not regenerate your access token every few hours.

$ giza users create-api-key

Usage

Creating Agents

Agents are the entities that interact with the Giza Platform to handle verification of predictions and interactions with Smart Contracts. They are responsible for wating until the proof of the prediction is available and verified, and then handling the interaction with the contract.

To create the agent, you will first need to locally create an ape account:

$ ape accounts generate <account name>

Enhance the security of your account by adding additional random input:
Show mnemonic? [Y/n]: n
Create Passphrase to encrypt account:
Repeat for confirmation:
SUCCESS: A new account '0x766867bB2E3E1A6E6245F4930b47E9aF54cEba0C' with HDPath m/44'/60'/0'/0/0 has been added with the id '<account name>'

For more information on how to create an account, check the ape documentation.

After creating the account, you can create the agent (the agent must be associated with a version that has an existing endpoint), this will prompt you to enter the account name:

$ giza agents create --model-id <model_id> --version-id <version_id> --name <agent_name> --description <agent_description>

[giza][2024-04-10 11:50:24.005] Creating agent [giza][2024-04-10 11:50:24.006] Using endpoint id to create agent, retrieving model id and version id
[giza][2024-04-10 11:50:53.480] Select an existing account to create the agent.
[giza][2024-04-10 11:50:53.480] Available accounts are:
┏━━━━━━━━━━━━━┓
┃  Accounts   ┃
┡━━━━━━━━━━━━━┩
│ my_account  │
└─────────────┘
Enter the account name: my_account
{
  "id": 1,
  "name": <agent_name>,
  "description": <agent_description>,
  "parameters": {
    "model_id": <model_id>,
    "version_id": <version_id>,
    "endpoint_id": <endpoint_id>,
    "alias": "my_account"
  },
  "created_date": "2024-04-10T09:51:04.226448",
  "last_update": "2024-04-10T09:51:04.226448"
}

Now, to interact with the agent and the contract, wou will need to export the passphrase of the account to the environment. The variable name should be <ACCOUNT NAME>_PASSPHRASE, all in caps. Make sure to keep this secret:

$ export <ACCOUNT NAME>_PASSPHRASE=<passphrase>
from giza.agents import Agent

# Here we check for the passphrase in the environment
agent = Agent.from_id(id=1, contracts={"my_contract": "0x1234567890"})

# Predict the data
result = agent.predict(data={"input": "data"})

# Handle the contracts
with agent.execute() as contracts:
    # Wait for the verification and then execute the contract
    contract_result = contracts.my_contract.function(result.value)

# Do anything with the result
...

Examples

Examples of how to use the Agents can be found in the examples directory. Each example includes a README or a Notebook with detailed instructions on how to run the example.

Contributing

Contributions are welcome! Please submit a pull request or create an issue to get started.

License

The Giza SDK is licensed under the MIT license.

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

giza_agents-0.4.2.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

giza_agents-0.4.2-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file giza_agents-0.4.2.tar.gz.

File metadata

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

File hashes

Hashes for giza_agents-0.4.2.tar.gz
Algorithm Hash digest
SHA256 3f48a98c7938d053efb34e1c97e92efadf8bf94bd243cf23941cb85fd14918e3
MD5 ad4c088fce38153609e26259e7780501
BLAKE2b-256 a55e9b188c8f4962fdc720dfb5706dee36d07eb6dd84b05b12e34443490eec15

See more details on using hashes here.

File details

Details for the file giza_agents-0.4.2-py3-none-any.whl.

File metadata

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

File hashes

Hashes for giza_agents-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 388bf5e5b6aeb03e238d4543f94e51b151bd1f653b4a953e8d1a8d28a2d1e52d
MD5 7e4ebf031520882905069d40e5bdbaa8
BLAKE2b-256 701d98d828b89adb4448f0f7826bd2e7cdb65cf426851e220d1035d743d5a153

See more details on using hashes here.

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