Enables creation of workflows for Dria Agents
Project description
Dria Workflows
Dria Workflows enables the creation of workflows for Dria Agents.
Installation
You can install Dria Workflows using pip:
pip install dria_workflows
Usage Example
Here's a simple example of how to use Dria Workflows:
import logging
from dria_workflows import WorkflowBuilder, Operator, Write, Edge, validate_workflow_json
def main():
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
builder = WorkflowBuilder()
# Add a step to your workflow
builder.generative_step(id="write_poem", prompt="Write a poem as if you are Kahlil Gibran", operator=Operator.GENERATION, outputs=[Write.new("poem")])
# Define the flow of your workflow
flow = [Edge(source="write_poem", target="_end")]
builder.flow(flow)
# Set the return value of your workflow
builder.set_return_value("poem")
# Build your workflow
workflow = builder.build()
# Validate your workflow
validate_workflow_json(workflow.model_dump_json(indent=2, exclude_unset=True, exclude_none=True))
# Save workflow
workflow.save("poem_workflow.json")
if __name__ == "__main__":
main()
Here is a more complex workflow
import logging
from dria_workflows import WorkflowBuilder, ConditionBuilder, Operator, Write, GetAll, Read, Push, Edge, Expression, validate_workflow_json
def main():
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
# Give a starting memory as input
builder = WorkflowBuilder(memory={"topic_1":"Linear Algebra", "topic_2":"CUDA"})
# Add steps to your workflow
builder.generative_step(id="create_query", prompt="Write down a search query related to following topics: {{topic_1}} and {{topic_2}}. If any, avoid asking questions asked before: {{history}}", operator=Operator.GENERATION, inputs=[GetAll.new("history", False)], outputs=[Write.new("search_query")])
builder.generative_step(id="search", prompt="{{search_query}}", operator=Operator.FUNCTION_CALLING, outputs=[Write.new("result"), Push.new("history")])
builder.generative_step(id="evaluate", prompt="Evaluate if search result is related and high quality to given question by saying Yes or No. Question: {{search_query}} , Search Result: {{result}}. Only output Yes or No and nothing else.", operator=Operator.GENERATION, outputs=[Write.new("is_valid")])
# Define the flow of your workflow
flow = [
Edge(source="create_query", target="search"),
Edge(source="search", target="evaluate"),
Edge(source="evaluate", target="_end", condition=ConditionBuilder.build(expected="Yes", target_if_not="create_query", expression=Expression.CONTAINS, input=Read.new("is_valid", True))),
]
builder.flow(flow)
# Set the return value of your workflow
builder.set_return_value("result")
# Build your workflow
workflow = builder.build()
validate_workflow_json(workflow.model_dump_json(indent=2, exclude_unset=True, exclude_none=True))
workflow.save("search_workflow.json")
if __name__ == "__main__":
main()
Detailed docs soon. andthattoo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dria_workflows-0.3.5.tar.gz
(21.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dria_workflows-0.3.5.tar.gz.
File metadata
- Download URL: dria_workflows-0.3.5.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6464c8cd1f511ad78933f1a2695b3a45a208033b7bfd634e5c378e4effe9d6a
|
|
| MD5 |
420ef98556cd0876da913c12bb20f201
|
|
| BLAKE2b-256 |
a1bf2a52e4f615090a218e7a769574050c6e7c1b9700b3cf1d4da43aafdd7270
|
File details
Details for the file dria_workflows-0.3.5-py3-none-any.whl.
File metadata
- Download URL: dria_workflows-0.3.5-py3-none-any.whl
- Upload date:
- Size: 28.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea74810375ef17b13a65366d185202974b452ddc00662bfa65c98075c642f3bd
|
|
| MD5 |
38732e30b23de9de82678f16bc343cd5
|
|
| BLAKE2b-256 |
8bb1965a0f98d4ee1792e8cd9bc86fd8ffd14b35908f9b37cbbbb0abe4f93c94
|