-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74461d5
commit d1a98e3
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |