Skip to content

chore: add llamaindex server package #585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Apr 28, 2025

Conversation

thucpn
Copy link
Collaborator

@thucpn thucpn commented Apr 28, 2025

  • copy llamaindex/server code
  • setup configs: lint, prettier, actions, scripts

Summary by CodeRabbit

  • New Features

    • Introduced the LlamaIndex Server package, enabling serving LlamaIndex and agent workflows as an API server with a customizable chat UI.
    • Added a comprehensive suite of reusable UI components, including chat, sidebar, forms, tables, menus, tooltips, and more.
    • Enabled dynamic rendering of event-driven UI components based on chat message annotations, supporting custom React components and error handling.
    • Integrated file upload, image preview, and cloud pipeline selection within the chat input.
    • Provided a weather tool and artifact preview within the chat interface.
    • Implemented resizable panels, responsive sidebar, and extensive customization options for the chat UI.
  • Documentation

    • Added detailed README files for the main server and UI packages, including setup instructions, feature overviews, and usage examples.
    • Updated global and package-level configuration files for TypeScript, Next.js, PostCSS, Prettier, and Tailwind CSS.
  • Chores

    • Added changelogs, configuration, and ignore files for improved development workflow and package management.
    • Updated package scripts to run commands across all packages in the monorepo.
  • Bug Fixes

    • Improved error handling and validation throughout the chat, file handling, and dynamic component rendering processes.
  • Style

    • Introduced global and component-level styles for consistent theming, dark mode, and responsive design.

@thucpn thucpn requested a review from marcusschiesser April 28, 2025 02:52
Copy link

changeset-bot bot commented Apr 28, 2025

🦋 Changeset detected

Latest commit: 348f828

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

This PR includes changesets to release 2 packages
Name Type
create-llama Patch
@llamaindex/server 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

Copy link

coderabbitai bot commented Apr 28, 2025

Warning

Rate limit exceeded

@thucpn has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 49 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 3960618 and 348f828.

