dto.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 int64 `json:"max_tokens"`
  9. }
  10. type ChatHistory struct {
  11. Role string `json:"role"`
  12. Message string `json:"message"`
  13. }
  14. type CohereResponse struct {
  15. IsFinished bool `json:"is_finished"`
  16. EventType string `json:"event_type"`
  17. Text string `json:"text,omitempty"`
  18. FinishReason string `json:"finish_reason,omitempty"`
  19. Response *CohereResponseResult `json:"response"`
  20. }
  21. type CohereResponseResult struct {
  22. ResponseId string `json:"response_id"`
  23. FinishReason string `json:"finish_reason,omitempty"`
  24. Text string `json:"text"`
  25. Meta CohereMeta `json:"meta"`
  26. }
  27. type CohereRerankRequest struct {
  28. Documents []any `json:"documents"`
  29. Query string `json:"query"`
  30. Model string `json:"model"`
  31. TopN int `json:"top_n"`
  32. ReturnDocuments bool `json:"return_documents"`
  33. }
  34. type CohereRerankResponseResult struct {
  35. Results []dto.RerankResponseDocument `json:"results"`
  36. Meta CohereMeta `json:"meta"`
  37. }
  38. type CohereMeta struct {
  39. //Tokens CohereTokens `json:"tokens"`
  40. BilledUnits CohereBilledUnits `json:"billed_units"`
  41. }
  42. type CohereBilledUnits struct {
  43. InputTokens int `json:"input_tokens"`
  44. OutputTokens int `json:"output_tokens"`
  45. }
  46. type CohereTokens struct {
  47. InputTokens int `json:"input_tokens"`
  48. OutputTokens int `json:"output_tokens"`
  49. }