feat: openai response /v1/response/compact (#2644)
* feat: openai response /v1/response/compact * feat: /v1/response/compact bill * feat: /v1/response/compact * feat: /v1/responses/compact -> codex channel * feat: /v1/responses/compact -> codex channel * feat: /v1/responses/compact -> codex channel * feat: codex channel default models * feat: compact model price * feat: /v1/responses/comapct test
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/QuantumNous/new-api/types"
|
||||
)
|
||||
|
||||
type OpenAIResponsesCompactionResponse struct {
|
||||
ID string `json:"id"`
|
||||
Object string `json:"object"`
|
||||
CreatedAt int `json:"created_at"`
|
||||
Output json.RawMessage `json:"output"`
|
||||
Usage *Usage `json:"usage"`
|
||||
Error any `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
func (o *OpenAIResponsesCompactionResponse) GetOpenAIError() *types.OpenAIError {
|
||||
return GetOpenAIError(o.Error)
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/QuantumNous/new-api/types"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type OpenAIResponsesCompactionRequest struct {
|
||||
Model string `json:"model"`
|
||||
Input json.RawMessage `json:"input,omitempty"`
|
||||
Instructions json.RawMessage `json:"instructions,omitempty"`
|
||||
PreviousResponseID string `json:"previous_response_id,omitempty"`
|
||||
}
|
||||
|
||||
func (r *OpenAIResponsesCompactionRequest) GetTokenCountMeta() *types.TokenCountMeta {
|
||||
var parts []string
|
||||
if len(r.Instructions) > 0 {
|
||||
parts = append(parts, string(r.Instructions))
|
||||
}
|
||||
if len(r.Input) > 0 {
|
||||
parts = append(parts, string(r.Input))
|
||||
}
|
||||
return &types.TokenCountMeta{
|
||||
CombineText: strings.Join(parts, "\n"),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *OpenAIResponsesCompactionRequest) IsStream(c *gin.Context) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *OpenAIResponsesCompactionRequest) SetModelName(modelName string) {
|
||||
if modelName != "" {
|
||||
r.Model = modelName
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user