Skip to content

feat: useMessage#5

Merged
gene9831 merged 2 commits intodevelopfrom
feat/use-data
Apr 15, 2025
Merged

feat: useMessage#5
gene9831 merged 2 commits intodevelopfrom
feat/use-data

Conversation

@hexqi
Copy link
Copy Markdown
Contributor

@hexqi hexqi commented Apr 11, 2025

Summary by CodeRabbit

  • New Features

    • Introduced an enhanced messaging hook that supports both standard and streaming responses with robust state management, retry, and abort capabilities.
    • Added a retry button for assistant messages in the demo interface to resend requests easily.
  • Documentation

    • Updated documentation to clearly detail messaging functionality, configuration options, and response handling.
  • Refactor

    • Streamlined the demo interface by consolidating message state indicators for loading and response management, simplifying user interactions.
    • Replaced manual message handling in the demo with the new messaging hook for cleaner and more maintainable code.
  • Chore

    • Updated the package to ensure compatibility with Vue version 3.0.0 or higher.
    • Added new scripts for improved development workflow and parallel execution of tasks.
    • Configured the development server to automatically open the browser on start.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 11, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces detailed documentation and type definitions for the useMessage composable, along with the new file that implements it. The changes include adding new interfaces in the README and in the composable file to manage message options, state, and return values. Additionally, there is an update to the peer dependency in package.json to require Vue 3 or higher, and new export statements to re-export functionalities for easier imports. The TinyRobotDemo component has been refactored to simplify variable naming and state management by integrating the new composable. The demo development workflow is enhanced by running multiple tasks concurrently, and the Vite server is configured to open the browser automatically on start.

Changes

File(s) Change Summary
packages/ai-adapter/README.md Added new documentation section for useMessage, detailing interfaces: UseMessageOptions, UseMessageReturn, MessageState, and enum STATUS.
packages/ai-adapter/package.json Added peer dependency "vue": ">=3.0.0".
packages/ai-adapter/src/index.ts
packages/ai-adapter/src/vue/index.ts
Added new export statements: export * from './vue' and export * from './useMessage' respectively.
packages/ai-adapter/src/vue/useMessage.ts Added new composable useMessage with enums, interfaces, and functions to manage chat messages, states, streaming, aborting, retrying, clearing, and adding messages.
packages/demo/src/views/tinyrobot/TinyRobotDemo.vue Refactored to use useMessage composable: removed manual state and methods, renamed useStreamResponse to useStream, unified loading states under messageState, added retry button, updated initial message handling, and removed manual abort logic. Added CSS for retry button styling.
package.json Updated dev:demo script to run multiple commands concurrently using concurrently; added new script serve:frontend; added concurrently as a dev dependency.
packages/demo/vite.config.ts Added server: { open: true } configuration to automatically open browser on server start.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Demo as TinyRobotDemo
    participant UseMsg as useMessage
    participant API as AI Client

    User->>Demo: Enter message
    Demo->>UseMsg: sendMessage(userMsg)
    UseMsg->>API: Initiate chat/streamChat request
    API-->>UseMsg: Return response (or error)
    UseMsg->>Demo: Update message state and messages
    Demo->>User: Display updated chat
Loading
sequenceDiagram
    participant User
    participant Demo as TinyRobotDemo
    participant UseMsg as useMessage
    participant API as AI Client

    User->>Demo: Click abort
    Demo->>UseMsg: abortRequest()
    UseMsg->>API: Cancel ongoing request
    API-->>UseMsg: Confirm abort
    UseMsg->>Demo: Update state (aborted)
Loading

Possibly related PRs

  • feat: add ai-mocker ai-adapter and chat-demo #3: The changes in the main PR are related to the retrieved PR as both involve modifications to the packages/ai-adapter/src/vue/useMessage.ts file, specifically with the introduction of the UseMessageOptions, UseMessageReturn, and MessageState interfaces, which are also referenced in the context of the AI client functionality.

Poem

In fields of code I hop with cheer,
New interfaces and exports now appear.
A composable sprouted to manage our chat,
With state and options—imagine that!
I’m a CodeRabbit dancing through each code line, so dear. 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/ai-adapter/src/vue/useMessage.ts

Oops! Something went wrong! :(

ESLint: 9.24.0

Error: The 'jiti' library is required for loading TypeScript configuration files. Make sure to install it.
at /node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/config/config-loader.js:144:9
at async loadTypeScriptConfigFileWithJiti (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/config/config-loader.js:143:25)
at async loadConfigFile (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/config/config-loader.js:261:11)
at async ConfigLoader.calculateConfigArray (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/config/config-loader.js:584:23)
at async #calculateConfigArray (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/config/config-loader.js:765:23)
at async /node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/eslint/eslint.js:746:6
at async Promise.all (index 0)
at async ESLint.lintFiles (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/eslint/eslint.js:743:19)
at async Object.execute (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/cli.js:638:14)
at async main (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/bin/eslint.js:160:19)

packages/demo/src/views/tinyrobot/TinyRobotDemo.vue

Oops! Something went wrong! :(

ESLint: 9.24.0

Error: The 'jiti' library is required for loading TypeScript configuration files. Make sure to install it.
at /node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/config/config-loader.js:144:9
at async loadTypeScriptConfigFileWithJiti (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/config/config-loader.js:143:25)
at async loadConfigFile (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/config/config-loader.js:261:11)
at async ConfigLoader.calculateConfigArray (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/config/config-loader.js:584:23)
at async #calculateConfigArray (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/config/config-loader.js:765:23)
at async /node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/eslint/eslint.js:746:6
at async Promise.all (index 0)
at async ESLint.lintFiles (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/eslint/eslint.js:743:19)
at async Object.execute (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/lib/cli.js:638:14)
at async main (/node_modules/.pnpm/eslint@9.24.0/node_modules/eslint/bin/eslint.js:160:19)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c4cfc0d and 75c7b0b.

📒 Files selected for processing (3)
  • packages/ai-adapter/README.md (1 hunks)
  • packages/ai-adapter/src/vue/useMessage.ts (1 hunks)
  • packages/demo/src/views/tinyrobot/TinyRobotDemo.vue (5 hunks)

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@hexqi hexqi requested a review from gene9831 April 11, 2025 02:00
Comment thread packages/ai-adapter/src/vue/useMessage.ts
@gene9831 gene9831 merged commit 10fb3a6 into develop Apr 15, 2025
@hexqi hexqi deleted the feat/use-data branch July 4, 2025 02:07
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