Skip to main content

Sengpt

ChatGPT in your terminal, runs on re-gpt so no OpenAI API key required

Installation • Configuration • Usage • Building from source • Support

example

Installation

Ensure you have Python 3.11 and Glow installed.

pip install sengpt

Configuration

Session token

  • Go to https://chat.openai.com and log in or sign up.
  • Open the browser developer tools (right click and click "inspect" or "inspect element").
  • Go to the Application tab (try expanding the dev tools window if you can't find it) and expand the Cookies section.
  • Look for https://chat.openai.com.
  • Copy the value for __Secure-next-auth.session-token.
  • Run sengpt --session_token <your-session-token-goes-here>.

Preconfigured prompts

  • Open the config file, run sengpt --config_file to see its location.
  • Add a field named preconfigured_prompts and set its value to key value pairs of prompt name and value e.g.,
{
  "preconfigured_prompts": {
    "readme": "generate a README.md for this project",
    "expain": "briefly explain what this code does",
    "refactor": "refactor this code to improve readability"
  }
}
  • To pass the prompt run sengpt --prompt_name or sengpt -pn.
  • Warning!!! Make sure the short version of the prompt name doesn't clash with each other or with any of sengpt's default flags, i.e., a prompt name like script_tags will clash with session_token so every time you try and use it sengpt will think you want to set your session token.
  • The preconfigured prompts are appended to the final prompt i.e., some_project.py | sengpt --readme make it as brief as possible

Modes

Interactive mode

Back and forth interaction with ChatGPT, saves the conversation on exit.

Currently doesn't support piped inputs i.e., cat README.md | sengpt summarise this document, if piped inputs are passed Query mode will be used instead.

Press Ctrl + C to exit.

Query mode

Print ChatGPT's response, delete the conversation and exit.

Default mode

The default mode is interactive mode but you can change this in the config

{
  "default_mode": "query"
}

With this configuration to use interactive mode run sengpt --interactive

Models

Either gpt-3.5 or gpt-4 can be used, the default is gpt-3.5. gpt-4 requires a ChatGPT Plus account and is slower. To switch to gpt-4 add this in your config file.

{
  "model": "gpt-4"
}

Username

How your username appears in the conversation, the default is You.

{
  "username": "Sen"
}

Usage


Usage: sengpt [prompt] [options]

-h, --help Show help message and exit
-v, --version Show the version information
-cf, --config_file Show the config file's contents and location
-st, --session_token Set session token

-ng, --no_glow Disable pretty printing with Glow,
this can be set to be the default behaviour in the config file

-c, --copy Copy the prompt response to the clipboard,
this can be set to be the default behaviour in the config file

-p, --paste Append the most recently copied clipboard text to the sent prompt
-rc, --recent_conversation Use the most recently saved conversation as context
-pp, --preconfigured_prompt Append a preconfigured prompt to the sent prompt,
replace "preconfigured_prompt" with the prompt's name
as it appears in the config file

-q, query Use query mode i.e., print ChatGPT's response and exit,
this flag is only necessary if "default_mode" in config file is interactive

-s, --save By default conversations in query mode are deleted on exit,
this saves the conversation instead,
this can be set to be the default behaviour in the config file

-i, --interactive Use interactive mode i.e., back and forth interaction with ChatGPT,
this flag is only necessary if "default_mode" in the config file is query

-d, --delete By default conversations in interactive mode are saved on exit,
this deletes then exits the interactive mode session,
this can be set to be the default behaviour in the config file

Building from Source

Ensure you have Python 3.11 and Git installed.

  1. Set everything up.
git clone https://github.com/SenZmaKi/Sengpt && cd Sengpt && pip install poetry && poetry install
  1. Run Sengpt.
poetry run sengpt
  1. Build the package to install with pip.
poetry build
  • The tar and wheel will be built at Sengpt/dist

Support

  • You can support the development of Sengpt through donations on GitHub Sponsors
  • You can also star the github repository for other terminal enthusiasts and freedom fighters to know about it

Metadata

Release files for sengpt 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sengpt 0.1.2
File Size Uploaded Provenance Actions
sengpt-0.1.2.tar.gz 30.3 kB Without provenance Details for sengpt-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sengpt 0.1.2
File Interpreter ABI Platform Actions
sengpt-0.1.2-py3-none-any.whl Python 3 none any Details for sengpt-0.1.2-py3-none-any.whl

Total release size: 66.2 kB

Release files / sengpt-0.1.2.tar.gz

Download URL sengpt-0.1.2.tar.gz
Size 30.3 kB
Tags Source
SHA-256 checksum
How to use checksums
58628a5e7ea34e1ed9f7cb1dbe0ca31d938bc9aab748a3ae5ecb253f0af92873
BLAKE2b-256 checksum
How to use checksums
a9e725a026cc6844657bc7abd366ddc7b0fb8a69503a0aed01cb313e0254b614
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.1 Windows/10

Release files / sengpt-0.1.2-py3-none-any.whl

Download URL sengpt-0.1.2-py3-none-any.whl
Size 35.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
420ded4a8e0e975002b6737e0c2b98b08b1148e31c6a77c9696de36cf284e798
BLAKE2b-256 checksum
How to use checksums
31464c38116306f780740abd8289643b11765370f9a251217e3510a268f256d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.1 Windows/10

Security for sengpt 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page