Skip to content

Commit

Permalink
chore: add withClient to packages using openai (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
henomis authored Jun 13, 2023
1 parent 4090215 commit 1cabb13
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions embedder/openai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func New(model Model) *openAIEmbedder {
}
}

func (o *openAIEmbedder) WithAPIKey(apiKey string) *openAIEmbedder {
o.openAIClient = openai.NewClient(apiKey)
func (o *openAIEmbedder) WithClient(client *openai.Client) *openAIEmbedder {
o.openAIClient = client
return o
}

Expand Down
4 changes: 2 additions & 2 deletions llm/openai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func (o *openAI) WithStop(stop []string) *openAI {
return o
}

func (o *openAI) WithAPIKey(apiKey string) *openAI {
o.openAIClient = openai.NewClient(apiKey)
func (o *openAI) WithClient(client *openai.Client) *openAI {
o.openAIClient = client
return o
}

Expand Down
4 changes: 2 additions & 2 deletions loader/whisper.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func NewWhisperLoader(filename string) *whisperLoader {
}
}

func (w *whisperLoader) WithOpenAIApiKey(openAIApiKey string) *whisperLoader {
w.openAIClient = openai.NewClient(openAIApiKey)
func (w *whisperLoader) WithClient(client *openai.Client) *whisperLoader {
w.openAIClient = client
return w
}

Expand Down
5 changes: 5 additions & 0 deletions prompt/whisper.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func NewPromptFromAudioFile(ctx context.Context, filePath string, audioResponseF
}, nil
}

func (p *whisperPrompt) WithClient(client *openai.Client) *whisperPrompt {
p.openAIClient = client
return p
}

func (p *whisperPrompt) Format(input types.M) error {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions transformer/dall-e.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func NewDallE() *DallE {
}
}

func (d *DallE) WithAPIKey(apiKey string) *DallE {
d.openAIClient = openai.NewClient(apiKey)
func (d *DallE) WithClient(client *openai.Client) *DallE {
d.openAIClient = client
return d
}

Expand Down

0 comments on commit 1cabb13

Please sign in to comment.