Skip to content

Commit e8ed2e4

Browse files
author
Kevin Jayne
authored
V0.4.0 (#42)
* update http error handling * update system message * config * check args * syntax * tts help * root flags * start diverge * cleanup * docker build * readme * readme * rm discord scrape command * discord user
1 parent 17aa0b6 commit e8ed2e4

17 files changed

+151
-493
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.github/
22
helm/
33
files/
4+
go.work*

.github/README.md

+16-22
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,24 @@ Visit your [API Keys](https://platform.openai.com/account/api-keys) page to retr
2020
###### ℹ️ You can omit keys for unused API endpoints
2121
```bash
2222
OPENAI_API_KEY={YOUR OPENAI API KEY}
23-
PRINTIFY_API_KEY={YOUR PRINTIFY API KEY}
2423
DISCORD_API_KEY={YOUR DISCORD BOT API KEY}
25-
DISCORD_PUB_KEY={YOUR DISCORD BOT PUB KEY}
2624
```
2725

2826

2927

3028
## Ponder a single thought
3129
### CLI
3230
```bash
33-
ponder --prompt "AI is Amazing"
31+
ponder "What is AI"
3432
```
3533
### Docker
3634
#### Running ponder in docker is exactly the same, but you have to provide the env vars when running
3735
```bash
38-
docker run -e OPENAI_API_KEY=$OPENAI_API_KEY ghcr.io/seemywingz/ponder:latest --prompt "Ai is Amazing"
36+
docker run -e OPENAI_API_KEY=$OPENAI_API_KEY ghcr.io/seemywingz/ponder:latest "What is AI"
3937
```
4038
#### Example Output
4139
```bash
42-
AI is indeed amazing. It has the potential to revolutionize many industries, from healthcare to transportation. AI can help automate mundane tasks, allowing humans to focus on more complex and creative tasks. AI can also be used to analyze large amounts of data quickly and accurately, helping to make better decisions. AI can also be used to create personalized experiences for customers, making them feel more connected to a company or product.
40+
AI, or Artificial Intelligence, refers to the simulation of human intelligence processes by machines, especially computer systems. These processes include learning (the acquisition of information and rules for using the information), reasoning (using the rules to reach approximate or definite conclusions), and self-correction.
4341
```
4442

4543
## A small chat
@@ -48,22 +46,19 @@ ponder --convo
4846
```
4947
#### Example Ouput
5048
```bash
51-
You:
52-
Hello, Ponder
49+
Ponder:
50+
Hello! How can I assist you today?
5351

54-
Ponder:
55-
Hello there! How can I help you?
52+
You:
53+
You are so helpful
5654

57-
You:
58-
you already have thank you
59-
60-
Ponder:
61-
Thank you for your kind words!
55+
Ponder:
56+
Thank you for your kind words! I'm here to help. If you have any questions or need assistance with something, feel free to ask.
6257
```
6358
6459
## Image Generation
6560
```bash
66-
ponder image -p "a ferocious cat with wings and fire"
61+
ponder image "a ferocious cat with wings and fire"
6762
```
6863
#### Example Ouput
6964
```bash
@@ -73,13 +68,13 @@ ponder image -p "a ferocious cat with wings and fire"
7368
7469
### You can always refer to the `--help` menu as well.
7570
```yaml
71+
7672
Ponder
7773
GitHub: https://github.com/seemywingz/ponder
78-
App Version: v0.3.0
74+
App Version: v0.4.0
7975
8076
Ponder uses OpenAI's API to generate text responses to user input.
81-
You can use Ponder as a Discord chat bot or to generate images using the DALL-E API.
82-
Or whatever else you can think of...
77+
Or whatever else you can think of. 🤔
8378

8479
Usage:
8580
ponder [flags]
@@ -92,16 +87,15 @@ Available Commands:
9287
discord-bot Discord Chat Bot Integration
9388
help Help about any command
9489
image Generate an image from a prompt
95-
printify Interact with the Printify API
90+
tts OpenAI Text to Speech API - TTS
9691

9792
Flags:
9893
--config string config file
9994
-c, --convo Conversational Style chat
10095
-h, --help help for ponder
101-
-x, --perform Attempt to perform the response as cli command
102-
-p, --prompt string Prompt AI generation
103-
-s, --say Say text out loud (MacOS only)
96+
--narrate Narrate the response using TTS and the default audio output
10497
-v, --verbose verbose output
98+
--voice string Voice to use: alloy, ash, coral, echo, fable, onyx, nova, sage and shimmer (default "onyx")
10599

106100
Use "ponder [command] --help" for more information about a command.
107101
```

Dockerfile

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
2-
FROM golang:1.21.5-alpine3.19 AS builder
3-
ENV APP_NAME ponder
4-
ENV WORKDIR /app
1+
FROM golang:1.23.4-alpine3.21 AS builder
2+
ENV APP_NAME=ponder
3+
ENV WORKDIR=/app
54
WORKDIR $WORKDIR
65
COPY . .
6+
RUN apk add --no-cache build-base pkgconfig alsa-lib-dev
77
RUN go mod download
88
RUN go build -o /$APP_NAME
99

1010
## Deploy
11-
FROM alpine:3.19.0
12-
ENV APP_NAME ponder
11+
FROM alpine:3.21.0
12+
ENV APP_NAME=ponder
1313
WORKDIR /
1414
COPY --from=builder /$APP_NAME /$APP_NAME
1515
ENTRYPOINT ["/ponder"]

cmd/Discord_api.go

+1-29
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ func deregisterCommands() {
7272
func registerCommands() {
7373

7474
commands := []*discordgo.ApplicationCommand{
75-
{
76-
Name: "scrape",
77-
Description: "Scrape Discord channel for Upscaled Midjourney Images",
78-
},
7975
{
8076
Name: "ponder-image",
8177
Description: "Use DALL-E 3 to generate an Image",
@@ -100,8 +96,6 @@ func registerCommands() {
10096
func handleCommands(s *discordgo.Session, i *discordgo.InteractionCreate) {
10197
discordInitialResponse("Pondering...", s, i)
10298
switch i.ApplicationCommandData().Name {
103-
case "scrape":
104-
discordScrapeImages(s, i)
10599
case "ponder-image":
106100
discordPonderImage(s, i)
107101
default: // Handle unknown slash commands
@@ -159,7 +153,7 @@ func discordOpenAIResponse(s *discordgo.Session, m *discordgo.MessageCreate, men
159153
}
160154

161155
// Send the messages to OpenAI
162-
ai.User = ai.User + m.Author.Username
156+
ai.User = "discord" + s.State.User.Username
163157
oaiResponse, err := ai.ChatCompletion(openaiMessages)
164158
catchErr(err)
165159
s.ChannelMessageSend(m.ChannelID, oaiResponse.Choices[0].Message.Content)
@@ -183,28 +177,6 @@ func discordPonderImage(s *discordgo.Session, i *discordgo.InteractionCreate) {
183177

184178
}
185179

186-
func discordScrapeImages(s *discordgo.Session, i *discordgo.InteractionCreate) {
187-
// Get the interaction channel ID
188-
channelID := i.ChannelID
189-
discord.ChannelTyping(channelID)
190-
messages, err := discord.ChannelMessages(channelID, 100, "", "", "")
191-
catchErr(err)
192-
discordFollowUp("Scraping Discord Channel for ALL Image URLs and sending them to #saved-images.\nAll `Upscaled` Midjourney Images will be sent to Printify as well...", s, i)
193-
194-
savedImagesChannelID := discordGetChannelID(s, i.GuildID, "saved-images")
195-
196-
for _, v := range messages {
197-
if len(v.Attachments) > 0 {
198-
url := v.Attachments[0].URL
199-
s.ChannelMessageSend(savedImagesChannelID, url)
200-
if strings.Contains(v.Content, "Upscaled") {
201-
printify_UploadImage(fileNameFromURL(url), url)
202-
}
203-
}
204-
}
205-
206-
}
207-
208180
func discordInitialResponse(content string, s *discordgo.Session, i *discordgo.InteractionCreate) {
209181
// Send initial defer response.
210182
response := &discordgo.InteractionResponse{

cmd/GPIOPin.go

-61
This file was deleted.

cmd/Printify_api.go

-52
This file was deleted.

cmd/Printify_json.go

-17
This file was deleted.

cmd/chat.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ var chatCmd = &cobra.Command{
2222
Use: "chat",
2323
Short: "Open ended chat with OpenAI",
2424
Long: ``,
25-
Args: cobra.ExactArgs(1), // Expect exactly one argument
25+
Args: func(cmd *cobra.Command, args []string) error {
26+
return checkArgs(args)
27+
},
2628
Run: func(cmd *cobra.Command, args []string) {
27-
prompt := args[0]
29+
2830
var err error
2931
if convo {
3032
for {
@@ -68,7 +70,7 @@ func chatCompletion(prompt string) string {
6870

6971
// Send the messages to OpenAI
7072
res, err := ai.ChatCompletion(ponderMessages)
71-
catchErr(err)
73+
catchErr(err, "fatal")
7274
ponderMessages = append(ponderMessages, goai.Message{
7375
Role: "assistant",
7476
Content: res.Choices[0].Message.Content,

cmd/image.go

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ var imageCmd = &cobra.Command{
2525
Use: "image",
2626
Short: "Generate an image from a prompt",
2727
Long: ``,
28+
Args: func(cmd *cobra.Command, args []string) error {
29+
return checkArgs(args)
30+
},
2831
Run: func(cmd *cobra.Command, args []string) {
2932
createImage(prompt, imageFile)
3033
},

cmd/printify.go

-45
This file was deleted.

0 commit comments

Comments
 (0)