Skip to content

Commit 83f40db

Browse files
committed
Merge remote-tracking branch 'origin/master'
* origin/master: feat(ai): add audio generation support (goravel#1467) chore: Update non-major dependencies (goravel#1468) refactor(ai): rename agent response interfaces (goravel#1466) feat(ai): add image storage helpers (goravel#1465) chore: Update non-major dependencies (goravel#1464)
2 parents 87e5a66 + c78a1d9 commit 83f40db

59 files changed

Lines changed: 4009 additions & 927 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ai/application.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,15 @@ func (r *Application) Agent(agent contractsai.Agent, options ...contractsai.Opti
3636
return NewConversation(r.ctx, agent, provider, model, middlewares), nil
3737
}
3838

39-
func (r *Application) Image(prompt string, options ...contractsai.Option) contractsai.ImageRequest {
40-
return NewImageRequest(r.ctx, r, prompt, options...)
39+
func (r *Application) Audio(prompt string) contractsai.AudioRequest {
40+
return NewAudioRequest(r.ctx, r, prompt)
4141
}
4242

43-
func (r *Application) putFile(ctx context.Context, file contractsai.StorableFile, options ...contractsai.Option) (contractsai.StoredFileResponse, error) {
43+
func (r *Application) Image(prompt string) contractsai.ImageRequest {
44+
return NewImageRequest(r.ctx, r, prompt)
45+
}
46+
47+
func (r *Application) putFile(ctx context.Context, file contractsai.StorableFile, options ...contractsai.Option) (contractsai.FileResponse, error) {
4448
_, providerName, provider, err := r.resolveProvider(options)
4549
if err != nil {
4650
return nil, err
@@ -90,6 +94,23 @@ func (r *Application) deleteFile(ctx context.Context, id string, options ...cont
9094
return fileProvider.DeleteFile(ctx, id)
9195
}
9296

97+
func (r *Application) audio(ctx context.Context, prompt contractsai.AudioPrompt, options ...contractsai.Option) (contractsai.AudioResponse, error) {
98+
opts, providerName, provider, err := r.resolveProvider(options)
99+
if err != nil {
100+
return nil, err
101+
}
102+
if prompt.Model == "" {
103+
prompt.Model = opts.Model
104+
}
105+
106+
audioProvider, ok := provider.(contractsai.AudioProvider)
107+
if !ok {
108+
return nil, errors.AIProviderDoesNotSupportAudio.Args(providerName)
109+
}
110+
111+
return audioProvider.Audio(ctx, prompt)
112+
}
113+
93114
func (r *Application) image(ctx context.Context, prompt contractsai.ImagePrompt, options ...contractsai.Option) (contractsai.ImageResponse, error) {
94115
opts, providerName, provider, err := r.resolveProvider(options)
95116
if err != nil {

0 commit comments

Comments
 (0)