Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mleidel/gptcmd
A command line AI client for Windows/Linux/ARM written in Go using the Open-AI API
https://github.com/mleidel/gptcmd
ai golang gpt-4 linux-shell openai windows-11
Last synced: 6 days ago
JSON representation
A command line AI client for Windows/Linux/ARM written in Go using the Open-AI API
- Host: GitHub
- URL: https://github.com/mleidel/gptcmd
- Owner: MLeidel
- License: gpl-3.0
- Created: 2023-12-08T16:46:21.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2023-12-10T20:33:21.000Z (10 months ago)
- Last Synced: 2024-09-24T21:03:46.991Z (9 days ago)
- Topics: ai, golang, gpt-4, linux-shell, openai, windows-11
- Language: Go
- Homepage:
- Size: 16.7 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gptcmd
**A command line AI chat client for windows
and linux written in Go using the OpenAI API**Requires 2 Environment Variables:
> GPTKEY="your OpenAI key" (required)
GPTMOD="engine model" (required)
GPTWRAP="line wrap length" (optional)
GPTTMP="temperature" (optional)Type your prompt on the command-line.
```bash
$> gptcmd Hello my prompt is everything I type after gptcmd ...```
A log of requests is kept in file _HOME_/gptcmd.log
for Windows _USERPROFILE_/gptcmd.logCompiled versions are offered here to use at your own risk.
The source is here as well. Install Golang and compile yourself:
```bash
$> GOOS=linux GOARCH=386 go build gptcmd.go # linux
$> GOOS=windows GOARCH=386 go build gptcmd.go # windows
$> GOOS=linux GOARCH=arm GOARM=5 go build gptcmd.go # raspberry pi```
---
**gptcmd**, **GptCLI**, and **gptcom** are basically
go, c, and python versions of the following bash script:```bash
#!/bin/bashMODEL="gpt-4"
read -p "Enter prompt: " PROMPT
RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${GPTKEY}" \
-d '{
"model": "'"$MODEL"'",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "'"$PROMPT"'"
}
]
}')date
echo "You said: ${PROMPT}"
echo "-------"
echo $RESPONSE | jq -r '.choices[0].message.content'
```