text_response.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package dto
  2. type TextResponseWithError struct {
  3. Id string `json:"id"`
  4. Object string `json:"object"`
  5. Created int64 `json:"created"`
  6. Choices []OpenAITextResponseChoice `json:"choices"`
  7. Data []OpenAIEmbeddingResponseItem `json:"data"`
  8. Model string `json:"model"`
  9. Usage `json:"usage"`
  10. Error OpenAIError `json:"error"`
  11. }
  12. type SimpleResponse struct {
  13. Usage `json:"usage"`
  14. Error OpenAIError `json:"error"`
  15. Choices []OpenAITextResponseChoice `json:"choices"`
  16. }
  17. type TextResponse struct {
  18. Id string `json:"id"`
  19. Object string `json:"object"`
  20. Created int64 `json:"created"`
  21. Model string `json:"model"`
  22. Choices []OpenAITextResponseChoice `json:"choices"`
  23. Usage `json:"usage"`
  24. }
  25. type OpenAITextResponseChoice struct {
  26. Index int `json:"index"`
  27. Message `json:"message"`
  28. FinishReason string `json:"finish_reason"`
  29. }
  30. type OpenAITextResponse struct {
  31. Id string `json:"id"`
  32. Object string `json:"object"`
  33. Created int64 `json:"created"`
  34. Choices []OpenAITextResponseChoice `json:"choices"`
  35. Usage `json:"usage"`
  36. }
  37. type OpenAIEmbeddingResponseItem struct {
  38. Object string `json:"object"`
  39. Index int `json:"index"`
  40. Embedding []float64 `json:"embedding"`
  41. }
  42. type OpenAIEmbeddingResponse struct {
  43. Object string `json:"object"`
  44. Data []OpenAIEmbeddingResponseItem `json:"data"`
  45. Model string `json:"model"`
  46. Usage `json:"usage"`
  47. }
  48. type ChatCompletionsStreamResponseChoice struct {
  49. Delta ChatCompletionsStreamResponseChoiceDelta `json:"delta"`
  50. FinishReason *string `json:"finish_reason,omitempty"`
  51. Index int `json:"index,omitempty"`
  52. }
  53. type ChatCompletionsStreamResponseChoiceDelta struct {
  54. Content string `json:"content"`
  55. Role string `json:"role,omitempty"`
  56. ToolCalls []ToolCall `json:"tool_calls,omitempty"`
  57. }
  58. type ToolCall struct {
  59. // Index is not nil only in chat completion chunk object
  60. Index *int `json:"index,omitempty"`
  61. ID string `json:"id"`
  62. Type any `json:"type"`
  63. Function FunctionCall `json:"function"`
  64. }
  65. type FunctionCall struct {
  66. Name string `json:"name,omitempty"`
  67. // call function with arguments in JSON format
  68. Arguments string `json:"arguments,omitempty"`
  69. }
  70. type ChatCompletionsStreamResponse struct {
  71. Id string `json:"id"`
  72. Object string `json:"object"`
  73. Created int64 `json:"created"`
  74. Model string `json:"model"`
  75. Choices []ChatCompletionsStreamResponseChoice `json:"choices"`
  76. }
  77. type ChatCompletionsStreamResponseSimple struct {
  78. Choices []ChatCompletionsStreamResponseChoice `json:"choices"`
  79. }
  80. type CompletionsStreamResponse struct {
  81. Choices []struct {
  82. Text string `json:"text"`
  83. FinishReason string `json:"finish_reason"`
  84. } `json:"choices"`
  85. }
  86. type Usage struct {
  87. PromptTokens int `json:"prompt_tokens"`
  88. CompletionTokens int `json:"completion_tokens"`
  89. TotalTokens int `json:"total_tokens"`
  90. }