Skip to main content

EdenAI SDKfor ython

Project description

Python SDK for EdenAI workflows

This package is in alpha and the api can still change

Installation

pip install edenai_sdk

Example

You can use client.create_or_update(name="my_unique_name", data=data) to create a workflow. If a workflow with this name already exists it will update the workflow. You can always view the workflow you've build in the UI in the EdenAI App

To see which parameters are availabe for each feature, you can check our api docs

from edenai_sdk.workflow import workflow_client

def main():
    client = workflow_client(
        api_key=os.environ.get("API_KEY")
    )

    data = {
        "nodes": [
            {
                "type": "input",
                "name": "Input_Node",
                "data": [
                    {"type": "string", "label": "text", "defaultValue": "Hello, world!"}
                ],
            },
            {
                "type": "text/chat",
                "name": "some_chat",
                "data": [
                    {"name": "provider", "value": "openai/gpt-4o"},
                    {"name": "text", "value": "explain me: {{Input_Node.text}}"},
                ],
            },
            {
                "type": "translation/automatic_translation",
                "name": "Translation",
                "data": [
                    {"name": "provider", "value": "google"},
                    {"name": "text", "value": "{{some_chat.generated_text}}"},
                    {"name": "source_language", "value": "en"},
                    {"name": "target_language", "value": "fr"},
                ],
            },
            {
                "type": "text/keyword_extraction",
                "name": "Keywords",
                "data": [
                    {"name": "provider", "value": "openai"},
                    {"name": "text", "value": "{{Translation.text}}"},
                ],
            },
            {
                "type": "code",
                "name": "some_code",
                "data": [
                    {
                        "name": "code",
                        "value": "const valueFromInput = {{ Input_Node.text }};\n  const valueFromNode = {{ some_chat.generated_text }};  \nfunction greet(msg) {\n  return `welcome ${msg}!`;\n};\n\nreturn {\n input: greet(valueFromInput),\n node: greet(valueFromNode),\n};",
                    }
                ],
            },
            {
                "type": "output",
                "name": "Output_Node",
                "data": [{"name": "french_keywords", "value": "{{Keywords.items[*].keyword}}"}],
            },
        ]
    }

    response = client.create_or_update(name="code_test", data=data)
    execution = client.execute(name="code_test", data={"text": "Tell me a story about Eden AI"})
    print(execution["output"])



if __name__ == "__main__":
    main()

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

edenai_sdk-0.1.0a2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edenai_sdk-0.1.0a2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file edenai_sdk-0.1.0a2.tar.gz.

File metadata

  • Download URL: edenai_sdk-0.1.0a2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for edenai_sdk-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 9b7988a3e8a2d72c7498025be3b16e62d08d650025a600dd261792fecc4a4c43
MD5 2df13f106d39f38ec3048eb6629e3951
BLAKE2b-256 c0c444b5fc4afcdf97ffda14d184f5ef57452d7115afcbd386220cbe24cd35ac

See more details on using hashes here.

File details

Details for the file edenai_sdk-0.1.0a2-py3-none-any.whl.

File metadata

  • Download URL: edenai_sdk-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for edenai_sdk-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 e74aff9d31086a9ad9533c62058499377e8a32b55fe589dd2182eb119a1000ab
MD5 1c3acf4ec2f6ac39b79f320a42047bd0
BLAKE2b-256 6bfc6f674e28320026ef9ba3255e09ad2ff9fee981b74e0b24d33a6579ec6ea2

See more details on using hashes here.

Supported by

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