Skip to content

feat(moonshot): add files extraction client - #46

Draft
chen-ran wants to merge 1 commit into
mainfrom
codex/kimi-file-extract
Draft

feat(moonshot): add files extraction client#46
chen-ran wants to merge 1 commit into
mainfrom
codex/kimi-file-extract

Conversation

@chen-ran

Copy link
Copy Markdown
Member

Summary

  • add a streamed Moonshot Files API client under provider/moonshot/files
  • support upload (including a purpose=file-extract convenience method), metadata retrieval, extracted-text reads, and remote deletion
  • validate multipart metadata, cap the convenience text reader, and cover request paths, auth, multipart encoding, errors, and input validation
  • document how the transport fits Kimi's official file-based QA flow

Why

Kimi's documented PDF/document QA flow is not a native Chat Completions file content part. It requires the application to upload a file to /v1/files, read /v1/files/{id}/content, inject the extracted text into model context, and eventually delete the remote file.

Twilight already maps generic chat content and Kimi-compatible tool schemas, but it had no client for this separate stateful Files API flow. That left applications to hand-roll the provider transport.

Official guide: https://platform.kimi.com/docs/guide/use-kimi-api-for-file-based-qa

Boundaries and impact

  • this PR does not automatically upload FilePart values or mutate the Kimi Chat Completions adapter
  • application orchestration still owns content-hash caching, token/context budgeting, prompt trust boundaries, retry policy, and remote-file cleanup timing
  • existing provider message mapping and non-Moonshot behavior are unchanged
  • a follow-up Memoh change can consume this client and implement the application-level policy

Validation

  • go build ./...
  • go vet ./...
  • go test -short -count=1 ./...
  • go test -count=1 ./provider/moonshot/files
  • golangci-lint run --allow-parallel-runners ./... (0 issues; another repository held golangci-lint's global runner lock)

No live Moonshot upload was run with a real API key.

⚠️ No human QA — this PR has not been verified by a human yet. Remove this line once a human confirms the happy path.

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