Skip to content

Conversation

@zzcr
Copy link
Member

@zzcr zzcr commented Jul 28, 2025

Summary by CodeRabbit

  • New Features

    • Added a modal dialog prompting users to input LLM URL and API key if not set, with validation and local storage support.
    • Enhanced the app to automatically load LLM configuration from environment variables or local cache, prioritizing environment variables.
  • Documentation

    • Updated the README to clarify LLM configuration methods and added a screenshot of the input interface.
  • Style

    • Improved user experience by enforcing required input before proceeding.
  • Chores

    • Updated a dependency version for improved compatibility.
    • Adjusted environment variable placeholder in the configuration file.

@coderabbitai
Copy link

coderabbitai bot commented Jul 28, 2025

Walkthrough

The changes implement a dual LLM configuration mechanism, allowing users to provide LLM URL and API key through either environment variables or a modal input form, with environment variables taking precedence. Supporting logic, UI, and documentation were updated accordingly, including new utility exports, Vue component declarations, and dependency updates.

Changes

Cohort / File(s) Change Summary
LLM Configuration UI & Logic
docs/src/App.vue
Added a modal dialog with a form to collect LLM URL and API key if not set in environment or local storage; manages state, validation, persistence, and reload logic.
LLM Configuration Utilities
docs/src/composable/utils.ts
Added isEnvLLMDefined and isLocalLLMDefined exports to check for LLM config presence; changed $local and $session export style.
LLM Provider Logic
docs/src/composable/AgentModelProvider.ts
Refactored to use new utility functions for LLM config precedence (env over local); minor UI string tweak and whitespace cleanup.
Vue Component Declarations
docs/components.d.ts
Registered TinyDialogBox, TinyForm, and TinyFormItem as global Vue components.
Documentation
README.md
Expanded instructions to clarify dual configuration methods; added screenshot of the LLM input interface.
Environment Example
docs/.env
Changed LLM API key placeholder to an empty string.
Dependency Update
docs/package.json
Updated @opentiny/next-sdk dependency version from alpha.2 to alpha.5.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App (Vue)
    participant LocalStorage
    participant EnvVars

    User->>App (Vue): Open app
    App (Vue)->>EnvVars: Check for LLM config in env
    alt Env config found
        App (Vue)-->>User: App loads with env config
    else Env config not found
        App (Vue)->>LocalStorage: Check for LLM config in local storage
        alt Local storage config found
            App (Vue)-->>User: App loads with local config
        else No config found
            App (Vue)-->>User: Show modal dialog for LLM input
            User->>App (Vue): Enter LLM URL & API key, click Save
            App (Vue)->>LocalStorage: Save config
            App (Vue)-->>User: Reload app with new config
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

A rabbit hops, with code anew,
Now LLM secrets come from two!
If env is shy, a prompt appears—
Just type it in, no need for fears.
With forms and checks, the flow is neat,
Hooray for code that can't be beat!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 e0c79b3 and e430578.

📒 Files selected for processing (1)
  • README.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch zzc/feat-local-llm-0728

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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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 generate unit tests to generate unit tests for 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.

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.

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: 0

🧹 Nitpick comments (3)
docs/src/composable/utils.ts (1)

22-23: Good implementation of configuration detection logic.

The boolean constants correctly implement the dual configuration approach. The logic properly checks for both required fields (URL and API key) in each configuration source.

Consider adding JSDoc comments to document the purpose and behavior of these constants:

+/**
+ * 检查是否通过环境变量定义了LLM配置
+ * 需要同时设置 VITE_LLM_API_KEY 和 VITE_LLM_URL
+ */
 export const isEnvLLMDefined = Boolean(import.meta.env.VITE_LLM_API_KEY && import.meta.env.VITE_LLM_URL)
+/**
+ * 检查是否通过本地存储定义了LLM配置
+ * 需要同时设置 llmUrl 和 llmApiKey
+ */
 export const isLocalLLMDefined = Boolean($local.llmUrl && $local.llmApiKey)
docs/src/App.vue (2)

13-37: Well-structured modal dialog implementation.

The modal dialog properly prevents users from bypassing the configuration requirement. Good use of form validation and required field rules.

Consider enhancing the URL validation to ensure proper format:

