GithubHelp home page GithubHelp logo

sdk_gpt's Introduction

Language Model Document Retriever (MetaMask developers and Zendesk knowledge base tests)

This repository contains a Node.js application that uses OpenAI's GPT-3.5 and GPT-4 based model to answer questions related to a set of documents. Specifically the MetaMask SDK documentation.

The application first processes the documents, creating a vector store for efficient retrieval, and then provides an interactive prompt for users to ask questions.

Features

  • Load and process documents from a specified directory.
  • Split documents into chunks using Markdown text splitter.
  • Create a vector store for efficient document retrieval.
  • Use OpenAI's GPT-3.5/4 based model to answer questions.
  • Provide an interactive prompt for users to ask questions.
  • Provide an REST API.
  • Provide an Discord bot.

Prerequisites

  • Node.js v16.x.x or higher

Setup

  1. Clone the repository:
git clone https://github.com/andreahaku/sdk_gpt.git
cd sdk_gpt
  1. Install the required dependencies:
yarn
  1. Create a .env file in the project root directory and add your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key_here

Replace your_openai_api_key_here with your actual OpenAI API key.

Usage

Add your documents (in Markdown format) to the sdk_docs directory.

Run the application (test questions):

yarn start

Run the application (interactive):

yarn start:interactive

An interactive prompt will appear, allowing you to ask questions related to the documents:

Enter your question or type 'exit' to quit:

Type your question and press Enter. The application will provide an answer based on the processed documents. To exit the interactive prompt, type exit and press Enter.

Run as REST API server:

yarn start:server

The server will start and listen for incoming requests on port 3000 (or the port specified in the PORT environment variable).

To interact with the API, use any HTTP client, such as Postman, Insomnia, or a simple command-line tool like curl. You can also use a library like axios or fetch in JavaScript to make requests from another application. The API has a single endpoint /ask that accepts POST requests containing a JSON payload with the question. Here's an example of how to send a request to the API using curl:

curl --request POST \
  --url http://localhost:3000/ask \
  --header 'Content-Type: application/json' \
  --data '{
    "question": "How can I install MetaMask SDK on iOS?"
  }'

that sends an answer similar to:

{"question":"How can I install MetaMask SDK on iOS?","answer":"To install MetaMask SDK on iOS, you will need to add it as a cocoapods dependency to your project by adding this entry in your Podfile: `pod 'metamask-ios-sdk'` and then running `pod install`. You can also add MetaMask iOS SDK as an SPM package to your project using the repository url: https://github.com/MetaMask/metamask-ios-sdk. Finally, you need to run the postinstall script: `yarn postinstall`, and then install the necessary pods that came with the library: `cd ios && pod install && cd ..`."}

Run as Discord bot

  1. Create your bot on the Discord Developer Portal:
    • Go to the Discord Developer Portal: https://discord.com/developers/applications.
    • Sign in with your Discord account.
    • Click "New Application" and provide a name for your bot.
    • Navigate to the "Bot" tab on the left side and click "Add Bot."
    • On the bot page, you'll find the bot's token. Keep it secret, as it's used to authenticate your bot.
  2. Run your bot:
    • In your terminal or command prompt, run node index.js to start your bot. If everything is set up correctly, you should see a message saying "Logged in as [bot-username]!".
  3. Invite your bot to a server:
    • To invite the bot to a server, you'll need to create an invite link. Replace YOUR_CLIENT_ID with the client ID found on the "General Information" page of your bot's application on the Discord Developer Portal:
    • Paste the following link into your browser and follow the instructions:
      https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot&permissions=3072
      

License

This project is licensed under the MIT License - see the LICENSE file for details.

P.S.

This README.md has been almost completely generated by GPT-4 ;)

sdk_gpt's People

Contributors

andreahaku avatar

Stargazers

JessDataDev avatar Eddie Penta avatar cloudonshore avatar Dan Finlay avatar

Watchers

 avatar David Sampaio avatar

Forkers

danfinlay ae-0h

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.