Skip to content

Commit

Permalink
docs: add example gif
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Dec 5, 2022
1 parent c361da9 commit 9d40862
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 2 deletions.
Binary file added media/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions media/demo.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# VHS documentation
#
# @see https://github.com/charmbracelet/vhs
#
# ```
# vhs < media/demo.tape
# ```
#
# Output:
# Output <path>.gif Create a GIF output at the given <path>
# Output <path>.mp4 Create an MP4 output at the given <path>
# Output <path>.webm Create a WebM output at the given <path>
#
# Require:
# Require <string> Ensure a program is on the $PATH to proceed
#
# Settings:
# Set FontSize <number> Set the font size of the terminal
# Set FontFamily <string> Set the font family of the terminal
# Set Height <number> Set the height of the terminal
# Set Width <number> Set the width of the terminal
# Set LetterSpacing <float> Set the font letter spacing (tracking)
# Set LineHeight <float> Set the font line height
# Set LoopOffset <float>% Set the starting frame offset for the GIF loop
# Set Theme <json|string> Set the theme of the terminal
# Set Padding <number> Set the padding of the terminal
# Set Framerate <number> Set the framerate of the recording
# Set PlaybackSpeed <float> Set the playback speed of the recording
#
# Sleep:
# Sleep <time> Sleep for a set amount of <time> in seconds
#
# Type:
# Type[@<time>] "<characters>" Type <characters> into the terminal with a
# <time> delay between each character
#
# Keys:
# Backspace[@<time>] [number] Press the Backspace key
# Down[@<time>] [number] Press the Down key
# Enter[@<time>] [number] Press the Enter key
# Space[@<time>] [number] Press the Space key
# Tab[@<time>] [number] Press the Tab key
# Left[@<time>] [number] Press the Left Arrow key
# Right[@<time>] [number] Press the Right Arrow key
# Up[@<time>] [number] Press the Up Arrow key
# Down[@<time>] [number] Press the Down Arrow key
# Ctrl+<key> Press the Control key + <key> (e.g. Ctrl+C)
#
# Display:
# Hide Hide the subsequent commands from the output
# Show Show the subsequent commands in the output

Output media/demo.gif

Hide
Require npx

#Set Shell bash
Set FontSize 17
Set Width 1200
Set Height 600
Set Padding 24
Set LoopOffset 75%

Type " "

Sleep 980ms
Backspace 1
Show
Type "npx tsx src/example.ts"
Sleep 500ms
Enter
Show

Sleep 8s
Sleep 8s
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"husky": "^8.0.2",
"lint-staged": "^13.0.3",
"npm-run-all": "^4.1.5",
"ora": "^6.1.2",
"prettier": "^2.8.0",
"tsup": "^6.5.0",
"tsx": "^3.12.1",
Expand Down
123 changes: 123 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<p align="center">
<img alt="Example usage" src="/media/demo.gif">
</p>

# ChatGPT API <!-- omit in toc -->

> Node.js client for the unofficial [ChatGPT](https://openai.com/blog/chatgpt/) API.
Expand Down
8 changes: 6 additions & 2 deletions src/example.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dotenv from 'dotenv-safe'
import { oraPromise } from 'ora'

import { ChatGPTAPI } from './chatgpt-api'

Expand All @@ -11,9 +12,12 @@ async function main() {
const api = new ChatGPTAPI({ sessionToken: process.env.SESSION_TOKEN })
await api.ensureAuth()

const response = await api.sendMessage(
const prompt =
'Write a python version of bubble sort. Do not include example usage.'
)

const response = await oraPromise(api.sendMessage(prompt), {
text: prompt
})

return response
}
Expand Down

0 comments on commit 9d40862

Please sign in to comment.