Skip to main content

Text ChatGPT Connector

The Text ChatGPT Connector is a simple script for connecting text files and ChatGPT.

Forked from scrapbox_chatgpt_connector.

Ref: https://scrapbox.io/villagepump/Scrapbox_ChatGPT_Connector

How to install

Install by pip:

$ pip install text_chatgpt_connector

Or you can use repository directly. Install Poetry and run

$ poetry install
$ poetry run tcc ...

You can run `tcc directly if you enter the poetry virtual environment:

$ poetry shell

How to use

Make index

To make index, run:

$ tcc index -i <input_dir>

input_dir is the directory which has text files (with suffix of .txt, .md or .markdown by default).

This will create pickle file named index.pickle. If you want to change the name, set -o <output_file>.

If you run with different input_dir for the same output_file, the index is appended to the previous one.

Ask question

To ask a question, run:

$ tcc ask -q  "もっとも大事な問いとは何だろう?"

If you want compare the answer without index, run with -n (--no_index) option:

$ tcc ask -n -q  "もっとも大事な問いとは何だろう?"

Usage

usage: tcc [-h] [-i INPUT_DIR] [-s INPUT_SUFFIX] [-o OUTPUT_FILE] [-k KEY] [-c CHARACTER_ENCODING] [--chat_model CHAT_MODEL]
           [--encoding ENCODING] [--embedding EMBEDDING] [--remain_url] [--keep_spaces] [--block_size BLOCK_SIZE]
           [--embed_max_size EMBED_MAX_SIZE] [--max_prompt_size MAX_PROMPT_SIZE] [--return_size RETURN_SIZE] [--prompt PROMPT]
           [--bare_prompt BARE_PROMPT] [-q QUESTION] [-n] [-v]
           [command]

positional arguments:
  command               Command (index or ask)

options:
  -h, --help            show this help message and exit
  -i INPUT_DIR, --input_dir INPUT_DIR
                        Input directory
  -s INPUT_SUFFIX, --input_suffix INPUT_SUFFIX
                        Comma separated suffixes of input files, "txt,md,markdown"
  -o OUTPUT_FILE, --output_file OUTPUT_FILE
                        Output file (pickle), default: "index.pickle"
  -k KEY, --key KEY     OpenAI API key. If not given, try to get from environment variable: OPENAI_API_KEY.
  -c CHARACTER_ENCODING, --character_encoding CHARACTER_ENCODING
                        Character encoding for input file, default: "utf-8"
  --chat_model CHAT_MODEL
                        Chat model name, default: "gpt-3.5-turbo"
  --encoding ENCODING   Encoding name for tiktoken, default: "cl100k_base"
  --embedding EMBEDDING
                        Embedding model name, default: "text-embedding-ada-002"
  --remain_url          Keep URL in the text
  --keep_spaces         Keep spaces in the text
  --block_size BLOCK_SIZE
                        Block size for embedding, default: 500
  --embed_max_size EMBED_MAX_SIZE
                        Max size for embedding, default: 8150
  --max_prompt_size MAX_PROMPT_SIZE
                        Max size for prompt, default: 4096
  --return_size RETURN_SIZE
                        Return size, default: 250
  --prompt PROMPT       Prompt template, default: "Read the following text and answer the question. Your reply should be shorter
                        than 250 characters. ## Text {text} ## Question {question}"
  --bare_prompt BARE_PROMPT
                        Prompt template without index, default: "Read the following text and answer the question. Your reply
                        should be shorter than 250 characters. ## Text {text} ## Question {question}"
  -q QUESTION, --question QUESTION
                        Question words for ask, default: "What is the most important question?"
  -n, --no_index        Ask the question directly
  -v, --version         Show version

Metadata

Release files for text-chatgpt-connector 0.0.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 text-chatgpt-connector 0.0.2
File Size Uploaded Provenance
text_chatgpt_connector-0.0.2.tar.gz 7.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for text-chatgpt-connector 0.0.2
File Interpreter ABI Platform
text_chatgpt_connector-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.9 kB

Release files / text_chatgpt_connector-0.0.2.tar.gz

Download URL text_chatgpt_connector-0.0.2.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2cd2d3de3cb9310507ef82facb0e3e098c0abb76918a919faa8eedbf67aab757
BLAKE2b-256 checksum
How to use checksums
212a1e5fd4015459a51540f0fbce72b1227ebfd57752e303e0a7c2b43d1c5db1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.11.2 Linux/5.15.90.1-microsoft-standard-WSL2

Release files / text_chatgpt_connector-0.0.2-py3-none-any.whl

Download URL text_chatgpt_connector-0.0.2-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4728cbe9ed90f4fc32119639146d1ef664c1b36b7d6e00ec3c9629e8e883c46
BLAKE2b-256 checksum
How to use checksums
c493b48386d1c5b2b63c16b042b0fdbae4eb1367f101c9ecc427731786a7307a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.11.2 Linux/5.15.90.1-microsoft-standard-WSL2

Security for text-chatgpt-connector 0.0.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.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

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