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
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1de4fd45d240b849679bb2bdf8d5bd5968a910eb5cadccf0354f01877a0d39c8 |
|
MD5 | e606b9fe9748332f7fc4c0b867fb2663 |
|
BLAKE2b-256 | c576fab761e31401d4e8d3e178145ea0b3f7d86647cd0c92b296041d001a8f42 |
File details
Details for the file dendrite_python_sdk-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: dendrite_python_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.4 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cf2eda7be29c2a8cfba7e52bb6d57a327ac5aaee8e8b250cc9394b2dd5bf048 |
|
MD5 | 8c9e95d7fba71dce9ea11dd3a3a447ee |
|
BLAKE2b-256 | ec205f211b872b733aa91157d395b8838b780db2f5a2efb40ec8b86ce20ef98e |