Files
yawan f7fc992f57
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
2026-09-22 16:19:06 +08:00

123 lines
3.7 KiB
Go

package types
import "strings"
// ReadRequest is the unified transport-agnostic request for document reading.
// Set FileContent for file mode, URL for URL mode.
type ReadRequest struct {
FileContent []byte
FileName string
FileType string
URL string
Title string
ParserEngine string
RequestID string
ParserEngineOverrides map[string]string
}
// ReadResult is the transport-agnostic result of document reading.
type ReadResult struct {
MarkdownContent string
ImageRefs []ImageRef
ImageDirPath string
Metadata map[string]string
Error string
IsAudio bool // true when the result contains raw audio data needing ASR transcription
AudioData []byte // raw audio bytes for ASR processing
}
// ImageRef represents an image reference extracted from the document.
type ImageRef struct {
Filename string
OriginalRef string
MimeType string
StorageKey string
ImageData []byte // inline image bytes (universal fallback for cross-machine deployments)
// IsOriginal marks references that point to the originally uploaded file
// itself (e.g. when the user uploads a standalone image). Such references
// must not be dropped by the icon/size filter — otherwise a small image
// upload would be silently discarded before multimodal processing.
IsOriginal bool
}
// ParserEngineInfo describes a registered parser engine.
type ParserEngineInfo struct {
Name string
Description string
FileTypes []string
Available bool
UnavailableReason string
}
// --- Internal types used by chunking pipeline ---
type DocParserStorageConfig struct {
Provider string
Region string
BucketName string
AccessKeyID string
SecretAccessKey string
AppID string
PathPrefix string
Endpoint string
}
type DocParserVLMConfig struct {
ModelName string
BaseURL string
APIKey string
InterfaceType string
}
type ParsedChunk struct {
Content string
// ContextHeader is an optional context string (e.g. a Markdown heading
// breadcrumb) that should be prepended at embedding time but is NOT
// part of the stored Content. Lets retrieval pipelines see section
// context without breaking End-Start == len(Content) invariants.
ContextHeader string
Seq int
Start int
End int
Images []ParsedImage
ChunkID string // populated by processChunks with the actual DB UUID
// ParentIndex is set when using parent-child chunking strategy.
// -1 (or unset/0 for flat chunks) means this is a top-level chunk.
// >= 0 means this is a child chunk referencing the parent at this index
// in the ParentChunks slice of ProcessChunksOptions.
ParentIndex int
}
// EmbeddingContent returns the text that should be sent to the embedding
// model: ContextHeader (if any) prepended to Content. Mirrors
// chunker.Chunk.EmbeddingContent so the choice is consistent across the
// chunker output and the indexing pipeline. Surrounding whitespace on
// Content is trimmed so leading/trailing newlines from boundary slicing
// don't dilute the embedded vector.
func (c ParsedChunk) EmbeddingContent() string {
body := strings.TrimSpace(c.Content)
if c.ContextHeader == "" {
return body
}
return c.ContextHeader + "\n\n" + body
}
// ParsedParentChunk represents a parent chunk in the parent-child strategy.
// Parent chunks are stored in DB for context retrieval but NOT vector-indexed.
type ParsedParentChunk struct {
Content string
Seq int
Start int
End int
}
type ParsedImage struct {
URL string
Caption string
OCRText string
OriginalURL string
Start int
End int
}