DAGs for LLM interactions
Project description
Diagraph
Diagraph represents Large Language Model (LLM) interactions as a graph, which makes it easy to build, edit, and re-execute a chain of structured dialogues.
Key features:
- Cache & Replay: Rerun starting from specific interactions. Save time and money.
- Edits: Edit interactions - prompts, results, functions - on the fly.
- Dependencies: Specify a function's dependencies as parameters for clean, readable, refactorable code.
- Functions: Use any LLM or set of tools you want. Diagraph operates on top of plain Python functions.
- Visualizations: Get a straightforward view of your graph with a built-in Jupyter visualization tool.
- Concurrency: Diagraph takes care of deciding when to run your functions so that all dependencies are satisfied. Get concurrency for free.
Requirements
Python 3.10+
Installation
pip install diagraph
Quickstart
from diagraph import Diagraph, Depends, prompt, llm
openai.api_key = 'sk-<OPENAI_TOKEN>'
@prompt
def tell_me_a_joke():
return 'Computer! Tell me a joke about tomatoes.'
@prompt
def explanation(joke: str = Depends(tell_me_a_joke)) -> str:
return f'Explain why the joke "{joke}" is funny.'
dg = Diagraph(explanation).run()
print(dg.result) # 'The joke is a play on words and concepts. There are two main ideas that make it humorous...
dg
Usage
License
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
diagraph-0.4.7.tar.gz
(718.7 kB
view details)
Built Distribution
diagraph-0.4.7-py3-none-any.whl
(739.1 kB
view details)
File details
Details for the file diagraph-0.4.7.tar.gz
.
File metadata
- Download URL: diagraph-0.4.7.tar.gz
- Upload date:
- Size: 718.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3830970431aaae8156a4e2d69513818abae171d15f0b4c8ed0c5a87d54af9ae8 |
|
MD5 | d3f6bf95ae4f88fe1899499d3f487924 |
|
BLAKE2b-256 | b0905786aab81ac72a65b67aebad51f600b24ff45501a613b0110e72f202ba43 |
File details
Details for the file diagraph-0.4.7-py3-none-any.whl
.
File metadata
- Download URL: diagraph-0.4.7-py3-none-any.whl
- Upload date:
- Size: 739.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a3acb09e041a121b6c116600dcb4e938548fef839266e4e3740bc5cb7316ef4 |
|
MD5 | 482cc10330ddb38fe65f585681f5bd12 |
|
BLAKE2b-256 | 78f29456facc9784d14d415982fd67f57997d1a362babb5d537c99680394f90a |