openai_responses_compaction_request.go 980 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package dto
  2. import (
  3. "encoding/json"
  4. "strings"
  5. "github.com/QuantumNous/new-api/types"
  6. "github.com/gin-gonic/gin"
  7. )
  8. type OpenAIResponsesCompactionRequest struct {
  9. Model string `json:"model"`
  10. Input json.RawMessage `json:"input,omitempty"`
  11. Instructions json.RawMessage `json:"instructions,omitempty"`
  12. PreviousResponseID string `json:"previous_response_id,omitempty"`
  13. }
  14. func (r *OpenAIResponsesCompactionRequest) GetTokenCountMeta() *types.TokenCountMeta {
  15. var parts []string
  16. if len(r.Instructions) > 0 {
  17. parts = append(parts, string(r.Instructions))
  18. }
  19. if len(r.Input) > 0 {
  20. parts = append(parts, string(r.Input))
  21. }
  22. return &types.TokenCountMeta{
  23. CombineText: strings.Join(parts, "\n"),
  24. }
  25. }
  26. func (r *OpenAIResponsesCompactionRequest) IsStream(c *gin.Context) bool {
  27. return false
  28. }
  29. func (r *OpenAIResponsesCompactionRequest) SetModelName(modelName string) {
  30. if modelName != "" {
  31. r.Model = modelName
  32. }
  33. }