Skip to content

feat: add MinerU document parse channel#4757

Closed
dongfangzan wants to merge 1 commit into
QuantumNous:mainfrom
dongfangzan:feat/mineru-channel
Closed

feat: add MinerU document parse channel#4757
dongfangzan wants to merge 1 commit into
QuantumNous:mainfrom
dongfangzan:feat/mineru-channel

Conversation

@dongfangzan
Copy link
Copy Markdown

@dongfangzan dongfangzan commented May 11, 2026

Summary

  • Add ChannelTypeMinerU (58) and APITypeMinerU
  • Add POST /v1/file_parse relay endpoint with multipart support
  • Implement MinerU adaptor for /file_parse synchronous parsing
  • model parameter is used for gateway channel selection only
  • backend parameter is passed through to MinerU directly
  • Support per-call billing (UsePrice) mechanism
  • Add channel health check test (/health endpoint)

Test Plan

  • PDF file parsing via /v1/file_parse
  • Channel health check test
  • Per-call billing works correctly
  • multipart form-data passthrough verified

Summary by CodeRabbit

Release Notes

  • New Features

    • Added MinerU channel support with document extraction and file parsing capabilities
    • Added /v1/file_parse endpoint for document extraction integration
    • Implemented health check verification for MinerU channels
  • Removed Features

    • Removed LinkedIn OAuth provider support

Review Change Stack

- Add ChannelTypeMinerU (58) and APITypeMinerU
- Add POST /v1/file_parse relay endpoint with multipart support
- Implement MinerU adaptor for /file_parse synchronous parsing
- model parameter is used for gateway channel selection only
- backend parameter is passed through to MinerU directly
- Support per-call billing (UsePrice) mechanism
- Add channel health check test (/health endpoint)

Tested locally against http://192.168.225.193:9000/file_parse
Copilot AI review requested due to automatic review settings May 11, 2026 01:37
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

Walkthrough

This PR adds MinerU document parsing support by introducing a new channel type (ChannelTypeMinerU), corresponding API type (APITypeMinerU), and a complete relay adaptor that forwards multipart file-upload requests to a self-hosted MinerU /file_parse endpoint and normalizes responses. It also includes middleware routing, request validation, health checks, and frontend channel registration, plus minor cleanup of LinkedIn OAuth and Vite CSS configuration.

Changes

MinerU Document Extraction Integration

Layer / File(s) Summary
Channel & Relay Constants
constant/api_type.go, constant/channel.go, types/relay_format.go, relay/constant/relay_mode.go
New ChannelTypeMinerU (58), APITypeMinerU, RelayFormatDocumentExtract, and RelayModeDocumentExtract constants establish the channel and relay identities.
Document Request DTO & Validation
dto/document.go, relay/helper/valid_request.go
DocumentExtractRequest embeds BaseRequest and implements IsStream(false) and token-count metadata. GetAndValidateDocumentExtractRequest parses multipart form and ensures at least one uploaded file is present.
Relay Info & Mode Generation
relay/common/relay_info.go, relay/constant/relay_mode.go
GenRelayInfoDocumentExtract creates relay metadata; Path2RelayMode maps /v1/file_parse prefix to RelayModeDocumentExtract.
MinerU Adaptor Implementation
relay/channel/mineru/constants.go, relay/channel/mineru/dto.go, relay/channel/mineru/adaptor.go
Adaptor reconstructs multipart requests from parsed form data, forwards to upstream MinerU /file_parse, unmarshals MinerUFileParseResult, handles errors, and returns fixed usage tokens.
Channel Type to Adaptor Wiring
common/api_type.go, relay/relay_adaptor.go
ChannelType2APIType maps ChannelTypeMinerU to APITypeMinerU; GetAdaptor returns mineru.Adaptor{} for that API type.
MinerU Health Check
controller/channel-test.go
Special-case health check for MinerU channels via GET <baseURL>/health, expecting 200 status and body containing "ok".
HTTP Route & Request Dispatch
router/relay-router.go, middleware/distributor.go, controller/relay.go
POST /v1/file_parse route wired to relay controller; middleware extracts model parameter and sets relay mode; controller dispatches to DocumentExtractHelper.
Document Extraction Handler
relay/document_handler.go
DocumentExtractHelper validates request type, applies model mapping, selects adaptor, invokes DoRequest, handles HTTP errors, processes response via DoResponse, and records quota usage.
Web Channel Registration
web/src/constants/channel.constants.js
MinerU channel (value 58) added to CHANNEL_OPTIONS with blue color.

