semvec/pypi-packages huggingface dataset:
streamll 0.1.1
Stream your DSPy application's inner-workings back to users in real-time
Requires Python: >=3.11
Keywords: dspy, streaming, llm, observability, ai

# streamll

Stream your DSPy application's inner-workings back to users in real-time. Route reasoning steps, token generation, and progress updates directly through your existing infrastructure.

## Installation

```bash
# Basic (terminal output only)
uv add streamll

# With Redis for production
uv add "streamll[redis]"

# With RabbitMQ
uv add "streamll[rabbitmq]"

# Everything
uv add "streamll[all]"
```

## Quick start

[![asciicast](https://asciinema.org/a/Lu7QCpvNtrShpYuq9riDx2CTr.svg)](https://asciinema.org/a/Lu7QCpvNtrShpYuq9riDx2CTr)

```python
import dspy
import streamll

# Stream tokens to terminal
@streamll.instrument(stream_fields=["answer"])
class QA(dspy.Module):
    def __init__(self):
        self.generate = dspy.ChainOfThought("question -> answer")

    def forward(self, question):
        return self.generate(question=question)

# Configure DSPy
dspy.configure(lm=dspy.LM("openai/gpt-4o-mini"))

qa = QA()
result = qa("Explain quantum computing")
```

## Production use

Send events to Redis or RabbitMQ instead of the terminal:

```python
from streamll.sinks import RedisSink

sink = RedisSink(redis_url="redis://localhost:6379", stream_key="ml_events")

@streamll.instrument(sinks=[sink], stream_fields=["answer"])
class QA(dspy.Module):
    def __init__(self):
        self.generate = dspy.ChainOfThought("question -> answer")

    def forward(self, question):
        return self.generate(question=question)
```

Consume events in another service:

```python
from streamll import EventConsumer

consumer = EventConsumer("redis://localhost:6379", target="ml_events")

@consumer.on("token")
async def handle_token(event):
    print(event.data["token"], end="", flush=True)

await consumer.run()
```

## Custom events

Emit custom events within your processing:

```python
@streamll.instrument
class RAGPipeline(dspy.Module):
    def forward(self, question):
        with streamll.trace("retrieval") as ctx:
            docs = self.retrieve(question)
            ctx.emit("docs_found", data={"count": len(docs)})

        answer = self.generate(docs=docs, question=question)
        return answer
```

## Event correlation

Attach correlation IDs that persist across all events:

```python
# In your API handler
streamll.set_context(
    conversation_id="conv_123",
    request_id="req_456"
)

# All subsequent events include this context
qa = QA()
result = qa("What is quantum computing?")

# Consumer can filter by context
@consumer.on("token")
async def handle_token(event):
    if event.data.get("conversation_id") == "conv_123":
        # Handle this specific conversation
        pass
```

## Development

```bash
# Run tests
uv run pytest

# With coverage
uv run pytest --cov=src/streamll

# Start test services (Redis, RabbitMQ)
docker-compose -f tests/docker-compose.yml up -d
```

## License

Apache 2.0
anova-lib 1.0.0
A wrapper for anova.chat

<p align="center">
  <img src="images/logo.png" alt="Nome do Projeto" width="200"/>
</p>

<h1 align="center">AnovaLib</h1>

<p align="center">
  A python wrapper for <a href="https://anova.chat/">anova</a> project
</p>

---

## Installation

```bash
pip install anova-lib
```

## Examples

```py
from anovalib import AnovaLib
```
tfrunner 0.12.5
A cli tool used to make running terraform or opentofu project simpler. Includes secret fetching and remote state management.
Requires Python: >=3.13

# Tfrunner

Welcome to `tfrunner`, a `cli` tool to run terraform commands with the following facilities:
- Multi-project support
- Automation support
- Remote backend
- GitLab secrets pulling


## Installation

Since `tfrunner` is a `cli` tool, the recommended installation is using `pipx`.

Please ensure you have a compatible `python >= 3.12` version.

Install with: `pipx install tfrunner`


## Usage

**Requirements**: `tfrunner` expects the following binaries to be installed:
- `terraform`: `tfrunner` is a wrapper on top of `terraform`
- `git`: when using the `--git-sandbox` flag, ensure you have `git` installed and that you are running the command in a `git` project

To use it to manage multiple projects, create a `yaml` file configuring each.

Here is an example file, let's name it `tfrunner.yaml`:
```yaml
flavour: terraform # Can use tofu

state_backend:
  kind: gitlab
  spec:
    url: https://gitlab.com
    project_id: 12345678
    token_var: GITLAB_TOKEN

secrets_backend:
  kind: gitlab
  spec:
    url: https://gitlab.com
    project_id: 12345678
    token_var: GITLAB_TOKEN

tfvars:
  gitlab_token: $GITLAB_TOKEN

projects:
  dev: # Reflects name of the environment
    path: ../infra/dev
    state_name: dev
    # Inner environment gets added (and overrides colliding vars) with global env vars
    # env vars take precedence over secrets
    tfvars:
      doppler_token: $DOPPLER_TOKEN
    # Inner secrets backend takes precendence
    secrets_backend:
      kind: doppler
      spec:
        project: my-project
        config: dev
        token_var: DOPPLER_TOKEN
```

Now you can run `tfrunner` as you would run any regular `terraform` command (options are also included). You need only to be wary of two additional arguments that are needed:
- `--project`: name of your project, as specified in your config file.
- `--config_path`: path to your configuration file. By default it will look for a `tfrunner.yaml` file in the current folder

As examples, for the `great-project` in our example `tfrunner.yaml` file, you could run:
```bash
tfrunner init --project great-project
tfrunner fmt --project great-project
tfrunner validate --project great-project
tfrunner plan --project great-project
tfrunner apply --project great-project
tfrunner destroy --config_path tfrunner.yaml --project great-project
```

The `--config_path` is optional in the `tfrunner destroy` command, as `tfrunner` will by default assume its path to be `tfrunner.yaml`.

## Usage with git-sandboxes

```bash
tfrunner init --project great-project --git-sandbox
tfrunner plan --project great-project --git-sandbox
tfrunner apply --project great-project --git-sandbox
tfrunner destroy --project great-project --git-sandbox
```

## Local development

**Requirements**:
- `uv` installed
- `terraform` installed
- `git` installed

1. Install virtual environment: `uv sync --all-groups`


# TODO:

- Make `tfrunner plan` generate a plan file by default
- Make `tfrunner apply` use that plan file by default