Skip to content

Conversation

@thucpn
Copy link
Collaborator

@thucpn thucpn commented May 8, 2025

Summary by CodeRabbit

  • New Features
    • Introduced example servers demonstrating LlamaIndex workflows, including an agentic retrieval-augmented generation (RAG) workflow and a simple calculator agent.
    • Added user interfaces for interacting with the example servers, featuring starter questions and app titles.
  • Documentation
    • Added a README with setup and usage instructions for running the example servers.
  • Chores
    • Added configuration files and updated workspace settings to support the new examples package.
    • Enhanced CI workflow to include type checking for the examples package.

@thucpn thucpn requested review from leehuwuj and marcusschiesser May 8, 2025 08:53
@changeset-bot
Copy link

changeset-bot bot commented May 8, 2025

🦋 Changeset detected

Latest commit: c534269

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@llamaindex/server Patch
llamaindex-server-examples Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented May 8, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A new set of example server workflows and supporting configuration files were added under packages/server/examples. These include a README, TypeScript configuration, package manifest, and two example servers: a simple calculator and an agentic RAG workflow. The workspace configuration was updated to include the examples package. Additionally, GitHub Actions were updated to run typechecking on the examples.

Changes

File(s) Change Summary
packages/server/examples/README.md Added a README with instructions for running LlamaIndex Server examples and interacting via a browser.
packages/server/examples/package.json, packages/server/examples/tsconfig.json Added package manifest and TypeScript configuration for the examples package, specifying dependencies, scripts, and compiler options.
packages/server/examples/simple-workflow/calculator.ts Introduced a simple calculator server example using LlamaIndex, with a single "add" tool agent and server setup on port 4000.
packages/server/examples/agentic-rag/index.ts Added an agentic RAG workflow server example using LlamaIndex, setting up a vector store index, query tool, and server on port 4100.
pnpm-workspace.yaml Updated workspace configuration to include the new examples package path.
.github/workflows/lint_on_push_or_pull.yml Added a GitHub Actions step to run TypeScript typechecking on the examples package during lint jobs.
.changeset/odd-tomatoes-explode.md Added a changeset specifying patch version bumps for @llamaindex/server and llamaindex-server-examples with a note about adding the examples package.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LlamaIndexServer
    participant Agent
    participant Tool

    User->>LlamaIndexServer: Sends request (e.g., "1 + 1" or RAG query)
    LlamaIndexServer->>Agent: Forwards user input
    Agent->>Tool: Invokes tool (e.g., "add" or query tool)
    Tool-->>Agent: Returns result
    Agent-->>LlamaIndexServer: Returns final answer
    LlamaIndexServer-->>User: Responds with answer
Loading

Possibly related PRs

Suggested reviewers

  • marcusschiesser

Poem

In the land of servers, new examples sprout,
With numbers to add and agents about.
RAG and calculator, side by side,
TypeScript and configs, all neatly supplied.
Hop to the browser, let queries commence—
A rabbit’s delight in code’s present tense! 🐇✨


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
packages/server/examples/README.md (1)

5-13: ⚠️ Potential issue

Add instructions for the agentic RAG example
The README currently only covers running the simple workflow. To fully document this package, include steps for agentic-rag/index.ts, e.g.:

## Running the examples

