-
Notifications
You must be signed in to change notification settings - Fork 437
feat:AI builds a system to add image resources to dialogues #1678
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
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Component as Main Component
participant Session as getSendSeesionProcess()
participant Resources as Resource Fetch
participant Stream as Stream Request
participant Schema as Schema Update
Component->>Session: await getSendSeesionProcess(props)
alt aiType === Builder
Session->>Resources: Fetch additional resources
Resources-->>Session: Resource URLs
Session->>Session: Construct imageStr
Session->>Session: Inject into message
end
Session->>Session: Resolve prompts from props or PROMPTS
Session-->>Component: Return prepared session data
Component->>Stream: await sendStreamRequest(...)
Stream-->>Component: Response received
alt Builder response processing
Component->>Schema: Compute new schema (JSON patches)
Schema->>Schema: setSchema(result)
Schema-->>Component: Schema persisted
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The diff involves async refactoring requiring careful verification of error handling and promise resolution, conditional Builder-specific logic necessitating mental model tracking, and new schema persistence operations. Changes are confined to a single file with clear structural intent, but the interplay between async flows and conditional branching demands focused attention. Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/plugins/robot/src/Main.vue (1)
269-271: Consider caching resource list to reduce redundant API calls.The resource list is fetched on every message send in Builder mode, even within the same session. If the resource list doesn't change frequently, consider caching it to improve performance.
Example approach:
// Add at component level (line ~220) const cachedResources = ref<string[]>([]) const resourcesFetched = ref(false) // Then in getSendSeesionProcess: if (aiType.value === AI_MODES['Builder']) { let imageStr = '' try { if (!resourcesFetched.value) { const res = await getMetaApi(META_SERVICE.Http).get('/material-center/api/resource/list') if (Array.isArray(res)) { cachedResources.value = res.map((item) => item?.resourceUrl).filter(Boolean) resourcesFetched.value = true } } imageStr = cachedResources.value.length ? `[图片资源] ${cachedResources.value}` : '' } catch (error) { console.error('Failed to fetch resources:', error) } // ... rest of the code }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/plugins/robot/src/Main.vue(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: push-check
🔇 Additional comments (3)
packages/plugins/robot/src/Main.vue (3)
189-189: LGTM!Adding
propsparameter tosetup()is correct and enables accessingprops.options?.promptson line 275.
275-277: LGTM!The prompt construction properly uses optional chaining for
props.options?.prompts, provides a fallback toPROMPTS, and correctly includes all required context (instructions, knowledge, schema, and image resources).
365-365: LGTM!Correctly awaits the now-async
getSendSeesionProcess()function, ensuring proper sequencing of session data preparation before streaming begins.
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
Bug Fixes
Improvements