mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 13:00:52 +08:00
Fix alt parameter handling in URL construction
- Ensured `alt` parameter is only appended when non-empty. - Added debug logging for constructed URLs.
This commit is contained in:
@@ -260,7 +260,9 @@ func (c *Client) APIRequest(ctx context.Context, endpoint string, body interface
|
|||||||
if alt == "" && stream {
|
if alt == "" && stream {
|
||||||
url = url + "?alt=sse"
|
url = url + "?alt=sse"
|
||||||
} else {
|
} else {
|
||||||
url = url + fmt.Sprintf("?$alt=%s", alt)
|
if alt != "" {
|
||||||
|
url = url + fmt.Sprintf("?$alt=%s", alt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if endpoint == "countTokens" {
|
if endpoint == "countTokens" {
|
||||||
@@ -272,7 +274,9 @@ func (c *Client) APIRequest(ctx context.Context, endpoint string, body interface
|
|||||||
if alt == "" && stream {
|
if alt == "" && stream {
|
||||||
url = url + "?alt=sse"
|
url = url + "?alt=sse"
|
||||||
} else {
|
} else {
|
||||||
url = url + fmt.Sprintf("?$alt=%s", alt)
|
if alt != "" {
|
||||||
|
url = url + fmt.Sprintf("?$alt=%s", alt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
jsonBody = []byte(gjson.GetBytes(jsonBody, "request").Raw)
|
jsonBody = []byte(gjson.GetBytes(jsonBody, "request").Raw)
|
||||||
systemInstructionResult := gjson.GetBytes(jsonBody, "systemInstruction")
|
systemInstructionResult := gjson.GetBytes(jsonBody, "systemInstruction")
|
||||||
@@ -285,6 +289,7 @@ func (c *Client) APIRequest(ctx context.Context, endpoint string, body interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// log.Debug(string(jsonBody))
|
// log.Debug(string(jsonBody))
|
||||||
|
// log.Debug(url)
|
||||||
reqBody := bytes.NewBuffer(jsonBody)
|
reqBody := bytes.NewBuffer(jsonBody)
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "POST", url, reqBody)
|
req, err := http.NewRequestWithContext(ctx, "POST", url, reqBody)
|
||||||
|
|||||||
Reference in New Issue
Block a user