Skip to content

Commit 75a182a

Browse files
committed
Fix pollinations provider
1 parent 328056e commit 75a182a

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/providers/pollinations/pollinations.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ import (
1616

1717
type RequestBody struct {
1818
Model string `json:"model"`
19-
Referrer string `json:"referrer"`
2019
Stream bool `json:"stream"`
2120
Messages []any `json:"messages"`
22-
Temperature string `json:"temperature"`
23-
Top_p string `json:"top_p"`
21+
2422
}
2523

2624
func NewRequest(input string, params structs.Params) (*http.Response, error) {
@@ -33,9 +31,6 @@ func NewRequest(input string, params structs.Params) (*http.Response, error) {
3331
requestInfo := RequestBody{
3432
Model: "openai",
3533
Stream: true,
36-
Referrer: "tgpt",
37-
Temperature: "1",
38-
Top_p: "1",
3934
}
4035

4136
apiKey := params.ApiKey
@@ -44,13 +39,13 @@ func NewRequest(input string, params structs.Params) (*http.Response, error) {
4439
requestInfo.Model = params.ApiModel
4540
}
4641

47-
if params.Temperature != "" {
48-
requestInfo.Temperature = params.Temperature
49-
}
42+
// if params.Temperature != "" {
43+
// requestInfo.Temperature = params.Temperature
44+
// }
5045

51-
if params.Top_p != "" {
52-
requestInfo.Top_p = params.Top_p
53-
}
46+
// if params.Top_p != "" {
47+
// requestInfo.Top_p = params.Top_p
48+
// }
5449

5550
systemMessage := structs.DefaultMessage{
5651
Role: "system",
@@ -79,7 +74,13 @@ func NewRequest(input string, params structs.Params) (*http.Response, error) {
7974

8075
}
8176

82-
req, err := http.NewRequest("POST", "https://text.pollinations.ai/openai", bytes.NewBuffer(jsonRequest))
77+
apiUrl := "https://text.pollinations.ai/openai"
78+
79+
if apiKey != "" {
80+
apiUrl = "https://gen.pollinations.ai/v1/chat/completions"
81+
}
82+
83+
req, err := http.NewRequest("POST", apiUrl, bytes.NewBuffer(jsonRequest))
8384

8485
if err != nil {
8586
log.Fatal("Some error has occured.\nError:", err)

0 commit comments

Comments
 (0)