dto.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package cohere
  2. import "one-api/dto"
  3. type CohereRequest struct {
  4. Model string `json:"model"`
  5. ChatHistory []ChatHistory `json:"chat_history"`
  6. Message string `json:"message"`
  7. Stream bool `json:"stream"`
  8. MaxTokens int `json:"max_tokens"`
  9. SafetyMode string `json:"safety_mode,omitempty"`
  10. }
  11. type ChatHistory struct {
  12. Role string `json:"role"`
  13. Message string `json:"message"`
  14. }
  15. type CohereResponse struct {
  16. IsFinished bool `json:"is_finished"`
  17. EventType string `json:"event_type"`
  18. Text string `json:"text,omitempty"`
  19. FinishReason string `json:"finish_reason,omitempty"`
  20. Response *CohereResponseResult `json:"response"`
  21. }
  22. type CohereResponseResult struct {
  23. ResponseId string `json:"response_id"`
  24. FinishReason string `json:"finish_reason,omitempty"`
  25. Text string `json:"text"`
  26. Meta CohereMeta `json:"meta"`
  27. }
  28. type CohereRerankRequest struct {
  29. Documents []any `json:"documents"`
  30. Query string `json:"query"`
  31. Model string `json:"model"`
  32. TopN int `json:"top_n"`
  33. ReturnDocuments bool `json:"return_documents"`
  34. }
  35. type CohereRerankResponseResult struct {
  36. Results []dto.RerankResponseResult `json:"results"`
  37. Meta CohereMeta `json:"meta"`
  38. }
  39. type CohereMeta struct {
  40. //Tokens CohereTokens `json:"tokens"`
  41. BilledUnits CohereBilledUnits `json:"billed_units"`
  42. }
  43. type CohereBilledUnits struct {
  44. InputTokens int `json:"input_tokens"`
  45. OutputTokens int `json:"output_tokens"`
  46. }
  47. type CohereTokens struct {
  48. InputTokens int `json:"input_tokens"`
  49. OutputTokens int `json:"output_tokens"`
  50. }