Code Monkey home page Code Monkey logo

commandchat's Introduction

chatGpt golang command line tool

build status

What is it?

  • It is a command line tool that can be used to chat with GPT, which will send messages with the latest two conversation record
  • It is based on Golang

How to run it in local

  • run go run . chat

How to use it

  • run export API_KEY="[your api key]"

  • run commandchat chat" to chat with Chatgpt and the default chat model is gpt-3.5-turbo

  • run commandchat setting to modify the chatting model, FYI, the input should be formatted as json

    • eg: switch to model text-davinci-003,
    {
      "modelName": "text-davinci-003",
      "apiUrl": "https://api.openai.com/v1/completions"
    }

output

Development tip

  • In case OpenAi locks down your APIKEY or account, you can use the Wiremock as your mock server to develop or debug your code. You can run ./startstub.sh
  • check your Wiremock works, input Url http://localhost:8080/__admin in your browser
  • How to use mock server to simulate
    • pre-preparing
      • docker
    • mock data is saved in the folder stub, if you want to add a new request, you can add a new file in its sub-folder mappings. And the response of a new request is saved in the sub-folder __files
    • modify the configuration setting.json, let the endpoint connect to the mocker server as follows:
      {
        "modelName": "gpt-3.5-turbo",
        "apiUrl": "http://localhost:8080/v1/chat/completions"
      }
    • run startstub.sh to start the mocker server, you will see the following output in your console
      2023-04-12 06:50:22.626 Verbose logging enabled
      2023-04-12 06:50:24.321 Verbose logging enabled
      /$$      /$$ /$$                     /$$      /$$                     /$$
      | $$  /$ | $$|__/                    | $$$    /$$$                    | $$
      | $$ /$$$| $$ /$$  /$$$$$$   /$$$$$$ | $$$$  /$$$$  /$$$$$$   /$$$$$$$| $$   /$$
      | $$/$$ $$ $$| $$ /$$__  $$ /$$__  $$| $$ $$/$$ $$ /$$__  $$ /$$_____/| $$  /$$/
      | $$$$_  $$$$| $$| $$  \__/| $$$$$$$$| $$  $$$| $$| $$  \ $$| $$      | $$$$$$/
      | $$$/ \  $$$| $$| $$      | $$_____/| $$\  $ | $$| $$  | $$| $$      | $$_  $$
      | $$/   \  $$| $$| $$      |  $$$$$$$| $$ \/  | $$|  $$$$$$/|  $$$$$$$| $$ \  $$
      |__/     \__/|__/|__/       \_______/|__/     |__/ \______/  \_______/|__/  \__/
      
      port:                         8080
      enable-browser-proxying:      false
      disable-banner:               false
      no-request-journal:           false
      verbose:                      true
      
    • Then you can run go run . chat to debug your app, you will see the verbose log in the console.

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.