Skip to content

Commit

Permalink
feat: added g4f feature
Browse files Browse the repository at this point in the history
  • Loading branch information
kingmariano committed Jul 20, 2024
1 parent 74461d5 commit d1a98e3
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions g4f.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package omnicron

import "context"

type G4FRequest struct {
Messages []Message `json:"messages"`
Model string `json:"model,omitempty"`
Stream bool `json:"stream,omitempty"`
Proxy string `json:"proxy,omitempty"`
Timeout int `json:"timeout,omitempty"`
Shuffle bool `json:"shuffle,omitempty"`
ImageURL string `json:"image_url,omitempty"`
}

// this uses the g4f library by xtekky: https://github.com/xtekky/gpt4free
func (c *Client) GPT4Free(ctx context.Context, req *G4FRequest) (*GabsContainer, error){
if len(req.Messages) == 0 {
return nil, ErrGroqChatCompletionNoMessage
}
if req.Model == "" {
return nil, ErrModelNotFound
}
body, err := c.newJSONPostRequest(ctx, "/gpt4free", "", req)
if err != nil {
return nil, err
}
g4fResponse, err := unmarshalJSONResponse(body)
if err != nil {
return nil, err
}
return g4fResponse, nil
}

0 comments on commit d1a98e3

Please sign in to comment.