Skip to main content

No project description provided

Project description

dendrite-python-sdk

Installation:

Authentication:

Get your API key by going to dendrite.se and creating an account.

You must enter your own OpenAI API key into your Dendrite account's environment variables before you can start.

Complete web tasks with Dendrite's agent:

client = DendriteAPI('your-api-key')

dto = {
    "message": "Please go to https://www.scrapethissite.com/pages/forms/ and scrape all the Team's names.",
    "store_chat":  True

}
res = client.complete_task(dto)

print(res.message) # Description of how the results were acheived
print(res.data) # JSON containing the data from the task if there is any

Complete web tasks with your own agent:

Entire example can be found in /examples.


...Custom actions...


messages = [
    {"role": "system", "content": "The assistant is a AI agent [...] "},
    {"role": "user", "content": "Please go to the website https://scrapethis [...] "},
]
max_iterations = 10
iterations = 0
openai_api_key = os.environ.get("OPENAI_API_KEY")
dendrite_api_key = os.environ.get("DENDRITE_API_KEY")

openai_client = openai.OpenAI(api_key=openai_api_key)
dendrite_client = DendriteAPI(api_key=dendrite_api_key)

actions = [go_to_website, scroll, custom_action_tool]

while iterations < max_iterations:
    iterations += 1

    response = openai_client.chat.completions.create({
        "model": "gpt-3.5-turbo-1106",
        "messages": messages,
        "tools": actions,
    })
    tool_calls = response.tool_calls
    if not tool_calls:
        break
    else:
        for tool_call in tool_calls:
            function_name = tool_call.function.name
            function_args = json.loads(tool_call.function.arguments)
            valid_args = {k: v for k, v in function_args.items()
                          if v is not None}

            function_response = "No response"

            if function_name == "go_to_website":
                function_response = dendrite_client.go_to_website(**valid_args)
            elif function_name == "scroll":
                function_response = dendrite_client.scroll(**valid_args)
            elif function_name == "custom_action":
                function_response = custom_action(**valid_args)

            tool_call = {
                "tool_call_id": tool_call.id,
                "role": "tool",
                "name": function_name,
                "content": function_response,
            }
            messages.append(tool_call)

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

dendrite_python_sdk-0.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

dendrite_python_sdk-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file dendrite_python_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: dendrite_python_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.4 Darwin/22.6.0

File hashes

Hashes for dendrite_python_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1de4fd45d240b849679bb2bdf8d5bd5968a910eb5cadccf0354f01877a0d39c8
MD5 e606b9fe9748332f7fc4c0b867fb2663
BLAKE2b-256 c576fab761e31401d4e8d3e178145ea0b3f7d86647cd0c92b296041d001a8f42

See more details on using hashes here.

File details

Details for the file dendrite_python_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dendrite_python_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4cf2eda7be29c2a8cfba7e52bb6d57a327ac5aaee8e8b250cc9394b2dd5bf048
MD5 8c9e95d7fba71dce9ea11dd3a3a447ee
BLAKE2b-256 ec205f211b872b733aa91157d395b8838b780db2f5a2efb40ec8b86ce20ef98e

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