Giter Club home page Giter Club logo

sample-gpt-local's Introduction

Running the Chat Application

This guide will help you run the chat application contained in the index.html file.

Prerequisites

Ensure you have the following:

  • A modern web browser (Chrome, Firefox, Safari, etc.)
  • A local web server (like Python's SimpleHTTPServer, Node's http-server, etc.). Or you can use Live Server feature from VSCode
  • An API key from OpenAI for API access. Or a laptop/PC with >8GB RAM

Start the app using OpenAI API

  1. Set up the API key

Open the index.html file and locate the following line:

const chatGPTKey = 'sk-'; // Paste the API key here

Replace 'sk-*****' with your actual OpenAI GPT-3 API key.

  1. Start the local server

Navigate to the directory containing index.html and start your local server. For example, if you're using Python's SimpleHTTPServer, you can start it with the command:

python -m SimpleHTTPServer

If you're using Node's http-server, you can start it with the command:

http-server
  1. Access the application

Open your web browser and navigate to localhost on the port your server is running. For example, if your server is running on port 8000, you would navigate to http://localhost:8000.

  1. Interact with the chat application

You should now see the chat interface in your browser. You can type messages into the input field and press "Send" to interact with the chatbot.

Please note that this is a simple setup meant for local development and testing. It is not suitable for a production environment.

Start the app using Local API

  1. Download model

Create a folder named models, then download mistral-7b-openorca.Q4_0.gguf from here https://huggingface.co/Open-Orca/Mistral-7B-OpenOrca and put into the models folder

  1. Install llama_cpp Python

Follow the guide here to install llama_cpp Python https://github.com/abetlen/llama-cpp-python

  1. Run local OpenAI server

Run the following script to run an OpenAI API server locally. The server should run at port 8000

python3 -m llama_cpp.server --model "./models/mistral-7b-openorca.Q4_0.gguf" --chat_format chatml --n_gpu_layers 1
  1. Update chat application code

Open the index.html file and locate the following line

  // Real GPT
  // const OPEN_AI_ENDPOINT = 'https://api.openai.com/v1' // Comment this line

  // Security, do not deploy this in production
  const chatGPTKey = 'sk-*****'; // Create an API key from here

  // Local GPT
  const OPEN_AI_ENDPOINT = 'http://localhost:8000/v1' // Uncomment this line

Run the application again. It should use localhost for local API inteference.

sample-gpt-local's People

Contributors

conanak99 avatar

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.