Created
September 19, 2023 17:08
-
-
Save Struki84/e61b532b1163fc1c4ae1b2d1cea42645 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Prompt(input string, options ...chains.ChainCallOption) { | |
llm, err := openai.NewChat(openai.WithModel("gpt-4")) | |
if err != nil { | |
log.Fatal(err) | |
} | |
// dsn := "host=localhost user=gpt-admin password=gpt-password dbname=gpt-db port=5432" | |
// memory := memory.NewPostgreBuffer(dsn) | |
// memory.SetSession("USID-001") | |
ctx := context.Background() | |
search, err := duckduckgo.New(5, "") | |
if err != nil { | |
log.Fatal(err) | |
} | |
agentTools := []tools.Tool{search} | |
// executor, err := agents.Initialize( | |
// llm, | |
// agentTools, | |
// agents.ConversationalReactDescription, | |
// agents.WithMemory(memory), | |
// agents.WithReturnIntermediateSteps(), // This throws an error | |
// ) | |
executor, err := agents.Initialize( | |
llm, | |
agentTools, | |
agents.ConversationalReactDescription, | |
) | |
if err != nil { | |
log.Fatal(err) | |
} | |
response, err := chains.Run( | |
ctx, | |
executor, | |
input, | |
chains.WithStreamingFunc(func(ctx context.Context, chunk []byte) error { | |
fmt.Print(string(chunk)) | |
return nil | |
}), | |
) | |
fmt.Println(response) | |
if err != nil { | |
log.Fatal(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment