Skip to content

Commit

Permalink
fix: fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
chuang8511 committed Oct 31, 2024
1 parent f751d74 commit ab140f3
Showing 1 changed file with 5 additions and 36 deletions.
41 changes: 5 additions & 36 deletions pkg/component/operator/document/v0/convert_document_to_markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,6 @@ import (
"context"

"github.com/instill-ai/pipeline-backend/pkg/component/base"
"github.com/instill-ai/pipeline-backend/pkg/component/internal/util"
)

type ConvertDocumentToMarkdownInput struct {
Document string `json:"document"`
DisplayImageTag bool `json:"display-image-tag"`
Filename string `json:"filename"`
DisplayAllPageImage bool `json:"display-all-page-image"`
}

type ConvertDocumentToMarkdownOutput struct {
Body string `json:"body"`
Filename string `json:"filename"`
Images []string `json:"images,omitempty"`
Error string `json:"error,omitempty"`
AllPageImages []string `json:"all-page-images,omitempty"`
Markdowns []string `json:"markdowns"`
}

func ConvertDocumentToMarkdown(inputStruct *ConvertDocumentToMarkdownInput, transformerGetter MarkdownTransformerGetterFunc) (*ConvertDocumentToMarkdownOutput, error) {
contentType, err := util.GetContentTypeFromBase64(inputStruct.Document)
"github.com/instill-ai/pipeline-backend/pkg/component/operator/document/v0/transformer"
"github.com/instill-ai/pipeline-backend/pkg/data"
"github.com/instill-ai/pipeline-backend/pkg/data/format"
Expand All @@ -42,21 +21,11 @@ func (e *execution) convertDocumentToMarkdown(ctx context.Context, job *base.Job
if err != nil {
return err
}
converterOutput, err := transformer.Transform()
if err != nil {
return nil, err
}

outputStruct := &ConvertDocumentToMarkdownOutput{
Body: converterOutput.Body,
Images: converterOutput.Images,
Error: strings.Join(converterOutput.ParsingError, "\n"),
AllPageImages: converterOutput.AllPageImages,
}

if inputStruct.Filename != "" {
filename := strings.Split(inputStruct.Filename, ".")[0] + ".md"
outputStruct.Filename = filename
transformerInputStruct := transformer.ConvertDocumentToMarkdownTransformerInput{
Document: dataURI.String(),
DisplayImageTag: inputStruct.DisplayImageTag,
Filename: inputStruct.Filename,
DisplayAllPageImage: inputStruct.DisplayAllPageImage,
}

transformerOutputStruct, err := transformer.ConvertDocumentToMarkdown(&transformerInputStruct, e.getMarkdownTransformer)
Expand Down

0 comments on commit ab140f3

Please sign in to comment.