Git Product home page Git Product logo

gptbot's Introduction

GPTBot

Go Reference

Question Answering Bot powered by OpenAI GPT models.

Installation

$ go get -u github.com/go-aie/gptbot

Quick Start

func main() {
    ctx := context.Background()
    apiKey := os.Getenv("OPENAI_API_KEY")
    encoder := gptbot.NewOpenAIEncoder(apiKey, "")
    store := gptbot.NewLocalVectorStore()

    // Feed documents into the vector store.
    feeder := gptbot.NewFeeder(&gptbot.FeederConfig{
        Encoder: encoder,
        Updater: store,
    })
    err := feeder.Feed(ctx, &gptbot.Document{
        ID:   "1",
        Text: "Generative Pre-trained Transformer 3 (GPT-3) is an autoregressive language model released in 2020 that uses deep learning to produce human-like text. Given an initial text as prompt, it will produce text that continues the prompt.",
    })
    if err != nil {
        fmt.Printf("err: %v", err)
        return
    }

    // Chat with the bot to get answers.
    bot := gptbot.NewBot(&gptbot.BotConfig{
        APIKey:  apiKey,
        Encoder: encoder,
        Querier: store,
    })

    question := "When was GPT-3 released?"
    answer, _, err := bot.Chat(ctx, question)
    if err != nil {
        fmt.Printf("err: %v", err)
        return
    }
    fmt.Printf("Q: %s\n", question)
    fmt.Printf("A: %s\n", answer)

    // Output:
    //
    // Q: When was GPT-3 released?
    // A: GPT-3 was released in 2020.
}

NOTE:

  • The above example uses a local vector store. If you have a larger dataset, please consider using a vector search engine (e.g. Milvus).
  • With the help of GPTBot Server, you can even upload documents as files and then start chatting via HTTP!

Design

GPTBot is an implementation of the method demonstrated in Question Answering using Embeddings.

architecture

Core Concepts

Concepts Description Built-in Support
Preprocessor Preprocess the documents by splitting them into chunks. ✅[customizable]
Preprocessor
Encoder Creates an embedding vector for each chunk. ✅[customizable]
OpenAIEncoder
VectorStore Stores and queries document chunk embeddings. ✅[customizable]
LocalVectorStore
Milvus
Feeder Feeds the documents into the vector store. /
Bot Question answering bot to chat with. /

License

MIT

gptbot's People

Contributors

russellluo avatar clarkthan avatar deckarep avatar

Stargazers

Theodor Dimache avatar LL avatar  avatar  avatar  avatar Parth Shukla avatar Sajal Sharma avatar  avatar Tenvi avatar amrrs avatar Jackson Sabey avatar John D. Pope avatar Royal Bhati avatar Soe San Win avatar John Peña avatar Thomas Darimont avatar Alessandro Resta avatar Charlie avatar  avatar  avatar  avatar Takeone avatar Jorge Vargas avatar  avatar Aran Wilkinson avatar jun avatar Rohit Jnagal avatar Tabish Iqbal avatar 郑树新 avatar Su Ho avatar Takeshi Yamashita avatar Abdullah GÜNGÖR avatar  avatar David Campbell avatar Ian Mobbs avatar Oleg Balunenko avatar Baptiste Canton avatar Benji Vesterby avatar Kemal Türk avatar Robin avatar Sayed Rafeeq avatar Matthew Yeung avatar nbboy avatar  avatar  avatar Ahmad Farag avatar Jay D. avatar Prayag Singh avatar Emanuel Freitas avatar Harish Durga avatar Xargin avatar  avatar imsgao avatar chenduo avatar Aaron Gershman avatar Takashi Abe avatar Tim Kersey avatar Markel avatar Jaana Dogan avatar Alexander avatar Illya Busigin avatar Edward Fernandes avatar Devin Pastoor avatar Michal Žídek avatar Mohd Salman avatar Eje Oheji David avatar chikami avatar

Watchers

 avatar Kostas Georgiou avatar

gptbot's Issues

Question on LocalVectorStore embeddings.

Hello,

I'm trying to wrap my head around the Local Vector Store. What I know is that it's primarily used for small-scale docs and it has the ability to load up from disk in JSON format.

But, it seems to lack the ability to create a store and serialize "save" to disk in JSON format right?

Doesn't it make sense to persist embeddings across runs of the application so that you don't have to recreate them each time?

If you think this makes sense I could probably help contribute this ability and write the code to do that.

Thanks,

-deckarep

Compilation issue while using gptbot library

vectorstore.go:96:38: type func(a *Similarity, b *Similarity) bool of func(a, b *Similarity) bool {…} does not match inferred type func(a *Similarity, b *Similarity) int for func(a E, b E) int

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.