text_response.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 TextResponse struct {
  13. Id string `json:"id"`
  14. Object string `json:"object"`
  15. Created int64 `json:"created"`
  16. Model string `json:"model"`
  17. Choices []OpenAITextResponseChoice `json:"choices"`
  18. Usage `json:"usage"`
  19. }
  20. type OpenAITextResponseChoice struct {
  21. Index int `json:"index"`
  22. Message `json:"message"`
  23. FinishReason string `json:"finish_reason"`
  24. }
  25. type OpenAITextResponse struct {
  26. Id string `json:"id"`
  27. Object string `json:"object"`
  28. Created int64 `json:"created"`
  29. Choices []OpenAITextResponseChoice `json:"choices"`
  30. Usage `json:"usage"`
  31. }
  32. type OpenAIEmbeddingResponseItem struct {
  33. Object string `json:"object"`
  34. Index int `json:"index"`
  35. Embedding []float64 `json:"embedding"`
  36. }
  37. type OpenAIEmbeddingResponse struct {
  38. Object string `json:"object"`
  39. Data []OpenAIEmbeddingResponseItem `json:"data"`
  40. Model string `json:"model"`
  41. Usage `json:"usage"`
  42. }
  43. type ChatCompletionsStreamResponseChoice struct {
  44. Delta struct {
  45. Content string `json:"content"`
  46. Role string `json:"role,omitempty"`
  47. ToolCalls any `json:"tool_calls,omitempty"`
  48. } `json:"delta"`
  49. FinishReason *string `json:"finish_reason,omitempty"`
  50. Index int `json:"index,omitempty"`
  51. }
  52. type ChatCompletionsStreamResponse struct {
  53. Id string `json:"id"`
  54. Object string `json:"object"`
  55. Created int64 `json:"created"`
  56. Model string `json:"model"`
  57. Choices []ChatCompletionsStreamResponseChoice `json:"choices"`
  58. }
  59. type ChatCompletionsStreamResponseSimple struct {
  60. Choices []ChatCompletionsStreamResponseChoice `json:"choices"`
  61. }
  62. type CompletionsStreamResponse struct {
  63. Choices []struct {
  64. Text string `json:"text"`
  65. FinishReason string `json:"finish_reason"`
  66. } `json:"choices"`
  67. }
  68. type Usage struct {
  69. PromptTokens int `json:"prompt_tokens"`
  70. CompletionTokens int `json:"completion_tokens"`
  71. TotalTokens int `json:"total_tokens"`
  72. }