Skip to content

Add AI-driven comment extraction for links#142

Merged
ruibaby merged 24 commits into
mainfrom
ai
Jul 7, 2026
Merged

Add AI-driven comment extraction for links#142
ruibaby merged 24 commits into
mainfrom
ai

Conversation

@ruibaby

@ruibaby ruibaby commented Jun 3, 2026

Copy link
Copy Markdown
Member

This PR adapts the plugin to the updated ai-foundation API and improves the AI-driven comment extraction UI.

Changes

API compatibility:

  • Remove the bundled/local AI Foundation API JAR and depend on run.halo.aifoundation:api:1.0.0-SNAPSHOT from the Sonatype snapshots repository
  • Update AiModelService::defaultLanguageModel::languageModel (method renamed in the new API)

Optional dependency:

  • Make ai-foundation an optional dependency (ai-foundation?: "*") in plugin.yaml
  • Add AI Foundation as a Halo Store recommended app via store.halo.run/recommended-apps
  • Split AI endpoints so the always-loaded status/recent-comments endpoint has no ai-foundation imports, while LinkAiExtractEndpoint imports ai-foundation classes and is skipped when ai-foundation is missing

AI extraction enhancements:

  • Add rssUrl field to LinkCommentExtractionResult for RSS feed extraction
  • Update prompts to ask AI for RSS URL extraction
  • Apply extracted rssUrl to RSS feed URLs automatically in the UI

UI improvements:

  • Card-style container with border/shadow instead of gray background
  • Use an icon-only close button instead of text "收起"
  • Replace radio buttons with dot indicators for comment selection
  • Use utils.date.timeAgo for relative time display
  • Add loading spinner and empty state for comment list
  • Set the comment textarea to 3 rows with improved focus behavior
  • Update description copy to mention RSS extraction

ruibaby added 2 commits May 29, 2026 21:58
Introduce AI-based extraction of friend-link info from comments: add LinkAiEndpoint (console routes for listing recent comments and extracting link data), DTOs LinkCommentDTO and LinkCommentAnalysisResult, and console client + UI wiring (api/index.ts and LinkForm.vue) to fetch comments and perform AI extraction. Add plugin documentation (plugin-ai-foundation-doc.md) describing the AI Foundation SDK usage, update plugin.yaml to require the ai-foundation plugin, and include a local api snapshot (api-1.0.0-SNAPSHOT.jar) referenced in build.gradle for compile/test.
- Replace api-1.0.0-SNAPSHOT.jar with api-0.0.0-7e636df07435.jar
- Update AiModelService::defaultLanguageModel to ::languageModel
- Make ai-foundation an optional dependency (ai-foundation?: *)
- Split LinkAiEndpoint into LinkAiEndpoint (recent-comments) and
  LinkAiExtractEndpoint (ai-extract) to avoid class loading failures
  when ai-foundation is not installed
- Add rssUrl field to LinkCommentAnalysisResult for RSS feed extraction
- Update prompts to include RSS URL extraction
- Improve AI extraction UI: card-style container, relative time display,
  loading/empty states, better comment list styling
- Use utils.date.timeAgo from @halo-dev/ui-shared for time formatting
- Apply extracted rssUrl to RSS feed URLs automatically
@ruibaby ruibaby changed the title feat: adapt to ai-foundation API changes and improve AI extraction UI Adapt ai-foundation integration to new API and improve AI extraction UI Jun 3, 2026
@ruibaby
ruibaby marked this pull request as ready for review June 3, 2026 14:41
@ruibaby ruibaby changed the title Adapt ai-foundation integration to new API and improve AI extraction UI Add AI-driven comment extraction for links Jun 3, 2026
…is available

- Add AiFoundationAvailableCondition to check ai-foundation presence
  via Class.forName before Spring attempts to load the bean
- Apply @conditional to LinkAiExtractEndpoint so Spring skips it
  gracefully when ai-foundation classes are missing
- Add rssUrl to handwritten LinkCommentAnalysisResult interface
ruibaby added 21 commits June 3, 2026 22:58
- Replace handwritten LinkCommentDTO interface with generated version
- Replace handwritten listRecentComments wrapper with generated
  ConsoleApiLinkHaloRunV1alpha1LinkAiApi
- Keep handwritten extractFromComment wrapper since the endpoint is
  conditionally registered and not present in OpenAPI docs