⛔ Files ignored due to path filters (3)
  • packages/server/next/app/favicon.ico is excluded by !**/*.ico
  • packages/server/next/public/llama.png is excluded by !**/*.png
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (104)
  • .changeset/smooth-bees-brush.md (1 hunks)
  • README.md (1 hunks)
  • package.json (1 hunks)
  • packages/create-llama/.gitignore (1 hunks)
  • packages/create-llama/package.json (1 hunks)
  • packages/server/.gitignore (1 hunks)
  • packages/server/.prettierignore (1 hunks)
  • packages/server/CHANGELOG.md (1 hunks)
  • packages/server/README.md (1 hunks)
  • packages/server/eslint.config.mjs (1 hunks)
  • packages/server/next/.gitignore (1 hunks)
  • packages/server/next/app/components/ui/accordion.tsx (1 hunks)
  • packages/server/next/app/components/ui/alert-dialog.tsx (1 hunks)
  • packages/server/next/app/components/ui/alert.tsx (1 hunks)
  • packages/server/next/app/components/ui/aspect-ratio.tsx (1 hunks)
  • packages/server/next/app/components/ui/avatar.tsx (1 hunks)
  • packages/server/next/app/components/ui/badge.tsx (1 hunks)
  • packages/server/next/app/components/ui/breadcrumb.tsx (1 hunks)
  • packages/server/next/app/components/ui/button.tsx (1 hunks)
  • packages/server/next/app/components/ui/calendar.tsx (1 hunks)
  • packages/server/next/app/components/ui/card.tsx (1 hunks)
  • packages/server/next/app/components/ui/carousel.tsx (1 hunks)
  • packages/server/next/app/components/ui/chart.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/canvas/panel.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/canvas/preview.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/chat-avatar.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/chat-header.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/chat-injection.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/chat-input.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/chat-message-content.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/chat-messages.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/chat-section.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/chat-starter.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/custom/events/dynamic-events-errors.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/custom/events/dynamic-events.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/custom/events/error-boundary.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/custom/events/import.ts (1 hunks)
  • packages/server/next/app/components/ui/chat/custom/events/loader.ts (1 hunks)
  • packages/server/next/app/components/ui/chat/custom/events/types.ts (1 hunks)
  • packages/server/next/app/components/ui/chat/custom/llama-cloud-selector.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/custom/markdown.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/hooks/use-copy-to-clipboard.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/tools/chat-tools.tsx (1 hunks)
  • packages/server/next/app/components/ui/chat/tools/weather-card.tsx (1 hunks)
  • packages/server/next/app/components/ui/checkbox.tsx (1 hunks)
  • packages/server/next/app/components/ui/collapsible.tsx (1 hunks)
  • packages/server/next/app/components/ui/command.tsx (1 hunks)
  • packages/server/next/app/components/ui/context-menu.tsx (1 hunks)
  • packages/server/next/app/components/ui/dialog.tsx (1 hunks)
  • packages/server/next/app/components/ui/drawer.tsx (1 hunks)
  • packages/server/next/app/components/ui/dropdown-menu.tsx (1 hunks)
  • packages/server/next/app/components/ui/form.tsx (1 hunks)
  • packages/server/next/app/components/ui/hooks/use-mobile.ts (1 hunks)
  • packages/server/next/app/components/ui/hover-card.tsx (1 hunks)
  • packages/server/next/app/components/ui/input-otp.tsx (1 hunks)
  • packages/server/next/app/components/ui/input.tsx (1 hunks)
  • packages/server/next/app/components/ui/label.tsx (1 hunks)
  • packages/server/next/app/components/ui/lib/utils.ts (1 hunks)
  • packages/server/next/app/components/ui/menubar.tsx (1 hunks)
  • packages/server/next/app/components/ui/navigation-menu.tsx (1 hunks)
  • packages/server/next/app/components/ui/pagination.tsx (1 hunks)
  • packages/server/next/app/components/ui/popover.tsx (1 hunks)
  • packages/server/next/app/components/ui/progress.tsx (1 hunks)
  • packages/server/next/app/components/ui/radio-group.tsx (1 hunks)
  • packages/server/next/app/components/ui/resizable.tsx (1 hunks)
  • packages/server/next/app/components/ui/scroll-area.tsx (1 hunks)
  • packages/server/next/app/components/ui/select.tsx (1 hunks)
  • packages/server/next/app/components/ui/separator.tsx (1 hunks)
  • packages/server/next/app/components/ui/sheet.tsx (1 hunks)
  • packages/server/next/app/components/ui/sidebar.tsx (1 hunks)
  • packages/server/next/app/components/ui/skeleton.tsx (1 hunks)
  • packages/server/next/app/components/ui/slider.tsx (1 hunks)
  • packages/server/next/app/components/ui/sonner.tsx (1 hunks)
  • packages/server/next/app/components/ui/switch.tsx (1 hunks)
  • packages/server/next/app/components/ui/table.tsx (1 hunks)
  • packages/server/next/app/components/ui/tabs.tsx (1 hunks)
  • packages/server/next/app/components/ui/textarea.tsx (1 hunks)
  • packages/server/next/app/components/ui/toggle-group.tsx (1 hunks)
  • packages/server/next/app/components/ui/toggle.tsx (1 hunks)
  • packages/server/next/app/components/ui/tooltip.tsx (1 hunks)
  • packages/server/next/app/globals.css (1 hunks)
  • packages/server/next/app/layout.tsx (1 hunks)
  • packages/server/next/app/page.tsx (1 hunks)
  • packages/server/next/components.json (1 hunks)
  • packages/server/next/next.config.ts (1 hunks)
  • packages/server/next/postcss.config.js (1 hunks)
  • packages/server/next/public/config.js (1 hunks)
  • packages/server/next/tsconfig.json (1 hunks)
  • packages/server/package.json (1 hunks)
  • packages/server/prettier.config.mjs (1 hunks)
  • packages/server/src/events.ts (1 hunks)
  • packages/server/src/handlers/chat.ts (1 hunks)
  • packages/server/src/handlers/cloud.ts (1 hunks)
  • packages/server/src/handlers/components.ts (1 hunks)
  • packages/server/src/handlers/files.ts (1 hunks)
  • packages/server/src/index.ts (1 hunks)
  • packages/server/src/server.ts (1 hunks)
  • packages/server/src/types.ts (1 hunks)
  • packages/server/src/utils/file.ts (1 hunks)
  • packages/server/src/utils/gen-ui.ts (1 hunks)
  • packages/server/src/utils/request.ts (1 hunks)
  • packages/server/src/utils/suggestion.ts (1 hunks)
  • packages/server/src/utils/workflow.ts (1 hunks)
  • packages/server/tsconfig.json (1 hunks)

Walkthrough

This change introduces the new @llamaindex/server package, providing a Next.js-based server for serving LlamaIndex and agent workflows as an API server with an optional chat UI. The update includes all necessary server infrastructure, API handlers for chat, files, components, and cloud configuration, as well as a comprehensive suite of UI components and utilities for chat, forms, and layout. TypeScript configuration, linting, formatting, and build scripts are established. Documentation, changelogs, and configuration files are added for both the package and its Next.js subproject. The server supports extensibility via a components directory and exposes endpoints for chat, static files, and custom UI components.

