mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-18 17:46:37 +08:00
fix: Implement improved headers for anthropic API requests.
Here is the summary of the commit in imperative tone and bullet points: - Update relay/adaptor/anthropic/adaptor.go to set default values for `anthropic-version` and `anthropic-beta` headers. - Refine condition for setting `anthropic-beta` header based on specific model types.
This commit is contained in:
parent
c1418df1fd
commit
ec4fd57ea6
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/Laisky/errors/v2"
|
"github.com/Laisky/errors/v2"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -34,6 +35,13 @@ func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *me
|
|||||||
}
|
}
|
||||||
req.Header.Set("anthropic-version", anthropicVersion)
|
req.Header.Set("anthropic-version", anthropicVersion)
|
||||||
req.Header.Set("anthropic-beta", "messages-2023-12-15")
|
req.Header.Set("anthropic-beta", "messages-2023-12-15")
|
||||||
|
|
||||||
|
// https://x.com/alexalbert__/status/1812921642143900036
|
||||||
|
// claude-3-5-sonnet can support 8k context
|
||||||
|
if strings.HasPrefix(meta.ActualModelName, "claude-3-5-sonnet") {
|
||||||
|
req.Header.Set("anthropic-beta", "max-tokens-3-5-sonnet-2024-07-15")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user