This example demonstrates how to use and write custom asyncflows actions.
This repo includes:
my_actions/my_get_url.py
, an action that fetches the HTML of a websiteget_website_title.yaml
, a flow that prompts a language model to get the title of the fetched websiteget_website_title.py
, a script that runs the flow
To run the example:
-
Set up Ollama or configure another language model
-
Clone the repository
git clone ssh://git@github.com/asynchronous-flows/api-call-example
- Change into the directory
cd api-call-example
- Create and activate your virtual environment (with, for example)
python3.11 -m venv .venv
source .venv/bin/activate
- If not already installed, install poetry. Install dependencies with:
poetry install
- Run the example
python -m api_call_example.get_website_title
Use this repository as a template, and add more actions in the api_call_example/my_actions
directory.
As long as they are in the my_actions
directory, they will be automatically loaded by the asyncflows
library.
If you'd like to change that directory, or use the paradigm in the different package,
simply include the tool.poetry.plugins
directive in the pyproject.toml
file:
[tool.poetry.plugins."asyncflows"]
actions = "api_call_example.my_actions"