dto.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package zhipu_4v
  2. import (
  3. "time"
  4. "github.com/QuantumNous/new-api/dto"
  5. "github.com/QuantumNous/new-api/types"
  6. )
  7. // type ZhipuMessage struct {
  8. // Role string `json:"role,omitempty"`
  9. // Content string `json:"content,omitempty"`
  10. // ToolCalls any `json:"tool_calls,omitempty"`
  11. // ToolCallId any `json:"tool_call_id,omitempty"`
  12. // }
  13. //
  14. // type ZhipuRequest struct {
  15. // Model string `json:"model"`
  16. // Stream bool `json:"stream,omitempty"`
  17. // Messages []ZhipuMessage `json:"messages"`
  18. // Temperature float64 `json:"temperature,omitempty"`
  19. // TopP float64 `json:"top_p,omitempty"`
  20. // MaxTokens int `json:"max_tokens,omitempty"`
  21. // Stop []string `json:"stop,omitempty"`
  22. // RequestId string `json:"request_id,omitempty"`
  23. // Tools any `json:"tools,omitempty"`
  24. // ToolChoice any `json:"tool_choice,omitempty"`
  25. // }
  26. //
  27. // type ZhipuV4TextResponseChoice struct {
  28. // Index int `json:"index"`
  29. // ZhipuMessage `json:"message"`
  30. // FinishReason string `json:"finish_reason"`
  31. // }
  32. type ZhipuV4Response struct {
  33. Id string `json:"id"`
  34. Created int64 `json:"created"`
  35. Model string `json:"model"`
  36. TextResponseChoices []dto.OpenAITextResponseChoice `json:"choices"`
  37. Usage dto.Usage `json:"usage"`
  38. Error types.OpenAIError `json:"error"`
  39. }
  40. //
  41. //type ZhipuV4StreamResponseChoice struct {
  42. // Index int `json:"index,omitempty"`
  43. // Delta ZhipuMessage `json:"delta"`
  44. // FinishReason *string `json:"finish_reason,omitempty"`
  45. //}
  46. type ZhipuV4StreamResponse struct {
  47. Id string `json:"id"`
  48. Created int64 `json:"created"`
  49. Choices []dto.ChatCompletionsStreamResponseChoice `json:"choices"`
  50. Usage dto.Usage `json:"usage"`
  51. }
  52. type tokenData struct {
  53. Token string
  54. ExpiryTime time.Time
  55. }