Giter Site home page Giter Site logo

justaigithub / gptcli Goto Github PK

View Code? Open in Web Editor NEW

This project forked from evilpan/gptcli

0.0 0.0 0.0 675 KB

ChatGPT in command line with open api (gpt-3.5/gpt-4)

Home Page: https://platform.openai.com/docs/introduction

License: GNU General Public License v2.0

Python 98.85% Dockerfile 1.15%

gptcli's Introduction

Take chatGPT into command line.

stream

Setup

  1. clone this repo
  2. pip3 install -U -r requirements.txt
  3. copy demo_config.json to config.json
  4. get your OPENAI_API_KEY and put it in config.json

Run

$ ./gptcli.py -h
usage: gptcli.py [-h] [-c CONFIG]

options:
  -h, --help  show this help message and exit
  -c CONFIG   path to your config.json (default: config.json)

Sample config.json:

{
    "key": "",                  // your api-key, will read from OPENAI_API_KEY envronment variable if empty
    "api_base": "",             // your api_base, will read from OPENAI_API_BASE envronment variable if empty
    "model": "gpt-3.5-turbo",   // GPT Model
    "stream": true,             // Stream mode
    "stream_render": false,     // Render live markdown in stream mode
    "context": "full",          // Session context mode, choices: "none", "request", "full"
    "showtokens": false,        // Show used token after every question
    "proxy": "",                // Use http/https/socks4a/socks5 proxy for requests to api.openai.com
    "prompt": [                 // Customize your prompt
        { "role": "system", "content": "If your response contains code, show with syntax highlight, for example ```js\ncode\n```" }
    ]
}

Supported model:

  • gpt-3.5-turbo
  • gpt-4
  • gpt-4-32k

Console help (with tab-complete):

$ ./gptcli.py
gptcli> .help -v

gptcli commands (use '.help -v' for verbose/'.help <topic>' for details):
======================================================================================================
.edit                 Run a text editor and optionally open a file with it
.help                 List available commands or provide detailed help for a specific command
.load                 Load conversation from Markdown/JSON file
.multiline            input multiple lines, end with ctrl-d(Linux/macOS) or ctrl-z(Windows). Cancel
                      with ctrl-c
.quit                 Exit this application
.reset                Reset session, i.e. clear chat history
.save                 Save current conversation to Markdown/JSON file
.set                  Set a settable parameter or show current settings of parameters
.tokens               Display total tokens used this session

Run in Docker:

# build
$ docker build -t gptcli:latest .

# run
$ docker run -it --rm -v $PWD/.key:/gptcli/.key gptcli:latest -h

# for host proxy access:
$ docker run --rm -it -v $PWD/config.json:/gptcli/config.json --network host gptcli:latest -c /gptcli/config.json

Feature

  • Single Python script
  • Session based
  • Markdown support with code syntax highlight
  • Stream output support
  • Proxy support (HTTP/HTTPS/SOCKS4A/SOCKS5)
  • Multiline input support (via .multiline command)
  • Save and load session from file (Markdown/JSON) (via .save and .load command)
  • Integrate with llama_index to support chatting with documents

LINK

gptcli's People

Contributors

evilpan avatar 6r6 avatar colton-k avatar xavierskip 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.