Skip to content

Repository files navigation

botMaker

A Go library to help create and train AI bots quickly with OpenA and PineCone. It is heavily based on code from the excellent vault-ai project.

Sample Usage

A simple chatbot:

funcChat() {
cfg:=Config{
OpenAPIKey: "xxxx",
PineconeKey: "xxxx",
PineconeEndpoint: "xxxx",
}
// Clientcl:=NewOAIClient(cfg.OpenAPIKey)
// Settings for the AIbs:=NewBotSettings()
bs.ID="a-UUID-here"// Build a prompt using the default templatepr:=NewBotPrompt("", cl)
pr.Instructions="You are an AI assistant that provides answers that are helpful in a friendly and cheerful way."pr.Body="What is the best way to scale a redis database?"// Create some storagepc:=&Pinecone{
APIEndpoint: cfg.PineconeEndpoint,
APIKey: cfg.PineconeKey,
UUID: bs.ID,
}
// attach memorybs.Memory=pcoaiResponse, _, err:=cl.CallUnifiedCompletionAPI(bs, pr)
iferr!=nil {
fatal("query send fail: %v", err)
}
fmt.Println("FIRST PROMPT:")
fmt.Println(pr.RenderedPrompt)
fmt.Println("GOT FIRST RESPONSE: ")
fmt.Println(oaiResponse)
time.Sleep(5*time.Second)
// we do some string shenanigans to make a chatbot// First: Update the contextoldBody:="Human: "+pr.Bodypr.ContextToRender=append(pr.ContextToRender, oldBody)
// Next make sure the AI's response is added toopr.ContextToRender=append(pr.ContextToRender, oaiResponse)
// Replace the main query with a new onepr.Body="How is a cluster different from sentinel?"// Make the call!secondResponse, _, err:=cl.CallUnifiedCompletionAPI(bs, pr)
iferr!=nil {
fatal("prompt2 fail: %v", err)
}
fmt.Println("SECOND RESPONSE")
fmt.Println(secondResponse)
}

Learning from a PDF

funcTestLearning() {
cfg:=Config{
OpenAPIKey: "xxx",
PineconeKey: "xxx",
PineconeEndpoint: "xxx",
}
// Clientcl:=NewOAIClient(cfg.OpenAPIKey)
// Create some storagepc:=&Pinecone{
APIEndpoint: cfg.PineconeEndpoint,
APIKey: cfg.PineconeKey,
UUID: "a45dbe63-4207-419c-bca7-5d940bf3d908",
}
l:=Learn{
Model: openai.GPT3TextDavinci003,
TokenLimit: 8191,
ChunkSize: 20,
Memory: pc,
Client: cl,
}
_, err:=l.FromFile("/data/socrates.pdf")
iferr!=nil {
fatal(err)
}
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages