text_response.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 struct {
  50. Content string `json:"content"`
  51. Role string `json:"role,omitempty"`
  52. ToolCalls any `json:"tool_calls,omitempty"`
  53. } `json:"delta"`
  54. FinishReason *string `json:"finish_reason,omitempty"`
  55. Index int `json:"index,omitempty"`
  56. }
  57. type ChatCompletionsStreamResponse struct {
  58. Id string `json:"id"`
  59. Object string `json:"object"`
  60. Created int64 `json:"created"`
  61. Model string `json:"model"`
  62. Choices []ChatCompletionsStreamResponseChoice `json:"choices"`
  63. }
  64. type ChatCompletionsStreamResponseSimple struct {
  65. Choices []ChatCompletionsStreamResponseChoice `json:"choices"`
  66. }
  67. type CompletionsStreamResponse struct {
  68. Choices []struct {
  69. Text string `json:"text"`
  70. FinishReason string `json:"finish_reason"`
  71. } `json:"choices"`
  72. }
  73. type Usage struct {
  74. PromptTokens int `json:"prompt_tokens"`
  75. CompletionTokens int `json:"completion_tokens"`
  76. TotalTokens int `json:"total_tokens"`
  77. }