Skip to main content

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.

Metadata

Release files for giza-agents 0.4.2

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

Source distribution (sdist)

Source distribution for giza-agents 0.4.2
File Size Uploaded Provenance Actions
giza_agents-0.4.2.tar.gz 17.9 kB Without provenance Details for giza_agents-0.4.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for giza-agents 0.4.2
File Interpreter ABI Platform Actions
giza_agents-0.4.2-py3-none-any.whl Python 3 none any Details for giza_agents-0.4.2-py3-none-any.whl

Total release size: 36.9 kB

Release files / giza_agents-0.4.2.tar.gz

Download URL giza_agents-0.4.2.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3f48a98c7938d053efb34e1c97e92efadf8bf94bd243cf23941cb85fd14918e3
BLAKE2b-256 checksum
How to use checksums
a55e9b188c8f4962fdc720dfb5706dee36d07eb6dd84b05b12e34443490eec15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / giza_agents-0.4.2-py3-none-any.whl

Download URL giza_agents-0.4.2-py3-none-any.whl
Size 18.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
388bf5e5b6aeb03e238d4543f94e51b151bd1f653b4a953e8d1a8d28a2d1e52d
BLAKE2b-256 checksum
How to use checksums
701d98d828b89adb4448f0f7826bd2e7cdb65cf426851e220d1035d743d5a153
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Security for giza-agents 0.4.2

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