Changes

File(s) / Path(s) Change Summary
.changeset/smooth-bees-brush.md, packages/server/CHANGELOG.md, packages/server/package.json Added changeset, changelog, and package manifest for @llamaindex/server with scripts, dependencies, and version history.
README.md, packages/server/README.md Added documentation for the main repo and the new server package, including usage, features, and guides.
package.json Updated scripts to remove --filter create-llama, making them apply to all packages.
packages/server/.gitignore, packages/server/.prettierignore, packages/server/prettier.config.mjs, packages/server/eslint.config.mjs Added ignore and configuration files for Git, Prettier, and ESLint in the server package.
packages/server/tsconfig.json, packages/server/next/tsconfig.json Added TypeScript configuration for both server and Next.js subproject.
packages/server/next/postcss.config.js, packages/server/next/components.json, packages/server/next/next.config.ts Added PostCSS, component, and Next.js configuration files for the Next.js app.
packages/server/next/public/config.js Added global config for client-side settings (API endpoints, app title, starter questions).
packages/server/next/app/globals.css Added global CSS with Tailwind, theme variables, and base styles.
packages/server/next/app/layout.tsx, packages/server/next/app/page.tsx Added Next.js root layout and main page, dynamically loading the chat section.
packages/server/next/app/components/ui/**/* Introduced a comprehensive set of UI components (accordion, alert, avatar, badge, button, calendar, card, carousel, chat, etc.) for the chat UI and general layout, built with React, Radix UI, and Tailwind.
packages/server/next/app/components/ui/chat/**/* Added chat UI components, including input, messages, avatars, dynamic events, error boundaries, markdown rendering, tool annotations, and LlamaCloud selector.
packages/server/next/app/components/ui/lib/utils.ts, hooks/use-mobile.ts Added utility functions for class name merging, config retrieval, and mobile detection.
packages/server/next/app/components/ui/table.tsx, form.tsx, sidebar.tsx, etc. Added table, form, sidebar, and other layout components.
packages/server/src/events.ts Defined event types, artifact schemas, and extraction utilities for workflow events and artifacts.
packages/server/src/handlers/chat.ts, cloud.ts, components.ts, files.ts Implemented HTTP handlers for chat, cloud config, component fetching, and file serving.
packages/server/src/index.ts Centralized exports for server modules and utilities.
packages/server/src/server.ts Implemented LlamaIndexServer class to run Next.js server with API endpoints and dynamic config.
packages/server/src/types.ts Defined types for workflows, factories, UI config, and server options.
packages/server/src/utils/file.ts, gen-ui.ts, request.ts, suggestion.ts, workflow.ts Added utility modules for file downloading, UI generation, HTTP handling, suggestion generation, and workflow execution/streaming.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant NextServer
    participant APIHandler
    participant Workflow

    User->>Browser: Interacts with Chat UI
    Browser->>NextServer: POST /api/chat (with messages)
    NextServer->>APIHandler: handleChat(req, res, workflowFactory)
    APIHandler->>Workflow: Run workflow with input & history
    Workflow-->>APIHandler: Stream response chunks/events
    APIHandler-->>NextServer: Pipe stream to response
    NextServer-->>Browser: Stream chat response
    Browser->>User: Display chat output
Loading

Possibly related PRs

Suggested reviewers

  • marcusschiesser

Poem

🐇
In a warren of code, a server was spun,
With chatbots and workflows, the work has begun.
Next.js and Tailwind, a UI parade,
Components and handlers, all neatly arrayed.
From artifacts, events, to chat streams anew—
This rabbit is happy to hop in with you!
🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

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
Collaborator

@marcusschiesser marcusschiesser left a comment

Choose a reason for hiding this comment

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

what about the github actions for the release?

@@ -21,12 +21,12 @@
"new-version": "pnpm -r build && changeset version",
"release": "pnpm -r build && changeset publish",
"release-snapshot": "pnpm -r build && changeset publish --tag snapshot",
"build": "pnpm -r --filter create-llama build",
"e2e": "pnpm -r --filter create-llama e2e",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TODO: add e2e tests for server package

@thucpn thucpn marked this pull request as ready for review April 28, 2025 07:06
@thucpn thucpn requested a review from marcusschiesser April 28, 2025 07:06
@marcusschiesser marcusschiesser merged commit 8fe5fc2 into main Apr 28, 2025
33 checks passed
@marcusschiesser marcusschiesser deleted the tp/add-llamaindex-server-package branch April 28, 2025 07:37
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