dto.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package gemini
  2. type GeminiChatRequest struct {
  3. Contents []GeminiChatContent `json:"contents"`
  4. SafetySettings []GeminiChatSafetySettings `json:"safety_settings,omitempty"`
  5. GenerationConfig GeminiChatGenerationConfig `json:"generation_config,omitempty"`
  6. Tools []GeminiChatTool `json:"tools,omitempty"`
  7. SystemInstructions *GeminiChatContent `json:"system_instruction,omitempty"`
  8. }
  9. type GeminiInlineData struct {
  10. MimeType string `json:"mimeType"`
  11. Data string `json:"data"`
  12. }
  13. type FunctionCall struct {
  14. FunctionName string `json:"name"`
  15. Arguments any `json:"args"`
  16. }
  17. type GeminiFunctionResponseContent struct {
  18. Name string `json:"name"`
  19. Content any `json:"content"`
  20. }
  21. type FunctionResponse struct {
  22. Name string `json:"name"`
  23. Response GeminiFunctionResponseContent `json:"response"`
  24. }
  25. type GeminiPartExecutableCode struct {
  26. Language string `json:"language,omitempty"`
  27. Code string `json:"code,omitempty"`
  28. }
  29. type GeminiPartCodeExecutionResult struct {
  30. Outcome string `json:"outcome,omitempty"`
  31. Output string `json:"output,omitempty"`
  32. }
  33. type GeminiFileData struct {
  34. MimeType string `json:"mimeType,omitempty"`
  35. FileUri string `json:"fileUri,omitempty"`
  36. }
  37. type GeminiPart struct {
  38. Text string `json:"text,omitempty"`
  39. InlineData *GeminiInlineData `json:"inlineData,omitempty"`
  40. FunctionCall *FunctionCall `json:"functionCall,omitempty"`
  41. FunctionResponse *FunctionResponse `json:"functionResponse,omitempty"`
  42. FileData *GeminiFileData `json:"fileData,omitempty"`
  43. ExecutableCode *GeminiPartExecutableCode `json:"executableCode,omitempty"`
  44. CodeExecutionResult *GeminiPartCodeExecutionResult `json:"codeExecutionResult,omitempty"`
  45. }
  46. type GeminiChatContent struct {
  47. Role string `json:"role,omitempty"`
  48. Parts []GeminiPart `json:"parts"`
  49. }
  50. type GeminiChatSafetySettings struct {
  51. Category string `json:"category"`
  52. Threshold string `json:"threshold"`
  53. }
  54. type GeminiChatTool struct {
  55. GoogleSearch any `json:"googleSearch,omitempty"`
  56. GoogleSearchRetrieval any `json:"googleSearchRetrieval,omitempty"`
  57. CodeExecution any `json:"codeExecution,omitempty"`
  58. FunctionDeclarations any `json:"functionDeclarations,omitempty"`
  59. }
  60. type GeminiChatGenerationConfig struct {
  61. Temperature float64 `json:"temperature,omitempty"`
  62. TopP float64 `json:"topP,omitempty"`
  63. TopK float64 `json:"topK,omitempty"`
  64. MaxOutputTokens uint `json:"maxOutputTokens,omitempty"`
  65. CandidateCount int `json:"candidateCount,omitempty"`
  66. StopSequences []string `json:"stopSequences,omitempty"`
  67. ResponseMimeType string `json:"responseMimeType,omitempty"`
  68. ResponseSchema any `json:"responseSchema,omitempty"`
  69. Seed int64 `json:"seed,omitempty"`
  70. }
  71. type GeminiChatCandidate struct {
  72. Content GeminiChatContent `json:"content"`
  73. FinishReason *string `json:"finishReason"`
  74. Index int64 `json:"index"`
  75. SafetyRatings []GeminiChatSafetyRating `json:"safetyRatings"`
  76. }
  77. type GeminiChatSafetyRating struct {
  78. Category string `json:"category"`
  79. Probability string `json:"probability"`
  80. }
  81. type GeminiChatPromptFeedback struct {
  82. SafetyRatings []GeminiChatSafetyRating `json:"safetyRatings"`
  83. }
  84. type GeminiChatResponse struct {
  85. Candidates []GeminiChatCandidate `json:"candidates"`
  86. PromptFeedback GeminiChatPromptFeedback `json:"promptFeedback"`
  87. UsageMetadata GeminiUsageMetadata `json:"usageMetadata"`
  88. }
  89. type GeminiUsageMetadata struct {
  90. PromptTokenCount int `json:"promptTokenCount"`
  91. CandidatesTokenCount int `json:"candidatesTokenCount"`
  92. TotalTokenCount int `json:"totalTokenCount"`
  93. }