Frontend Configuration & OAuth Updates

Layer / File(s) Summary
LinkedIn OAuth Removal
web/src/helpers/render.jsx
SiLinkedin icon import and linkedin entry in oauthProviderIconMap deleted; fall back to default icon for linkedin provider.
Vite CSS Alias
web/vite.config.js
resolve.alias entry added to map @douyinfe/semi-ui/dist/css/semi.css to node_modules path.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • creamlike1024
  • Calcium-Ion

Poem

🐰 A MinerU arrives at the gateway door,
With multipart files and dreams of more,
Health checks pass with /health ok,
While LinkedIn waves its final farewell—
New channels bloom, Vite config rings true!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add MinerU document parse channel' directly and clearly summarizes the main change—introduction of a new MinerU channel for document parsing. It accurately reflects the changeset's primary objective.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@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: 4

🧹 Nitpick comments (1)
relay/channel/mineru/adaptor.go (1)

187-194: 💤 Low value

Clarify the status check comment.

The comment mentions "pending" but the code checks for "failed". If "pending" also represents an error state for synchronous parsing, it should be checked as well. Otherwise, update the comment to accurately reflect the check.

📝 Suggested comment fix
-	// Check status - pending means something went wrong since we expect completed
+	// Check status - failed means processing failed
 	if result.Status == "failed" {
 		return nil, types.NewErrorWithStatusCode(
 			errors.New("mineru processing failed"),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/channel/mineru/adaptor.go` around lines 187 - 194, Decide whether a
"pending" status should be treated as an error; if it should, change the
condition in the adaptor.go block that checks result.Status to include pending
(e.g., result.Status == "failed" || result.Status == "pending") and keep the
comment indicating pending means something went wrong; otherwise update the
comment to accurately state that the code checks for "failed" (replace "pending"
with "failed") so the comment matches the condition that uses result.Status.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@controller/channel-test.go`:
- Line 84: Replace the blocking call at "resp, err := http.Get(healthURL)" with
an http.Client that has a timeout (e.g., client := &http.Client{Timeout: 5 *
time.Second}) and call client.Get(healthURL) instead; ensure you still check err
before using resp, always defer resp.Body.Close() when resp != nil, and consider
making the timeout a constant or config value so the channel test goroutine
cannot hang indefinitely.

In `@middleware/distributor.go`:
- Around line 273-283: ParseMultipartForm's error must be checked and handled:
call c.Request.ParseMultipartForm(64<<20), capture the error returned from
ParseMultipartForm, and if non-nil log the error (use existing logger or
c.Error/c.AbortWithStatusJSON) and avoid proceeding to read
c.Request.MultipartForm; only read MultipartForm.Value["model"] and set
modelRequest.Model and c.Set("relay_mode",
relayconstant.RelayModeDocumentExtract) when parsing succeeded and MultipartForm
is non-nil. Update the block that uses c.Request.ParseMultipartForm,
modelRequest.Model, and relayconstant.RelayModeDocumentExtract to perform the
error check and short-circuit on failure.

In `@relay/channel/mineru/adaptor.go`:
- Around line 104-121: In the loop that iterates fileHeaders, after opening each
file with fileHeader.Open() immediately call defer file.Close() to ensure the
file is always closed on function exit (replace the explicit file.Close() calls
in each error path and at the end of the loop); keep the existing error handling
for writer.CreateFormFile and io.Copy but remove manual closes there so
resources are managed by the deferred file.Close() tied to the file returned by
fileHeader.Open().

In `@relay/document_handler.go`:
- Line 60: The call to service.PostTextConsumeQuota assumes usage is *dto.Usage
and will panic if DoResponse returned another type; change the unchecked
assertion usage.(*dto.Usage) to a checked form: perform a type assertion with
the ok comma form (e.g., u, ok := usage.(*dto.Usage)), check ok (and nil) and
handle the failure path (log/error/return) before calling
service.PostTextConsumeQuota; update any related variable names around
DoResponse and service.PostTextConsumeQuota to use the safely asserted u value.

---

Nitpick comments:
In `@relay/channel/mineru/adaptor.go`:
- Around line 187-194: Decide whether a "pending" status should be treated as an
error; if it should, change the condition in the adaptor.go block that checks
result.Status to include pending (e.g., result.Status == "failed" ||
result.Status == "pending") and keep the comment indicating pending means
something went wrong; otherwise update the comment to accurately state that the
code checks for "failed" (replace "pending" with "failed") so the comment
matches the condition that uses result.Status.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eff785db-4442-4629-924f-08df0d4d74a6

📥 Commits

Reviewing files that changed from the base of the PR and between 543cc64 and 92e9e0a.

📒 Files selected for processing (20)
  • common/api_type.go
  • constant/api_type.go
  • constant/channel.go
  • controller/channel-test.go
  • controller/relay.go
  • dto/document.go
  • middleware/distributor.go
  • relay/channel/mineru/adaptor.go
  • relay/channel/mineru/constants.go
  • relay/channel/mineru/dto.go
  • relay/common/relay_info.go
  • relay/constant/relay_mode.go
  • relay/document_handler.go
  • relay/helper/valid_request.go
  • relay/relay_adaptor.go
  • router/relay-router.go
  • types/relay_format.go
  • web/src/constants/channel.constants.js
  • web/src/helpers/render.jsx
  • web/vite.config.js
💤 Files with no reviewable changes (1)
  • web/src/helpers/render.jsx

baseURL = *channel.BaseURL
}
healthURL := strings.TrimSuffix(baseURL, "/") + "/health"
resp, err := http.Get(healthURL)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add timeout to the HTTP GET request.

The http.Get call has no timeout and will block indefinitely if the MinerU backend is unresponsive, potentially hanging the channel test goroutine and degrading the test-all-channels flow.

⏱️ Proposed fix: use http.Client with timeout
-	healthURL := strings.TrimSuffix(baseURL, "/") + "/health"
-	resp, err := http.Get(healthURL)
+	healthURL := strings.TrimSuffix(baseURL, "/") + "/health"
+	client := &http.Client{Timeout: 10 * time.Second}
+	resp, err := client.Get(healthURL)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
resp, err := http.Get(healthURL)
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Get(healthURL)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@controller/channel-test.go` at line 84, Replace the blocking call at "resp,
err := http.Get(healthURL)" with an http.Client that has a timeout (e.g., client
:= &http.Client{Timeout: 5 * time.Second}) and call client.Get(healthURL)
instead; ensure you still check err before using resp, always defer
resp.Body.Close() when resp != nil, and consider making the timeout a constant
or config value so the channel test goroutine cannot hang indefinitely.

Comment thread middleware/distributor.go
Comment on lines +273 to +283
} else if strings.HasPrefix(c.Request.URL.Path, "/v1/file_parse") {
// MinerU document extract uses multipart form-data
if c.Request.MultipartForm == nil {
c.Request.ParseMultipartForm(64 << 20)
}
if c.Request.MultipartForm != nil {
if values, ok := c.Request.MultipartForm.Value["model"]; ok && len(values) > 0 {
modelRequest.Model = values[0]
}
}
c.Set("relay_mode", relayconstant.RelayModeDocumentExtract)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Missing error handling for multipart form parsing.

Line 276 calls ParseMultipartForm but ignores the returned error. If parsing fails (e.g., due to malformed multipart data), the error is silently discarded, and subsequent code at lines 278-282 proceeds to access c.Request.MultipartForm, which may be nil or incomplete. This could lead to unexpected behavior or incomplete model extraction.

🛡️ Proposed fix to handle parsing errors
 	} else if strings.HasPrefix(c.Request.URL.Path, "/v1/file_parse") {
 		// MinerU document extract uses multipart form-data
 		if c.Request.MultipartForm == nil {
-			c.Request.ParseMultipartForm(64 << 20)
+			if err := c.Request.ParseMultipartForm(64 << 20); err != nil {
+				// Log the error but continue - model extraction is optional
+				common.SysError(fmt.Sprintf("Failed to parse multipart form: %v", err))
+			}
 		}
 		if c.Request.MultipartForm != nil {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} else if strings.HasPrefix(c.Request.URL.Path, "/v1/file_parse") {
// MinerU document extract uses multipart form-data
if c.Request.MultipartForm == nil {
c.Request.ParseMultipartForm(64 << 20)
}
if c.Request.MultipartForm != nil {
if values, ok := c.Request.MultipartForm.Value["model"]; ok && len(values) > 0 {
modelRequest.Model = values[0]
}
}
c.Set("relay_mode", relayconstant.RelayModeDocumentExtract)
} else if strings.HasPrefix(c.Request.URL.Path, "/v1/file_parse") {
// MinerU document extract uses multipart form-data
if c.Request.MultipartForm == nil {
if err := c.Request.ParseMultipartForm(64 << 20); err != nil {
// Log the error but continue - model extraction is optional
common.SysError(fmt.Sprintf("Failed to parse multipart form: %v", err))
}
}
if c.Request.MultipartForm != nil {
if values, ok := c.Request.MultipartForm.Value["model"]; ok && len(values) > 0 {
modelRequest.Model = values[0]
}
}
c.Set("relay_mode", relayconstant.RelayModeDocumentExtract)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@middleware/distributor.go` around lines 273 - 283, ParseMultipartForm's error
must be checked and handled: call c.Request.ParseMultipartForm(64<<20), capture
the error returned from ParseMultipartForm, and if non-nil log the error (use
existing logger or c.Error/c.AbortWithStatusJSON) and avoid proceeding to read
c.Request.MultipartForm; only read MultipartForm.Value["model"] and set
modelRequest.Model and c.Set("relay_mode",
relayconstant.RelayModeDocumentExtract) when parsing succeeded and MultipartForm
is non-nil. Update the block that uses c.Request.ParseMultipartForm,
modelRequest.Model, and relayconstant.RelayModeDocumentExtract to perform the
error check and short-circuit on failure.

Comment on lines +104 to +121
for _, fileHeader := range fileHeaders {
file, err := fileHeader.Open()
if err != nil {
return nil, fmt.Errorf("failed to open file %s: %w", fileHeader.Filename, err)
}

part, err := writer.CreateFormFile(fieldName, fileHeader.Filename)
if err != nil {
file.Close()
return nil, fmt.Errorf("failed to create form file for %s: %w", fileHeader.Filename, err)
}

if _, err := io.Copy(part, file); err != nil {
file.Close()
return nil, fmt.Errorf("failed to copy file %s: %w", fileHeader.Filename, err)
}
file.Close()
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Prefer defer file.Close() for safer resource management.

The current code manually closes file in each error path and at the end. Using defer immediately after Open() is safer and prevents resource leaks if the code changes or panics.

♻️ Proposed refactor
 		for _, fileHeader := range fileHeaders {
 			file, err := fileHeader.Open()
 			if err != nil {
 				return nil, fmt.Errorf("failed to open file %s: %w", fileHeader.Filename, err)
 			}
+			defer file.Close()
 
 			part, err := writer.CreateFormFile(fieldName, fileHeader.Filename)
 			if err != nil {
-				file.Close()
 				return nil, fmt.Errorf("failed to create form file for %s: %w", fileHeader.Filename, err)
 			}
 
 			if _, err := io.Copy(part, file); err != nil {
-				file.Close()
 				return nil, fmt.Errorf("failed to copy file %s: %w", fileHeader.Filename, err)
 			}
-			file.Close()
 		}
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/channel/mineru/adaptor.go` around lines 104 - 121, In the loop that
iterates fileHeaders, after opening each file with fileHeader.Open() immediately
call defer file.Close() to ensure the file is always closed on function exit
(replace the explicit file.Close() calls in each error path and at the end of
the loop); keep the existing error handling for writer.CreateFormFile and
io.Copy but remove manual closes there so resources are managed by the deferred
file.Close() tied to the file returned by fileHeader.Open().

Comment thread relay/document_handler.go
return newAPIError
}

service.PostTextConsumeQuota(c, info, usage.(*dto.Usage), nil)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Add type assertion safety check.

The type assertion usage.(*dto.Usage) will panic if DoResponse returns a different type. Use a checked assertion instead.

🛡️ Proposed fix
-	service.PostTextConsumeQuota(c, info, usage.(*dto.Usage), nil)
-	return nil
+	dtoUsage, ok := usage.(*dto.Usage)
+	if !ok {
+		return types.NewError(fmt.Errorf("invalid usage type, expected *dto.Usage, got %T", usage), types.ErrorCodeInvalidRequest, types.ErrOptionWithSkipRetry())
+	}
+	service.PostTextConsumeQuota(c, info, dtoUsage, nil)
+	return nil
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
service.PostTextConsumeQuota(c, info, usage.(*dto.Usage), nil)
dtoUsage, ok := usage.(*dto.Usage)
if !ok {
return types.NewError(fmt.Errorf("invalid usage type, expected *dto.Usage, got %T", usage), types.ErrorCodeInvalidRequest, types.ErrOptionWithSkipRetry())
}
service.PostTextConsumeQuota(c, info, dtoUsage, nil)
return nil
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@relay/document_handler.go` at line 60, The call to
service.PostTextConsumeQuota assumes usage is *dto.Usage and will panic if
DoResponse returned another type; change the unchecked assertion
usage.(*dto.Usage) to a checked form: perform a type assertion with the ok comma
form (e.g., u, ok := usage.(*dto.Usage)), check ok (and nil) and handle the
failure path (log/error/return) before calling service.PostTextConsumeQuota;
update any related variable names around DoResponse and
service.PostTextConsumeQuota to use the safely asserted u value.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new “MinerU” relay channel to support synchronous document parsing via a new multipart endpoint (POST /v1/file_parse), including backend wiring for relay format/mode routing and basic channel health checking.

Changes:

  • Introduces RelayFormatDocumentExtract / RelayModeDocumentExtract and wires /v1/file_parse into the relay router + request validation + handler dispatch.
  • Adds a new MinerU channel/adaptor implementation that proxies multipart uploads to MinerU’s /file_parse and bills per call via fixed usage.
  • Updates channel type/API type constants and the web UI channel list (plus a Vite alias tweak).

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
web/vite.config.js Adds an explicit alias for Semi UI CSS resolution.
web/src/helpers/render.jsx Removes LinkedIn icon import/mapping.
web/src/constants/channel.constants.js Adds MinerU (58) to UI channel options.
types/relay_format.go Adds RelayFormatDocumentExtract.
router/relay-router.go Adds POST /v1/file_parse relay route.
relay/relay_adaptor.go Registers MinerU adaptor selection by API type.
relay/helper/valid_request.go Adds multipart validation for document extract requests.
relay/document_handler.go Adds relay handler helper for document extraction flow.
relay/constant/relay_mode.go Adds RelayModeDocumentExtract and path mapping.
relay/common/relay_info.go Adds GenRelayInfoDocumentExtract and format dispatch.
relay/channel/mineru/dto.go Defines MinerU /file_parse response DTOs.
relay/channel/mineru/constants.go Adds MinerU model list + channel name.
relay/channel/mineru/adaptor.go Implements multipart proxying + response passthrough + per-call usage for MinerU.
middleware/distributor.go Extracts model from multipart form for /v1/file_parse channel selection.
dto/document.go Adds DocumentExtractRequest request type.
controller/relay.go Routes RelayModeDocumentExtract to the new helper.
controller/channel-test.go Adds MinerU /health connectivity test path.
constant/channel.go Adds ChannelTypeMinerU (58), base URL slot, and name.
constant/api_type.go Adds APITypeMinerU.
common/api_type.go Maps MinerU channel type to API type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread middleware/distributor.go
Comment on lines +273 to +277
} else if strings.HasPrefix(c.Request.URL.Path, "/v1/file_parse") {
// MinerU document extract uses multipart form-data
if c.Request.MultipartForm == nil {
c.Request.ParseMultipartForm(64 << 20)
}
Comment on lines +83 to +88
healthURL := strings.TrimSuffix(baseURL, "/") + "/health"
resp, err := http.Get(healthURL)
if err != nil {
return testResult{
localErr: fmt.Errorf("mineru health check failed: %w", err),
}
Comment on lines +72 to +74
var requestBuf bytes.Buffer
writer := multipart.NewWriter(&requestBuf)

Comment on lines +108 to +114
}

part, err := writer.CreateFormFile(fieldName, fileHeader.Filename)
if err != nil {
file.Close()
return nil, fmt.Errorf("failed to create form file for %s: %w", fileHeader.Filename, err)
}
Comment on lines +162 to +168

// Read response body
body, readErr := io.ReadAll(resp.Body)
if readErr != nil {
return nil, types.NewError(fmt.Errorf("failed to read response body: %w", readErr), types.ErrorCodeDoRequestFailed)
}
resp.Body.Close()
}
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
@dongfangzan
Copy link
Copy Markdown
Author

误触创建,关闭。

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.

2 participants