text_response.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package dto
  2. type TextResponseWithError struct {
  3. Choices []OpenAITextResponseChoice `json:"choices"`
  4. Object string `json:"object"`
  5. Data []OpenAIEmbeddingResponseItem `json:"data"`
  6. Model string `json:"model"`
  7. Usage `json:"usage"`
  8. Error OpenAIError `json:"error"`
  9. }
  10. type TextResponse struct {
  11. Model string `json:"model"`
  12. Choices []OpenAITextResponseChoice `json:"choices"`
  13. Usage `json:"usage"`
  14. }
  15. type OpenAITextResponseChoice struct {
  16. Index int `json:"index"`
  17. Message `json:"message"`
  18. FinishReason string `json:"finish_reason"`
  19. }
  20. type OpenAITextResponse struct {
  21. Id string `json:"id"`
  22. Object string `json:"object"`
  23. Created int64 `json:"created"`
  24. Choices []OpenAITextResponseChoice `json:"choices"`
  25. Usage `json:"usage"`
  26. }
  27. type OpenAIEmbeddingResponseItem struct {
  28. Object string `json:"object"`
  29. Index int `json:"index"`
  30. Embedding []float64 `json:"embedding"`
  31. }
  32. type OpenAIEmbeddingResponse struct {
  33. Object string `json:"object"`
  34. Data []OpenAIEmbeddingResponseItem `json:"data"`
  35. Model string `json:"model"`
  36. Usage `json:"usage"`
  37. }
  38. type ChatCompletionsStreamResponseChoice struct {
  39. Delta struct {
  40. Content string `json:"content"`
  41. Role string `json:"role,omitempty"`
  42. ToolCalls any `json:"tool_calls,omitempty"`
  43. } `json:"delta"`
  44. FinishReason *string `json:"finish_reason,omitempty"`
  45. Index int `json:"index,omitempty"`
  46. }
  47. type ChatCompletionsStreamResponse struct {
  48. Id string `json:"id"`
  49. Object string `json:"object"`
  50. Created int64 `json:"created"`
  51. Model string `json:"model"`
  52. Choices []ChatCompletionsStreamResponseChoice `json:"choices"`
  53. }
  54. type ChatCompletionsStreamResponseSimple struct {
  55. Choices []ChatCompletionsStreamResponseChoice `json:"choices"`
  56. }
  57. type CompletionsStreamResponse struct {
  58. Choices []struct {
  59. Text string `json:"text"`
  60. FinishReason string `json:"finish_reason"`
  61. } `json:"choices"`
  62. }
  63. type Usage struct {
  64. PromptTokens int `json:"prompt_tokens"`
  65. CompletionTokens int `json:"completion_tokens"`
  66. TotalTokens int `json:"total_tokens"`
  67. }