jschuur / chatgpt-repl Goto Github PK
View Code? Open in Web Editor NEWInteractive CLI for ChatGPT
Home Page: https://npmjs.com/package/chatgpt-repl
Interactive CLI for ChatGPT
Home Page: https://npmjs.com/package/chatgpt-repl
Turn this:
Session cost: $0.0008 (377 tokens)
Total cost: $10.1 (57619 tokens)
Into:
Session cost: $ 0.0008 (377 tokens)
Total cost: $10.10 (57,619 tokens)
For performance reasons, changing the system
mid-session clears the conversation history. But this means you can't use the .retry
command to rerun a prompt after you used .system
(up arrow still works though).
Ideally, save the last prompt separate from the conversation history, so the retry command behaves consistently.
.apikey [string]
lets you set API during a session..apikey
shows the last 6 digits of the key for security reasons
.settings
so it doesn't show the full API keyDoesn't quite seem as easy as chatgpt-repl -m text-davinci-002
e.g..
Check if other models have a different API/parameter set.
Take a prompt from the command line and output only the result with no additional UI/text (suitable to pipe into a file/another script/tool).
From REPL save interactive conversation to a file
This is the REPL prompt that currently says 'You:'.
Template with variables for settings, usage, time etc.
Also allow this for the startup message?
In true REPL style, navigate the previous user inputs via up/down arrow. Use cliffy?
Do I need to shut down readline entirely during this time?
Play back response with text to speech.
Use https://github.com/Marak/say.js?
Check out https://beta.elevenlabs.io/speech-synthesis (amazing audio, pretty expensive though).
Requires #20.
This needs more research. Ideally, you just run a .continue
command and it picks up where you left off, or asks you how much you want to (temporarily) raise the max token amount by.
Log usage into a SQLite database for per day/mode/API key. Can then show a usage sparkline.
Good excuse to use Drizzle (after migrating to TypeScript).
Response is 'unknown'.
.alias gpt4 '.model gpt4'
..chatgpt-repl.json
config file.Could use cli-highlight.
Would need to know the language for each code block (or assume a default). Could parse it out of the response text or use a (setable) default?
Make a list models API request when a key is added to verify that it's valid.
GPT-4's pricing is different from GPT-3, so this will need consideration in the usage tracking.
Total usage tracking should track usage per model too.
Requires #20
.usage
generates sparkline chartSeems to exit the chat loop if I try and use an ora spinner.
Have raised an isssue about this on ora repo.
During a Chat Completion API request, hit Ctrl-C to cancel it.
Use streamed-chatgpt-api.
See also: #46.
Minor issue: When exiting ChatGPT REPL by just hitting the enter key, the last prompt field shows 'undefined'. This is likely an issue with clack.
Inspired by https://github.com/BuilderIO/ai-shell
Better set the style of the response by changing the default from 'You are a helpful assistant'.
Take in a new string as a CLI option or a mid-conversation command (#3).
Streamed responses don't include usage info in the response. Would have to calculate this via [tiktoken])(https://github.com/dqbd/tiktoken) e.g., but that would be a big dependency for the project.
Alternatively, count chunks manually for rough estimate (more info).
Initially, .models
command just shows current internal list of compatible models (KNOWN_MODELS).
Related: #21 will let you update models from the API.
https://platform.openai.com/docs/guides/speech-to-text
Upload local audio file and use for transcription (or other prompt)
The try/catch doesn't seem to show all non-401 status code errors. It hits the catch
block, but ignore this part, leading to a confusing blank response when there's an issue with the openai.createChatCompletion
payload.
Line 98 in 8dd438a
Just doing console.error(error)
at the top of the catch block shows the error though.
Ideas after #29 implemented:
Hitting something like shift-enter should insert a newline into the prompt, rather than it sending off the response.
This might only be possible in GNU readline and not the Node.js one.
The history file should encode the newline in this case.
.model
command.models update
command forces an updateI usually use commander, but this time around, add better command line option handling of default values, the help and the version commands by using cac.
If a response contains a code segment, use a commend to copy just that
Use a regexp to extract based on triple backticks?
.copycode 1
copies the first block (use parse-numeric-range)Related: #32
Is this a 'response in this language' feature or 'translate this exact text to this language'.
May make more sense as an interactive translation feature.
Would just add 'answer in {language}' or 'translate to {language}' to the prompt.
Ideas:
.gpt-output
Subdirectory of local folder but default but support override.savecode
command to do this from the REPL if not on.savecode js
)~/.chatgptrepl
..chatgptrepl
.run [filename]
uses text from a local file to run a prompt.load [filename]
adds the contents of the file to the prompt, but you can still edit itSet variables and then use them, in a prompt.
Use case: reusing text in similar or related prompts.
.conversation
command asks if you want to create a new one or switch
.conversation new
or .conversation pick
does either right awayconversations
command to list conversationsSee also: #30.
Tab complete from list of known models
Change settings ($temperature=1.7
) or issue actions (!reset
or !retry
) for the prompt to affect the current session without exiting it.
PR is merged, but currently still in development branch.
Should be able to hit up arrow when starting a new session and get the last text entered.
.historylength
(.conversationlength
?) to avoid confusionA declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.