text_response.go 2.0 KB

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