Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Commit

Permalink
add: otto blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
iwilltry42 committed Oct 28, 2024
1 parent cf24292 commit d3aea0e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 5 deletions.
4 changes: 3 additions & 1 deletion ingest.gpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Name: Knowledge Ingestion
Description: Ingest content into a dataset.
Credential: github.com/gptscript-ai/credentials/model-provider
Params: Input: Input File
Params: Dataset: Dataset ID

#!${GPTSCRIPT_TOOL_DIR}/bin/gptscript-go-tool ingest --dataset ${GPTSCRIPT_DATASET} "${GPTSCRIPT_INPUT}"
#!${GPTSCRIPT_TOOL_DIR}/bin/gptscript-go-tool ingest --flows-file=blueprint:otto --dataset ${DATASET} "${INPUT}"
1 change: 1 addition & 0 deletions load.gpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ Name: Knowledge Loading
Description: Load a document, convert it to Knowledge JSON Format and store it to a file.
Params: Input: Input File
Params: Output: Output File
Params: know_load_metadata: Comma-delimited key=value pairs to be added to the metadata of the loaded document.

#!${GPTSCRIPT_TOOL_DIR}/bin/gptscript-go-tool load "${INPUT}" "${OUTPUT}"
2 changes: 1 addition & 1 deletion pkg/cmd/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
type ClientLoad struct {
Loader string `usage:"Choose a document loader to use"`
OutputFormat string `name:"format" usage:"Choose an output format" default:"structured"`
Metadata map[string]string `usage:"Metadata to attach to the loaded files" env:"KNOW_LOAD_METADATA"`
Metadata map[string]string `usage:"Metadata to attach to the loaded files" env:"METADATA"`
}

func (s *ClientLoad) Customize(cmd *cobra.Command) {
Expand Down
7 changes: 5 additions & 2 deletions pkg/datastore/documentloader/documentloaders.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,13 @@ func GetDocumentLoaderFunc(name string, config any) (LoaderFunc, error) {
return FromLangchain(lcgodocloaders.NewText(strings.NewReader(text))).Load(ctx)
}, nil
case "structured":
var structuredCfg structured.Structured
if config != nil {
return nil, fmt.Errorf("structured document loader does not accept configuration")
if err := mapstructure.Decode(config, &structuredCfg); err != nil {
return nil, fmt.Errorf("failed to decode structured document loader configuration: %w", err)
}
}
return new(structured.Structured).Load, nil
return structuredCfg.Load, nil
default:
return nil, fmt.Errorf("unknown document loader %q", name)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/flows/config/blueprints.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ var BlueprintDefault []byte
//go:embed blueprints/context.yaml
var BlueprintContext []byte

//go:embed blueprints/otto.yaml
var BlueprintOtto []byte

var Blueprints = map[string][]byte{
"default": BlueprintDefault,
"context": BlueprintContext,
"otto": BlueprintOtto,
}

func GetBlueprint(name string) ([]byte, error) {
Expand Down
20 changes: 20 additions & 0 deletions pkg/flows/config/blueprints/otto.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
flows:
otto:
default: true
globals:
ingestion:
textsplitter:
chunkSize: 2048
chunkOverlap: 256
ingestion:
- filetypes: [".json"]
documentloader:
name: structured
retrieval:
retriever:
name: basic
options:
topK: 20



2 changes: 1 addition & 1 deletion tool.gpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Credential: github.com/gptscript-ai/credentials/model-provider
Params: Datasets: The datasets to query
Params: Query: The query to search for

#!${GPTSCRIPT_TOOL_DIR}/bin/gptscript-go-tool retrieve --dataset="${DATASETS}" "${QUERY}"
#!${GPTSCRIPT_TOOL_DIR}/bin/gptscript-go-tool retrieve --flows-file=blueprint:otto --dataset="${DATASETS}" "${QUERY}"

0 comments on commit d3aea0e

Please sign in to comment.