feat(knowledge): URL・文章・画像から curated ナレッジの下書きを作って保存する - #1123
Open
owk-owk130 wants to merge 6 commits into
Open
Conversation
POST /admin/knowledge/curated-draft を multipart で呼ぶ draftCurated を knowledge repository に足し、toFormData を 配列フィールド対応にする。変換できる MIME 種別と下書きの 件数上限は server と web で共有する定数に置く。 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AYsHuZj1hWRdK1hieBG5YU
POST /admin/knowledge/curated-draft を追加する。URL は fetch して HTML をテキスト化(charset は Content-Type と meta から判定、 X の投稿は公開 oEmbed)、画像と PDF は既存の converter で読み、 貼り付けテキストと合わせて 1 つの資料束にする。読めなかった資料は 理由付きで返し、全部読めないときだけ 422 にする。 資料は structuredOutput の drafter agent に渡し、#1083 の curated frontmatter(source_type / source_authority / verified_at / url)で Markdown を組み立てて返す。R2 には書かず、保存は既存の PUT /admin/knowledge/files/{key} に任せる。 LLM usage に curated-draft を追加し knowledge-base 区分で集計する。 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AYsHuZj1hWRdK1hieBG5YU
「URL から作る」「文章から作る」「画像・PDF から作る」のタブで 資料を渡し、下書き API の結果をタイトルと本文の形で確認・修正して 保存する。URL はチップ入力で複数貼れる。frontmatter は画面に出さず、 保存先の slug は自動で決めて必要なときだけ変更する。 ファイル一覧では curated/ 配下だけに編集ボタンを出し、既存の FileEditor で追記できるようにする。 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AYsHuZj1hWRdK1hieBG5YU
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AYsHuZj1hWRdK1hieBG5YU
Contributor
Coverage Report for server
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
Coverage Report for web
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
Coverage Report for shared
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
Contributor
Coverage Report for widget
File CoverageNo changed files found. |
git 管理の基本ナレッジ約 329 件に管理画面から追加した curated が 埋もれていたので、「追加したナレッジ」を既定タブにして分ける。 削除ボタンは curated/ 配下と、画像・PDF 変換で入った元ファイル付きの 行にだけ出し、knowledge:upload で戻ってしまう基本ナレッジからは外す。 一覧は 70dvh で収めてスクロールさせ、表のヘッダーは固定する。 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YZeugZ89XV3Vdh59ELCiXS
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YZeugZ89XV3Vdh59ELCiXS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
curated/<slug>.mdとして保存するPOST /admin/knowledge/curated-draftを追加する(R2 には書かない。保存は既存のPUT /admin/knowledge/files/{key})curated/配下だけに編集ボタンを出し、既存の FileEditor で追記できるようにする主な変更内容
server
lib/html-to-text.ts: 依存追加なしの HTML → テキスト化。charset は Content-Type と<meta charset>から判定してTextDecoderでデコード。title/og:title/og:descriptionも拾うlib/x-post.ts: X の個別投稿は公開 oEmbed(publish.x.com/oembed)で本文を取るservices/knowledge/curated-draft.ts: URL fetch(5MB 上限をストリームで即時判定、15 秒タイムアウト、ログインページへの転送は除外)、PDF/画像は既存convertToMarkdown、貼り付けテキストを 1 つの資料束にして drafter agent に structuredOutput で渡す。frontmatter は feat(knowledge): curated 区分を新設し検証用ナレッジを追加 #1083 の curated 契約(source_type: curated/source_authority: 2/verified_at/url)。urlは入力 1 件目で、読めなくても情報源に載せる。読めなかった資料は理由付きで返し、全部読めないときだけ 422mastra/agents/curated-drafter-agent.ts: 資料に無いことは書かない・自分の知識で補わない・資料が短ければ短いまま、の指示curated-draftを追加し、コスト区分は knowledge-baseopenapi-errorsに 422 を追加shared
constants/knowledge.ts: 変換できる MIME 種別と件数上限(URL 10・ファイル 5・合計 20MB)を server / web で共有knowledge-repository.draftCurated(multipart)、toFormDataの配列対応、CuratedDraft/CuratedDraftRequest型web
CuratedComposer: 「URL から作る」「文章から作る」「画像・PDF から作る」の排他タブ。URL はチップ入力(貼り付けで即追加、複数可)、画像はドロップ / 選択 / 貼り付け。生成後はタイトル欄と整形表示の本文(「編集」で直せる)、参照した資料のリンク、保存先は自動で「変更」から編集、既存キーなら上書き警告FileListに curated/ 限定の編集ボタン、KnowledgePanelに組み込み確認したこと
test:cov全通過otoineppu-tokyo.mdと同じ構成の下書き(約 9 秒)。Instagram プロフィール URL は og:description が返るので読めた。X 投稿 + 別 URL の複数入力、画像のみ、テキスト + URL も通過未確認・注意
curated/*.mdは git 管理外。knowledge:upload --clean後はPOST /admin/knowledge/syncで再同期する(CLAUDE.md に記載)Test plan
curated-draftが knowledge-base 区分で載るcurated/の行だけ編集できる