model.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. package cohere
  2. type Request struct {
  3. P *float64 `json:"p,omitempty"`
  4. Temperature *float64 `json:"temperature,omitempty"`
  5. PresencePenalty *float64 `json:"presence_penalty,omitempty"`
  6. FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
  7. Model string `json:"model,omitempty"`
  8. Message string `json:"message" required:"true"`
  9. Preamble string `json:"preamble,omitempty"`
  10. PromptTruncation string `json:"prompt_truncation,omitempty"`
  11. ConversationID string `json:"conversation_id,omitempty"`
  12. StopSequences []string `json:"stop_sequences,omitempty"`
  13. Tools []Tool `json:"tools,omitempty"`
  14. ToolResults []ToolResult `json:"tool_results,omitempty"`
  15. Documents []Document `json:"documents,omitempty"`
  16. Connectors []Connector `json:"connectors,omitempty"`
  17. ChatHistory []ChatMessage `json:"chat_history,omitempty"`
  18. K int `json:"k,omitempty"`
  19. MaxInputTokens int `json:"max_input_tokens,omitempty"`
  20. Seed int `json:"seed,omitempty"`
  21. MaxTokens int `json:"max_tokens,omitempty"`
  22. Stream bool `json:"stream,omitempty"`
  23. }
  24. type ChatMessage struct {
  25. Role string `json:"role" required:"true"`
  26. Message string `json:"message" required:"true"`
  27. }
  28. type Tool struct {
  29. ParameterDefinitions map[string]ParameterSpec `json:"parameter_definitions"`
  30. Name string `json:"name" required:"true"`
  31. Description string `json:"description" required:"true"`
  32. }
  33. type ParameterSpec struct {
  34. Description string `json:"description"`
  35. Type string `json:"type" required:"true"`
  36. Required bool `json:"required"`
  37. }
  38. type ToolResult struct {
  39. Call ToolCall `json:"call"`
  40. Outputs []map[string]any `json:"outputs"`
  41. }
  42. type ToolCall struct {
  43. Parameters map[string]any `json:"parameters" required:"true"`
  44. Name string `json:"name" required:"true"`
  45. }
  46. type StreamResponse struct {
  47. Response *Response `json:"response,omitempty"`
  48. EventType string `json:"event_type"`
  49. GenerationID string `json:"generation_id,omitempty"`
  50. Text string `json:"text,omitempty"`
  51. FinishReason string `json:"finish_reason,omitempty"`
  52. SearchQueries []*SearchQuery `json:"search_queries,omitempty"`
  53. SearchResults []*SearchResult `json:"search_results,omitempty"`
  54. Documents []*Document `json:"documents,omitempty"`
  55. Citations []*Citation `json:"citations,omitempty"`
  56. IsFinished bool `json:"is_finished"`
  57. }
  58. type SearchQuery struct {
  59. Text string `json:"text"`
  60. GenerationID string `json:"generation_id"`
  61. }
  62. type SearchResult struct {
  63. SearchQuery *SearchQuery `json:"search_query"`
  64. Connector *Connector `json:"connector"`
  65. DocumentIDs []string `json:"document_ids"`
  66. }
  67. type Connector struct {
  68. ID string `json:"id"`
  69. }
  70. type Document struct {
  71. ID string `json:"id"`
  72. Snippet string `json:"snippet"`
  73. Timestamp string `json:"timestamp"`
  74. Title string `json:"title"`
  75. URL string `json:"url"`
  76. }
  77. type Citation struct {
  78. Text string `json:"text"`
  79. DocumentIDs []string `json:"document_ids"`
  80. Start int `json:"start"`
  81. End int `json:"end"`
  82. }
  83. type Response struct {
  84. FinishReason *string `json:"finish_reason"`
  85. ResponseID string `json:"response_id"`
  86. Text string `json:"text"`
  87. GenerationID string `json:"generation_id"`
  88. Message string `json:"message"`
  89. ChatHistory []*Message `json:"chat_history"`
  90. Citations []*Citation `json:"citations"`
  91. Documents []*Document `json:"documents"`
  92. SearchResults []*SearchResult `json:"search_results"`
  93. SearchQueries []*SearchQuery `json:"search_queries"`
  94. Meta Meta `json:"meta"`
  95. }
  96. type Message struct {
  97. Role string `json:"role"`
  98. Message string `json:"message"`
  99. }
  100. type Version struct {
  101. Version string `json:"version"`
  102. }
  103. type Units struct {
  104. InputTokens int `json:"input_tokens"`
  105. OutputTokens int `json:"output_tokens"`
  106. }
  107. type ChatEntry struct {
  108. Role string `json:"role"`
  109. Message string `json:"message"`
  110. }
  111. type Meta struct {
  112. APIVersion APIVersion `json:"api_version"`
  113. BilledUnits BilledUnits `json:"billed_units"`
  114. Tokens Usage `json:"tokens"`
  115. }
  116. type APIVersion struct {
  117. Version string `json:"version"`
  118. }
  119. type BilledUnits struct {
  120. InputTokens int `json:"input_tokens"`
  121. OutputTokens int `json:"output_tokens"`
  122. }
  123. type Usage struct {
  124. InputTokens int64 `json:"input_tokens"`
  125. OutputTokens int64 `json:"output_tokens"`
  126. }