Skip to main content

Sekvo logo

sekvo

Sekvo is a simple and flexible Python library for piping and processing of prompts through various AI providers.

With Sekvo, you can easily chain prompts, use multiple providers, collect metrics, validate responses, apply transformations and filters, and process prompts in parallel and batches, all from the comfort of a shell.

Python Version

quick usage and installation example

# via git
cd sekvo/
pyenv install 3.13.1
python -m venv venv_3131/
pip isntall -e '.[all]'

# via pypi
pip install sekvo


# add your key to .env/.env.anthropic.dev

# usage
sekvo
sekvo --help
sekvo providers
sekvo --list-commands
sekvo anthropic.generate --help

echo 'tell me a joke' | sekvo anthropic.generate
sekvo anthropic.generate 'tell me a joke'

# raw output
echo 'tell me a joke' | sekvo anthropic.generate --raw

# json output
sekvo anthropic.generate --json 'tell me a joke'

# a custom prompt and summary
curl https://nebkiso.com > page.txt
echo 'What is this webpage about?\n' > prompt.txt
cat prompt.txt page.txt | sekvo anthropic.generate


# structured json merging

jq -s 'add | unique' <(cat my-json-prompt.txt | sekvo anthropic.generate --raw) ../old-places.json >| merged-places.json

Features

  • Prompt Piping: Chain prompts together and pipe them through different AI providers for sequential processing.
  • Multiple Providers: Seamlessly integrate with multiple AI providers, such as AnthropicProvider, and switch between them effortlessly.
  • Parallel Processing: Process prompts in parallel using multiple providers simultaneously.
  • Metrics Collection: Collect valuable metrics, including provider information, input tokens, and processing duration, for each prompt.
  • JSON Validation: Automatically validate the JSON response from providers and retry on invalid responses.
  • Transformations and Filters: Apply custom transformations and filters to the prompts and responses.
  • Batch Processing: Process multiple prompts in batches for efficient handling of large datasets.

More Usage Examples

Examples

More examples: Located here

Basic Prompt Processing

from sekvo.core.prompt_pipe import Prompt
from sekvo.providers.anthropic.generate import AnthropicProvider

provider = AnthropicProvider(env_name="anthropic-test")

result = await (Prompt("test prompt") | provider)
print(result)  # Output: response(test prompt)

Chaining Prompts and Providers

from sekvo.core.prompt_pipe import Prompt
from sekvo.providers.anthropic.generate import AnthropicProvider

provider1 = AnthropicProvider(env_name="anthropic-test1")
provider2 = AnthropicProvider(env_name="anthropic-test2")

result = await (Prompt("test prompt") | provider1 | provider2)
print(result)  # Output: provider2(provider1(test prompt))

Parallel Processing

from sekvo.core.prompt_pipe import ParallelPrompt
from sekvo.providers.anthropic.generate import AnthropicProvider

provider1 = AnthropicProvider(env_name="anthropic-test1")
provider2 = AnthropicProvider(env_name="anthropic-test2")

result = await (ParallelPrompt("test prompt") | [provider1, provider2])
print(result)  # Output: ["provider1(test prompt)", "provider2(test prompt)"]

Transformations and Filters

from sekvo.core.prompt_pipe import FilterPrompt
from sekvo.providers.anthropic.generate import AnthropicProvider

provider = AnthropicProvider(env_name="anthropic-test")

prompt = FilterPrompt("test prompt")
result = await (
    prompt
    .transform(str.upper)
    .filter(lambda x: len(x) > 0) |
    provider
)
print(result)  # Output: response(TEST PROMPT)

Batch Processing

from sekvo.core.prompt_pipe import BatchPrompt
from sekvo.providers.anthropic.generate import AnthropicProvider

provider = AnthropicProvider(env_name="anthropic-test")

prompt = BatchPrompt(["test1", "test2", "test3"])
results = await (prompt | provider)
print(results)  # Output: ["response(test1)", "response(test2)", "response(test3)"]

Installation

pip install sekvo

Contributing

Contributions are welcome!

Metadata

Release files for sekvo 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sekvo 0.1.1
File Size Uploaded Provenance
sekvo-0.1.1.tar.gz 171.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sekvo 0.1.1
File Interpreter ABI Platform
sekvo-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 193.8 kB

Release files / sekvo-0.1.1.tar.gz

Download URL sekvo-0.1.1.tar.gz
Size 171.2 kB
Tags Source
SHA-256 checksum
How to use checksums
558b281eee3dc749c3b1d8be8cdcd37aee7cf38fa68329d846718a9e892b6e78
BLAKE2b-256 checksum
How to use checksums
2185ad9edf6cd2ca9deb364a98ce1186f7b5e8b28b2e39cdb8b73172e7630dea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / sekvo-0.1.1-py3-none-any.whl

Download URL sekvo-0.1.1-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d79b9cf5107ad14ece8b6b0013db7aa447c7e83473ba3c509b7ff6d5e8d6157b
BLAKE2b-256 checksum
How to use checksums
e2a2995ca90beffdb3273260caec42c13e8048c5ab4e625284d6e2f1b3018b76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Security for sekvo 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page