mirror of
https://github.com/hanzo-go/openai.git
synced 2026-09-24 00:31:39 +00:00
The fork kept the upstream module path (module github.com/sashabaranov/ go-openai), so every consumer could only reach it through a "replace github.com/sashabaranov/go-openai => github.com/hanzoai/go-openai" directive — and Go replace directives do NOT propagate to consumers, so each downstream repo had to copy the same replace or fail to compile against fork-only fields (e.g. ReasoningContent). That is the opposite of one-and- only-one-way. Declare the fork's OWN module path so it can be required directly and inherited transitively. Package name stays 'openai' (import identifier unchanged); only the module path + internal self-imports (/internal, /jsonschema) are renamed. Upstream issue-URL comments are left intact as attribution. Builds + vets clean. Co-authored-by: Hanzo Dev <[email protected]>
36 lines
649 B
Go
36 lines
649 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/hanzoai/go-openai"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) < 2 {
|
|
fmt.Println("please provide a filename to convert to text")
|
|
return
|
|
}
|
|
if _, err := os.Stat(os.Args[1]); errors.Is(err, os.ErrNotExist) {
|
|
fmt.Printf("file %s does not exist\n", os.Args[1])
|
|
return
|
|
}
|
|
|
|
client := openai.NewClient(os.Getenv("OPENAI_API_KEY"))
|
|
resp, err := client.CreateTranscription(
|
|
context.Background(),
|
|
openai.AudioRequest{
|
|
Model: openai.Whisper1,
|
|
FilePath: os.Args[1],
|
|
},
|
|
)
|
|
if err != nil {
|
|
fmt.Printf("Transcription error: %v\n", err)
|
|
return
|
|
}
|
|
fmt.Println(resp.Text)
|
|
}
|