chat.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package fastgpt
  2. type ChatReq struct {
  3. ChatId string `json:"chatId"`
  4. Stream bool `json:"stream"`
  5. Detail bool `json:"detail"`
  6. Variables Variables `json:"variables"`
  7. Messages []Message `json:"messages"`
  8. }
  9. type ChatResp struct {
  10. Id string `json:"id"`
  11. Object string `json:"object"`
  12. Created uint64 `json:"created"`
  13. Model string `json:"model"`
  14. Choices []Choice `json:"choices"`
  15. }
  16. type ChatNoStreamResp struct {
  17. Id string `json:"id"`
  18. Model string `json:"model"`
  19. Usage Usage `json:"usage"`
  20. Choices []NoStreamChoice `json:"choices"`
  21. }
  22. type NoStreamChoice struct {
  23. Message Delta `json:"message"`
  24. FinishReason string `json:"finish_reason,optional"`
  25. Index uint64 `json:"index"`
  26. }
  27. type Usage struct {
  28. PromptTokens int `json:"prompt_tokens"`
  29. CompletionTokens int `json:"completion_tokens"`
  30. TotalTokens int `json:"total_tokens"`
  31. }
  32. type Choice struct {
  33. Delta Delta `json:"delta"`
  34. FinishReason string `json:"finish_reason,optional"`
  35. Index uint64 `json:"index"`
  36. }
  37. type Delta struct {
  38. Content string `json:"content"`
  39. Role string `json:"role"`
  40. }
  41. type Variables struct {
  42. Uid string `json:"uid"`
  43. Name string `json:"name"`
  44. }
  45. type Message struct {
  46. Content string `json:"content"`
  47. Role string `json:"role"`
  48. }
  49. type ChatResponse struct {
  50. Id string `json:"id"`
  51. Object string `json:"object"`
  52. Created uint64 `json:"created"`
  53. Model string `json:"model"`
  54. Choices []Choice `json:"choices"`
  55. }
  56. // GetChatUrl 请求地址
  57. func GetChatUrl() string {
  58. return "/v1/chat/completions"
  59. }
  60. func GetChatToken() string {
  61. return "fastgpt-eEvIvCz2ccEmgbp4nUEbUDHLoCN2wz4BnpI3ucxECFRbG9xiNBOfjd797vIkT"
  62. }