-<tiny-form-item label="LLM URL" prop="llmUrl" :rules="{ required: true, messages: '必填', trigger: 'blur' }">
+<tiny-form-item label="LLM URL" prop="llmUrl" :rules="[
+  { required: true, message: '必填', trigger: 'blur' },
+  { type: 'url', message: '请输入有效的URL格式', trigger: 'blur' }
+]">

55-62: Consider improving user experience in the submit handler.

The current implementation works but could be enhanced for better UX:

  1. Add error handling for validation failures
  2. Provide user feedback during save operation
  3. Consider a more graceful alternative to window.location.reload()
 const submit = () => {
-  formRef.value.validate().then(() => {
+  formRef.value.validate().then(() => {
+    // Add loading state here if needed
     $local.llmUrl = createData.llmUrl
     $local.llmApiKey = createData.llmApiKey
     boxVisibility.value = false
-    window.location.reload()
+    // Consider using router navigation or reactive updates instead of reload
+    window.location.reload()
-  })
+  }).catch((error) => {
+    // Handle validation errors
+    console.error('表单验证失败:', error)
+  })
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d3e78e4 and e0c79b3.

⛔ Files ignored due to path filters (1)
  • docs/public/llm.png is excluded by !**/*.png
📒 Files selected for processing (7)
  • README.md (1 hunks)
  • docs/.env (1 hunks)
  • docs/components.d.ts (1 hunks)
  • docs/package.json (1 hunks)
  • docs/src/App.vue (2 hunks)
  • docs/src/composable/AgentModelProvider.ts (3 hunks)
  • docs/src/composable/utils.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
docs/src/composable/AgentModelProvider.ts (1)
docs/src/composable/utils.ts (2)
  • isEnvLLMDefined (22-22)
  • $local (12-12)
🔇 Additional comments (10)
docs/.env (1)

1-1: LGTM! Environment variable correctly cleared for dual-configuration support.

This change properly implements the dual-configuration mechanism by clearing the placeholder value, allowing the application to detect when environment variables are not set and prompt users for LLM configuration via the modal dialog.

docs/components.d.ts (1)

15-17: LGTM! New component declarations properly added for modal dialog functionality.

The TinyDialogBox, TinyForm, and TinyFormItem components are correctly declared following the established pattern and are necessary for implementing the LLM configuration modal dialog.

docs/package.json (1)

19-19: Ensure compatibility with @opentiny/next-sdk 0.0.1-alpha.5

Ran npm view @opentiny/next-sdk@0.0.1-alpha.5:

  • version: 0.0.1-alpha.5
  • deprecated: null
  • engines: null

All alpha versions (alpha.1 through alpha.5) are published with no deprecation warnings or engine requirements. Before merging, please:

  • Review the release notes or changelog for any breaking changes.
  • Verify your test suite covers the new UI components introduced in alpha.5.
  • Confirm there are no new security advisories in your CI or npm audit reports.

File for review:

  • docs/package.json (line 19)
README.md (1)

47-52: Excellent documentation update for the dual-configuration feature.

The documentation clearly explains both configuration methods and establishes the priority system (environment variables > local cache). The inclusion of the screenshot reference enhances user understanding of the feature.

docs/src/composable/AgentModelProvider.ts (3)

8-8: LGTM! Necessary imports added for dual-configuration support.

The new utility imports are required for implementing the conditional LLM configuration logic.


39-39: Good UX improvement with ellipsis for loading state.

Adding ellipsis to the tool call status message provides better visual indication of an ongoing process.


60-61: All checks passed: dual-configuration logic and storage utilities verified

The isEnvLLMDefined flag and $local proxy in storage.ts correctly detect, parse, and fall back to empty strings when values aren’t present. No further changes required—ready to merge.

docs/src/composable/utils.ts (1)

10-12: LGTM: Clean export pattern refactoring.

The import-then-export pattern maintains the same API while improving code organization.

docs/src/App.vue (2)

46-53: Good reactive state setup with proper fallbacks.

The form data initialization correctly prioritizes local storage over environment variables, which aligns with the expected behavior.


64-66: Correct logic for showing the configuration dialog.

The condition properly checks both environment variables and local storage to determine when user input is needed.

@kagol kagol merged commit 3b87a2a into main Jul 28, 2025
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