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

Commit

Permalink
feat: use GPTScript Gateway instead of OpenAI directly
Browse files Browse the repository at this point in the history
Signed-off-by: Donnie Adams <donnie@acorn.io>

Add dataset toolgpt (#79)

change: use default blueprint for gateway version

Don't use dataset id context (#81)
  • Loading branch information
thedadams authored and iwilltry42 committed Aug 22, 2024
1 parent 94200bd commit 79a90ab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
package main

import (
"fmt"
"os"

acmd "github.com/acorn-io/cmd"
"github.com/gptscript-ai/knowledge/pkg/cmd"
)

func main() {
if err := os.Setenv("OPENAI_API_KEY", os.Getenv("GPTSCRIPT_GATEWAY_API_KEY")); err != nil {
panic(fmt.Errorf("failed to set OPENAI_API_KEY: %w", err))
}

gatewayURL := os.Getenv("GPTSCRIPT_GATEWAY_URL")
if gatewayURL == "" {
gatewayURL = "https://gateway-api.gptscript.ai"
}
if err := os.Setenv("OPENAI_BASE_URL", gatewayURL+"/llm"); err != nil {
panic(fmt.Errorf("failed to set OPENAI_BASE_URL: %w", err))
}

acmd.Main(cmd.New())
}
2 changes: 1 addition & 1 deletion pkg/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Client struct {
}

type ClientFlowsConfig struct {
FlowsFile string `usage:"Path to a YAML/JSON file containing ingestion/retrieval flows" env:"KNOW_FLOWS_FILE" default:""`
FlowsFile string `usage:"Path to a YAML/JSON file containing ingestion/retrieval flows" env:"KNOW_FLOWS_FILE" default:"blueprint:default"`
Flow string `usage:"Flow name" env:"KNOW_FLOW"`
}

Expand Down
5 changes: 2 additions & 3 deletions tool.gpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ If the answers it returns seem irrelevant, you can use other tools, but do not f
Name: Knowledge Retrieval
Description: Retrieve information from files uploaded by the user.
Context: github.com/gptscript-ai/context/workspace
Credential: github.com/gptscript-ai/credential as sys.openai with OPENAI_API_KEY as env and "Please provide your OpenAI API key" as message and key as field
Credential: github.com/gptscript-ai/gateway-creds as github.com/gptscript-ai/gateway
Param: know_retrieve_keywords: (OPTIONAL - only use if you think it will improve results) A comma-separated list (no spaces) of keywords used to pre-filter the document base before conducting the semantic similarity search. Prefix a keyword sign with a dash (-) to exclude documents containing that keyword.
Param: query: The query to search for in the knowledge base. It will be used for semantic similarity search, so enhance it accordingly to yield good results.
Param: debug: (OPTIONAL) Set to "true" to enable debug mode - only use if you are explicitly asked to do so.

#!${GPTSCRIPT_TOOL_DIR}/bin/gptscript-go-tool askdir --path "${GPTSCRIPT_WORKSPACE_DIR}" "${QUERY}"

#!${GPTSCRIPT_TOOL_DIR}/bin/gptscript-go-tool retrieve --dataset ${GPTSCRIPT_THREAD_ID} "${QUERY}"

0 comments on commit 79a90ab

Please sign in to comment.