- Fix IconCloseLine → IconClose (correct Halo component export)
- Fix selectedCommentName type to accept undefined from generated DTO
Add a new AI extraction endpoint (/apis/.../links/-/ai-extract) to the OpenAPI spec and generated TypeScript client: new LinkCommentAnalysisResult model, API methods, request types, and update .openapi-generator file list. Update server URL/BASE_PATH from localhost:51338 to localhost:8091 and enable useExistingServer in the Gradle OpenAPI plugin; bump run.halo.plugin.devtools to 0.8.0. Also make LinkDetailDTO.title required.
Replace custom axios extract helper with the generated AI client and clean up related types/imports. api/index.ts: remove AxiosResponse import, delete custom extractFromComment and LinkCommentAnalysisResult, and export the generated clients. LinkForm.vue: import types from the generated API, call linkAiApiClient.ai.extractLinkFromComment({ body }) instead of the removed helper, remove the previous catch error toast, and apply minor formatting/import reordering changes.
Delete the Halo AI Foundation SDK usage guide (plugin-ai-foundation-doc.md). The file containing detailed instructions for integrating and using AiModelService, language/embedding models, streaming, structured outputs, tools, timeouts, and provider options was removed.
Add LinkAiExtract.vue to encapsulate the AI-driven comment extraction UI and logic (fetch recent comments, select/edit comment, call AI extract API, emit result). Refactor LinkForm.vue to use the new component for new links (isNew computed) and remove duplicated AI extraction code and unused imports; rename the internal handler to applyAiExtractedResult and wire it to the component's @extract event. This centralizes AI extraction behavior and simplifies the link form.
Introduce LinkCommentExtractRequest to support AI-based friend-link extraction: add Java DTO (src/main/java/.../LinkCommentExtractRequest.java) and TypeScript model (console/src/api/generated/models/link-comment-extract-request.ts), update OpenAPI spec (api-docs/openapi/v3_0/linksV1alpha1Api.json) and regenerate client artifacts (console/src/api/generated/...), and wire the new model into the console UI and backend (updated LinkAiExtract.vue and LinkAiExtractEndpoint.java). These changes enable sending structured JSON requests to the AI extraction API and keep generated client code in sync with the spec.
Reformat the OpenAPI spec for the links API and update generated TypeScript models.

- api-docs/openapi/v3_0/linksV1alpha1Api.json: regenerated/serialized with consistent spacing and content-type normalization (many responses/request bodies now use "*/*"); primarily formatting/serialization changes.
- console/src/api/generated/models/link-comment-extract-request.ts and console/src/api/generated/models/link-detail-dto.ts: regenerated TypeScript models from the updated spec.

These changes are codegen/formatting updates to keep the docs and client models in sync.
Normalize whitespace and trailing newlines in generated OpenAPI artifacts. Minor formatting changes applied to api-docs/openapi/v3_0/linksV1alpha1Api.json and generated TypeScript files under console/src/api/generated (API and model files) — mainly JSDoc blank-line spacing and EOF newlines. No functional or behavioral changes.
Remove the bundled api-0.0.0-*.jar from the repo and update build.gradle to pull the API from a Maven snapshot repository instead of a local file. Adds the Sonatype snapshots repository and replaces file-based compileOnly/testImplementation entries with 'run.halo.aifoundation:api:1.0.0-SNAPSHOT'. Also fixes EOF newline in build.gradle. This avoids committing the binary and uses the published snapshot artifact.
Introduce AI-assisted link extraction support: add GET /links/-/ai-status endpoint and LinkAiFeatureStatus schema, update generated API client and models. Add frontend changes to LinkAiExtract and LinkForm to display plain-text comment content, conditionally show AI extraction UI based on runtime status, and use FormKit for editing; include comment-content utility with tests. On the server add LinkAiSettings, LinkAiFeatureStatus DTO, LinkAiSettingsFetcher, wire settings checks into Ai endpoints and extraction flow to respect configured model and feature toggles. Add settings.yaml UI schema and unit tests for settings fetcher and extraction endpoint behavior.
Upgrade halo plugin version from 2.24 to 2.25.2. Replace the custom AiModelSelector entry in settings.yaml with a FormKit aiModelSelector and refactor its configuration: set modelType to "language", keep clearable true, map name/key to modelName, and preserve placeholder/help text. This migrates the settings to the new form component shape.
Add a new metadata annotation `store.halo.run/recommended-apps` pointing to `app-acslk9nu`, and include an inline comment linking to the AI Foundation app. This surfaces a recommended Halo store app for PluginLinks.
Rename AI comment analysis/extract types and endpoints to use "extraction" terminology, update generated client and model names, and adjust API paths and operation IDs (/ai-extract -> /extract-from-comment, getAiStatus -> getLinkAiFeatureStatus, listRecentComments -> listRecentLinkComments). Add AiFoundationAvailability utility and use it in the condition to avoid duplicated Class.forName logic. Improve error handling and logging for AI failures, add URL validation and user warnings when AI-provided URLs are invalid, and update related Vue components/utilities. Bump platform/plugin requirement to 2.25.0 and update build.gradle and plugin.yaml. Update and add unit tests to reflect the renames and new behaviors.
Remove the 'approved' filter from the recent comments endpoint so it now lists the 10 most recent comments regardless of approval status. Update the OpenAPI spec and generated TypeScript client comments to match the new behavior, and simplify the Java endpoint ListOptions construction (also removing the now-unused import).
Pass explicit mode ("create"/"edit") from LinkCreationModal and LinkEditingModal to LinkForm. LinkForm gains an optional mode prop and updates its isNew computed to prefer mode when provided, falling back to absence of name. This fixes incorrect new/edit detection when the creation modal provided an empty formState object.
# Conflicts:
#	build.gradle
#	src/main/resources/plugin.yaml
Remove the Sonatype snapshots repository and upgrade aifoundation dependency from 1.0.0-SNAPSHOT to 1.0.0-beta.4, using the stable release instead of snapshots.
@ruibaby
ruibaby merged commit 6b5cec8 into main Jul 7, 2026
1 check passed
@ruibaby
ruibaby deleted the ai branch July 7, 2026 06:51
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.

1 participant