|
|
@@ -8,6 +8,7 @@ import (
|
|
|
"net/http"
|
|
|
"one-api/dto"
|
|
|
"one-api/relay/channel"
|
|
|
+ "one-api/relay/channel/openai"
|
|
|
relaycommon "one-api/relay/common"
|
|
|
"one-api/relay/constant"
|
|
|
"one-api/types"
|
|
|
@@ -33,6 +34,8 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
|
|
return fmt.Sprintf("%s/client/v4/accounts/%s/ai/v1/chat/completions", info.BaseUrl, info.ApiVersion), nil
|
|
|
case constant.RelayModeEmbeddings:
|
|
|
return fmt.Sprintf("%s/client/v4/accounts/%s/ai/v1/embeddings", info.BaseUrl, info.ApiVersion), nil
|
|
|
+ case constant.RelayModeResponses:
|
|
|
+ return fmt.Sprintf("%s/client/v4/accounts/%s/ai/v1/responses", info.BaseUrl, info.ApiVersion), nil
|
|
|
default:
|
|
|
return fmt.Sprintf("%s/client/v4/accounts/%s/ai/run/%s", info.BaseUrl, info.ApiVersion, info.UpstreamModelName), nil
|
|
|
}
|
|
|
@@ -57,8 +60,7 @@ func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayIn
|
|
|
}
|
|
|
|
|
|
func (a *Adaptor) ConvertOpenAIResponsesRequest(c *gin.Context, info *relaycommon.RelayInfo, request dto.OpenAIResponsesRequest) (any, error) {
|
|
|
- // TODO implement me
|
|
|
- return nil, errors.New("not implemented")
|
|
|
+ return request, nil
|
|
|
}
|
|
|
|
|
|
func (a *Adaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, requestBody io.Reader) (any, error) {
|
|
|
@@ -105,6 +107,12 @@ func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycom
|
|
|
} else {
|
|
|
err, usage = cfHandler(c, info, resp)
|
|
|
}
|
|
|
+ case constant.RelayModeResponses:
|
|
|
+ if info.IsStream {
|
|
|
+ usage, err = openai.OaiResponsesStreamHandler(c, info, resp)
|
|
|
+ } else {
|
|
|
+ usage, err = openai.OaiResponsesHandler(c, info, resp)
|
|
|
+ }
|
|
|
case constant.RelayModeAudioTranslation:
|
|
|
fallthrough
|
|
|
case constant.RelayModeAudioTranscription:
|