Skip to content

docs(sample-app): add AlephAlpha tracing example#4348

Open
LuoisaWu wants to merge 1 commit into
traceloop:mainfrom
LuoisaWu:docs/alephalpha-sample-app
Open

docs(sample-app): add AlephAlpha tracing example#4348
LuoisaWu wants to merge 1 commit into
traceloop:mainfrom
LuoisaWu:docs/alephalpha-sample-app

Conversation

@LuoisaWu

@LuoisaWu LuoisaWu commented Jul 4, 2026

Copy link
Copy Markdown

Summary:

  • Add a minimal sample app for Aleph Alpha completion tracing.
  • Initialize Traceloop SDK and wrap the provider call in task/workflow decorators.
  • Declare the Aleph Alpha client and instrumentation dependency in sample-app.

Testing:

  • python -m py_compile packages/sample-app/sample_app/alephalpha_example.py

Related:

Summary by CodeRabbit

  • New Features
    • Added a runnable sample app demonstrating a text-completion workflow.
    • Included support for a new AI client and its related tracing integration in the sample app setup.
    • The sample can now be run directly to print a completion result.

@CLAassistant

CLAassistant commented Jul 4, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds an Aleph Alpha sample application to the sample-app package. It introduces new dependencies (aleph-alpha-client, opentelemetry-instrumentation-alephalpha) in pyproject.toml and a new example script demonstrating Traceloop-instrumented completion requests using the Aleph Alpha client.

Changes

Aleph Alpha sample integration

Layer / File(s) Summary
Dependency additions
packages/sample-app/pyproject.toml
Adds aleph-alpha-client (>=7.1.0,<8) and opentelemetry-instrumentation-alephalpha dependencies, plus a local editable [tool.uv.sources] mapping for the instrumentation package.
Sample script
packages/sample-app/sample_app/alephalpha_example.py
New script initializes Traceloop, creates an Aleph Alpha client from an env token, defines a complete_prompt task and alephalpha_completion_demo workflow, and runs via __main__.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Sequence Diagram(s)

sequenceDiagram
    participant Main as __main__
    participant Workflow as alephalpha_completion_demo
    participant Task as complete_prompt
    participant Client as Aleph Alpha Client

    Main->>Workflow: invoke
    Workflow->>Task: complete_prompt()
    Task->>Client: complete(CompletionRequest)
    Client-->>Task: completion response
    Task-->>Workflow: completion text
    Workflow-->>Main: print result
Loading

Related issues: None specified.

Related PRs: None specified.

Suggested labels: enhancement, dependencies

Suggested reviewers: None specified.

🐰 A hop, a skip, a token so free,
Aleph Alpha joins our sample tree,
Traceloop watches each prompt take flight,
Completions returned, all clear and bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding an Aleph Alpha tracing example to the sample app.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/sample-app/sample_app/alephalpha_example.py (1)

10-10: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

No validation if API token is missing.

If neither ALEPH_ALPHA_API_KEY nor AA_TOKEN is set, token will be None, and Client(token=None) will fail with an unclear error at import/module-load time rather than a helpful message telling the user to configure credentials.

💡 Proposed fix
-client = Client(token=os.environ.get("ALEPH_ALPHA_API_KEY") or os.environ.get("AA_TOKEN"))
+api_token = os.environ.get("ALEPH_ALPHA_API_KEY") or os.environ.get("AA_TOKEN")
+if not api_token:
+    raise EnvironmentError(
+        "Please set the ALEPH_ALPHA_API_KEY or AA_TOKEN environment variable"
+    )
+client = Client(token=api_token)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/sample-app/sample_app/alephalpha_example.py` at line 10, The Aleph
Alpha example initializes Client with a possibly missing token, so add explicit
credential validation before constructing the client. In alephalpha_example.py,
check the result of os.environ.get for ALEPH_ALPHA_API_KEY and AA_TOKEN, and if
both are absent, raise a clear error that tells the user to set one of those
environment variables; otherwise pass the resolved token into Client. Keep the
check near the existing Client initialization so the failure happens with a
helpful message instead of a module-load error.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/sample-app/sample_app/alephalpha_example.py`:
- Line 10: The Aleph Alpha example initializes Client with a possibly missing
token, so add explicit credential validation before constructing the client. In
alephalpha_example.py, check the result of os.environ.get for
ALEPH_ALPHA_API_KEY and AA_TOKEN, and if both are absent, raise a clear error
that tells the user to set one of those environment variables; otherwise pass
the resolved token into Client. Keep the check near the existing Client
initialization so the failure happens with a helpful message instead of a
module-load error.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 22876689-4a5d-4b2b-9376-294c95774278

📥 Commits

Reviewing files that changed from the base of the PR and between 93429cf and 8d759d8.

📒 Files selected for processing (2)
  • packages/sample-app/pyproject.toml
  • packages/sample-app/sample_app/alephalpha_example.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants