Giter VIP home page Giter VIP logo

chatgpt-wrapper's Introduction

ChatGPT CLI and Python Wrapper

ChatGPT Wrapper is an open-source unofficial Python API and CLI that lets you interact with ChatGPT.

Highlights

๐Ÿค– Programmable ChatGPT. The ChatGPT Wrapper lets you use the powerful ChatGPT bot in your Python scripts or on the command line, making it easy to leverage its functionality into your projects.

๐Ÿ’ฌ Runs in Shell. You can call and interact with ChatGPT in the terminal

How it works

Run an interactive CLI in the terminal:

$ chatgpt
Provide a prompt for ChatGPT, or type help or ? to list commands.
1> 

Or just get a quick response for one question:

$ chatgpt What is six times seven?

Six times seven is 42.      

Here's a short demo of some of the CLI features: https://user-images.githubusercontent.com/233113/206799611-8807f659-cd4c-449f-9937-843153533a15.mp4

See below for details on using ChatGPT as an API.

Requirements

To use this repository, you will need to have the following packages installed:

setuptools: This package is used to create and manage Python packages. You can install it using pip install setuptools.

Installation

You can install the latest version of this software directly from github with pip:

pip install git+https://github.com/mmabrouk/chatgpt-wrapper

This will install chatgpt-wrapper and it's dependencies.

Before starting the program, you will need to install a browser in playwright (if you haven't already). The program will use firefox by default.

playwright install firefox

With that done, you should start up the program in install mode, which will open up a browser window.

chatgpt install

Log in to ChatGPT in the browser window, then stop the program. After doing this, restart the program without the install parameter to begin using it.

Usage

Shell

The shell includes some nice features:

  • It provides commands to start a new conversation, or navigate to past points in the conversation.
  • It provides a command that allows the user to choose between rendered markdown and streaming output (can't have both).
  • It provides a logging option, and the ability to restore any context that's been logged, even from old sessions.
  • It provides a command to read prompts from files, and a command to support reading multi-line prompts.

Python

To use the ChatGPT class as an API for talking to ChatGPT, create an instance of the class and use the ask method to send a message to OpenAI and receive the response. For example:

from chatgpt_wrapper import ChatGPT

bot = ChatGPT()
response = bot.ask("Hello, world!")
print(response)  # prints the response from chatGPT

The say method takes a string argument representing the message to send to ChatGPT, and returns a string representing the response received from ChatGPT.

You may also stream the response as it comes in from ChatGPT in chunks using the ask_stream generator.

Upcoming Features

  • Async mode
  • Remove reliance on playwright
  • Improve error messaging
  • Automatic installation start when not logged in

Note: We welcome pull requests for any of the above features, or any other improvements you'd like to see in the project.

Contributing

We welcome contributions to ChatGPT Wrapper! If you have an idea for a new feature or have found a bug, please open an issue on the GitHub repository.

License

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

Acknowledgments

chatgpt-wrapper's People

Contributors

mmabrouk avatar natanel-shitrit avatar tecuya avatar

Stargazers

 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.