Updated to include a manual config specification if you want to try different models.
This commit is contained in:
parent
ba855d1622
commit
8f51a88997
|
@ -1,3 +1,4 @@
|
|||
.aider*
|
||||
.env
|
||||
*.png
|
||||
gonamer
|
||||
|
|
12
README.md
12
README.md
|
@ -4,7 +4,7 @@ Gonamer is a command-line tool written in Go that uses any openai compatible vi
|
|||
|
||||
## Features
|
||||
|
||||
- Uses OpenAI's vision model to analyze image content
|
||||
- Uses any OpenAI compatible vision model to analyze image content
|
||||
- Supports JPG, JPEG, PNG, and GIF formats
|
||||
- Generates unique, descriptive filenames
|
||||
- Handles filename conflicts automatically
|
||||
|
@ -22,7 +22,9 @@ go get gopkg.in/yaml.v3
|
|||
|
||||
## Configuration
|
||||
|
||||
Create a configuration file at `~/.config/gonamer.yaml` with the following structure:
|
||||
By default, Gonamer looks for a configuration file at `~/.config/gonamer.yaml`. You can also specify a custom configuration file using the `-c` flag.
|
||||
|
||||
Create a configuration file with the following structure:
|
||||
|
||||
```yaml
|
||||
apikey: "your-api-key"
|
||||
|
@ -38,12 +40,16 @@ Make sure to replace:
|
|||
## Usage
|
||||
|
||||
```bash
|
||||
gonamer <image_filename>
|
||||
gonamer [-c config.yaml] <image_filename>
|
||||
```
|
||||
|
||||
For example:
|
||||
```bash
|
||||
# Using default config at ~/.config/gonamer.yaml
|
||||
gonamer vacation_photo.jpg
|
||||
|
||||
# Using a custom config file
|
||||
gonamer -c custom-config.yaml vacation_photo.jpg
|
||||
```
|
||||
|
||||
The tool will:
|
||||
|
|
19
gonamer.go
19
gonamer.go
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -63,8 +64,12 @@ type Config struct {
|
|||
}
|
||||
|
||||
func main() {
|
||||
var configFile string
|
||||
flag.StringVar(&configFile, "c", "", "Path to config file")
|
||||
flag.Parse()
|
||||
|
||||
// Get the config file path
|
||||
configFilePath, err := getConfigFilePath()
|
||||
configFilePath, err := getConfigFilePath(configFile)
|
||||
if err != nil {
|
||||
log.Fatalf("Error getting config file path: %v", err)
|
||||
}
|
||||
|
@ -76,11 +81,12 @@ func main() {
|
|||
}
|
||||
|
||||
// Get the image filename from the command-line arguments
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println("Usage: go run main.go <image_filename>")
|
||||
if len(flag.Args()) < 1 {
|
||||
fmt.Println("Usage: gonamer [-c config.yaml] <image_filename>")
|
||||
flag.PrintDefaults()
|
||||
return
|
||||
}
|
||||
imageFilename := os.Args[1]
|
||||
imageFilename := flag.Arg(0)
|
||||
|
||||
// Validate the image filename extension
|
||||
if !ImageExtensionRegex.MatchString(imageFilename) {
|
||||
|
@ -106,7 +112,10 @@ func main() {
|
|||
}
|
||||
|
||||
// getConfigFilePath returns the path to the config file.
|
||||
func getConfigFilePath() (string, error) {
|
||||
func getConfigFilePath(configFile string) (string, error) {
|
||||
if configFile != "" {
|
||||
return configFile, nil
|
||||
}
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
Loading…
Reference in New Issue