text_response.go 2.1 KB

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