```bash
export OPENAI_API_KEY=your_openai_api_key
npx tsx simple-workflow/calculator.ts
+ npx tsx agentic-rag/index.ts

Open browser


Without this, users won’t know how to launch the RAG workflow.

</blockquote></details>

</blockquote></details>

<details>
<summary>🧹 Nitpick comments (4)</summary><blockquote>

<details>
<summary>packages/server/examples/tsconfig.json (1)</summary><blockquote>

`2-11`: **TypeScript compiler options look solid**  
The config enables strict mode, ES2022 targets, and bundler resolution which suits the examples. Consider explicitly setting `"rootDir": "."` to define the project root and avoid unexpected file inclusions.  
  
```diff
--- a/packages/server/examples/tsconfig.json
+++ b/packages/server/examples/tsconfig.json
@@ compilerOptions {
+   "rootDir": ".",
packages/server/examples/agentic-rag/index.ts (1)

36-44: Handle server start errors
Calling .start() directly can silently fail. Wrap it to log errors and exit appropriately:

 new LlamaIndexServer({
   /* ... */
 }).start();
+  .catch(err => {
+    console.error("Server failed to start:", err);
+    process.exit(1);
+  });
packages/server/examples/simple-workflow/calculator.ts (2)

6-15: Well-structured calculator agent with a clear tool definition

The agent is defined with a single "add" tool that has appropriate name, description, parameter validation, and execution logic. The use of zod for type validation is a good practice.

Consider adding more mathematical operations (subtract, multiply, divide) to make this example more comprehensive for users learning the framework.


17-24: Good server configuration with helpful UI elements

The server setup correctly uses the defined agent as its workflow and provides a clear UI configuration with relevant starter questions.

Consider adding comments explaining the configuration options for newcomers to the framework. Also, since this is an example that others will run, it would be helpful to include error handling or logging when the server starts successfully.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0384268 and bd4d1a0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • packages/server/examples/README.md (1 hunks)
  • packages/server/examples/agentic-rag/index.ts (1 hunks)
  • packages/server/examples/package.json (1 hunks)
  • packages/server/examples/simple-workflow/calculator.ts (1 hunks)
  • packages/server/examples/tsconfig.json (1 hunks)
  • pnpm-workspace.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (28)
  • GitHub Check: build
  • GitHub Check: typescript (22, 3.11, ubuntu-22.04, nextjs, --llamacloud)
  • GitHub Check: typescript (22, 3.11, ubuntu-22.04, nextjs, --example-file)
  • GitHub Check: typescript (22, 3.11, ubuntu-22.04, nextjs, --no-files)
  • GitHub Check: typescript (22, 3.11, windows-latest, nextjs, --llamacloud)
  • GitHub Check: typescript (22, 3.11, windows-latest, nextjs, --example-file)
  • GitHub Check: typescript (22, 3.11, windows-latest, nextjs, --no-files)
  • GitHub Check: typescript (22, 3.11, macos-latest, nextjs, --llamacloud)
  • GitHub Check: typescript (22, 3.11, macos-latest, nextjs, --example-file)
  • GitHub Check: typescript (22, 3.11, macos-latest, nextjs, --no-files)
  • GitHub Check: typescript (20, 3.11, ubuntu-22.04, nextjs, --llamacloud)
  • GitHub Check: python (20, 3.11, ubuntu-22.04, fastapi, --llamacloud)
  • GitHub Check: typescript (20, 3.11, ubuntu-22.04, nextjs, --example-file)
  • GitHub Check: python (20, 3.11, ubuntu-22.04, fastapi, --example-file)
  • GitHub Check: typescript (20, 3.11, ubuntu-22.04, nextjs, --no-files)
  • GitHub Check: python (20, 3.11, ubuntu-22.04, fastapi, --no-files)
  • GitHub Check: typescript (20, 3.11, windows-latest, nextjs, --llamacloud)
  • GitHub Check: python (20, 3.11, windows-latest, fastapi, --llamacloud)
  • GitHub Check: typescript (20, 3.11, windows-latest, nextjs, --example-file)
  • GitHub Check: python (20, 3.11, windows-latest, fastapi, --example-file)
  • GitHub Check: typescript (20, 3.11, windows-latest, nextjs, --no-files)
  • GitHub Check: python (20, 3.11, windows-latest, fastapi, --no-files)
  • GitHub Check: typescript (20, 3.11, macos-latest, nextjs, --llamacloud)
  • GitHub Check: python (20, 3.11, macos-latest, fastapi, --llamacloud)
  • GitHub Check: typescript (20, 3.11, macos-latest, nextjs, --example-file)
  • GitHub Check: python (20, 3.11, macos-latest, fastapi, --example-file)
  • GitHub Check: typescript (20, 3.11, macos-latest, nextjs, --no-files)
  • GitHub Check: python (20, 3.11, macos-latest, fastapi, --no-files)
🔇 Additional comments (6)
pnpm-workspace.yaml (1)

1-4: Include examples package in workspace
The new "packages/server/examples" path ensures the examples package is managed by pnpm. Verify that no other workspace globs conflict with this addition.

packages/server/examples/tsconfig.json (1)

12-13: include/exclude patterns are sufficient
Including all source files and excluding node_modules/dist aligns with standard conventions for example packages.

packages/server/examples/agentic-rag/index.ts (1)

1-17: Core workflow implementation is correct
Imports, global settings, and the workflowFactory are well structured for an agentic RAG example.

packages/server/examples/package.json (1)

9-18: Dependencies pinning looks correct
Using workspace:* for internal packages and caret ranges for external ones is appropriate for this workspace.

packages/server/examples/simple-workflow/calculator.ts (2)

1-4: Appropriate imports for setting up a LlamaIndex-based agent workflow

The imports correctly bring in the necessary components from LlamaIndex packages and zod for schema validation.


1-24:

✅ Verification successful

Verify OpenAI API key requirement

Since this example uses LlamaIndex which typically requires access to language models, users might need to set environment variables.


🏁 Script executed:

#!/bin/bash
# Check if any environment variables are mentioned in the README
cd packages/server/examples
if [ -f "README.md" ]; then
  echo "Checking README.md for environment variable mentions:"
  grep -i "OPENAI\|API_KEY\|environment" README.md
else
  echo "README.md not found"
fi

Length of output: 262


Environment variable requirement confirmed

Verified that packages/server/examples/README.md already includes:

export OPENAI_API_KEY=your_openai_api_key

so the OpenAI API key requirement for the calculator example is documented.

@marcusschiesser marcusschiesser merged commit d304554 into main May 8, 2025
30 of 33 checks passed
@marcusschiesser marcusschiesser deleted the tp/add-example-folder branch May 8, 2025 10:15
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.

3 participants