IDoubaoService.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. namespace OASystem.API.OAMethodLib.DoubaoAPI
  2. {
  3. public enum ReasoningEffort
  4. {
  5. Minimal,
  6. Low,
  7. Medium,
  8. High
  9. }
  10. public class DouBaoChatMessage
  11. {
  12. public DouBaoRole Role { get; set; }
  13. public string Content { get; set; }
  14. }
  15. public enum DouBaoRole
  16. {
  17. system,
  18. user,
  19. assistant
  20. }
  21. public class CompleteChatOptions
  22. {
  23. public thinkingOptions ThinkingOptions { get; set; } = new thinkingOptions()
  24. {
  25. IsThinking = false,
  26. ReasoningEffort = ReasoningEffort.Minimal
  27. };
  28. }
  29. public class thinkingOptions
  30. {
  31. public bool IsThinking { get; set; } = false;
  32. public ReasoningEffort ReasoningEffort { get; set; } = ReasoningEffort.Minimal;
  33. }
  34. public class DoubaoResponse
  35. {
  36. public string id { get; set; }
  37. public string @object { get; set; }
  38. public long created { get; set; }
  39. public string model { get; set; }
  40. public string service_tier { get; set; }
  41. public List<Choice> choices { get; set; }
  42. public Usage usage { get; set; }
  43. }
  44. public class Choice
  45. {
  46. public int index { get; set; }
  47. public string finish_reason { get; set; }
  48. public object logprobs { get; set; } // 可以是 null 或者详细概率结构
  49. public Message message { get; set; }
  50. }
  51. public class Message
  52. {
  53. public string role { get; set; }
  54. public string content { get; set; }
  55. public string reasoning_content { get; set; } // 豆包特有字段
  56. }
  57. public class Usage
  58. {
  59. public int completion_tokens { get; set; }
  60. public int prompt_tokens { get; set; }
  61. public int total_tokens { get; set; }
  62. public TokenDetails prompt_tokens_details { get; set; }
  63. public TokenDetails completion_tokens_details { get; set; }
  64. }
  65. public class TokenDetails
  66. {
  67. public int reasoning_tokens { get; set; }
  68. }
  69. public interface IDoubaoService
  70. {
  71. Task<string> CompleteChatAsync(List<DouBaoChatMessage> messages, CompleteChatOptions? options = null);
  72. }
  73. }