dto.go 2.0 KB

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