Skip to main content

Your project description

Project description

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!

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

sekvo-0.1.1.tar.gz (171.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sekvo-0.1.1-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file sekvo-0.1.1.tar.gz.

File metadata

  • Download URL: sekvo-0.1.1.tar.gz
  • Upload date:
  • Size: 171.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for sekvo-0.1.1.tar.gz
Algorithm Hash digest
SHA256 558b281eee3dc749c3b1d8be8cdcd37aee7cf38fa68329d846718a9e892b6e78
MD5 c3029a46b59cdc46c42aa8fdb52c3f6e
BLAKE2b-256 2185ad9edf6cd2ca9deb364a98ce1186f7b5e8b28b2e39cdb8b73172e7630dea

See more details on using hashes here.

File details

Details for the file sekvo-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sekvo-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for sekvo-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d79b9cf5107ad14ece8b6b0013db7aa447c7e83473ba3c509b7ff6d5e8d6157b
MD5 8ab986992f99e88a0bfc1e5a2e997823
BLAKE2b-256 e2a2995ca90beffdb3273260caec42c13e8048c5ab4e625284d6e2f1b3018b76

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page