dto.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. }
  94. // Imagen related structs
  95. type GeminiImageRequest struct {
  96. Instances []GeminiImageInstance `json:"instances"`
  97. Parameters GeminiImageParameters `json:"parameters"`
  98. }
  99. type GeminiImageInstance struct {
  100. Prompt string `json:"prompt"`
  101. }
  102. type GeminiImageParameters struct {
  103. SampleCount int `json:"sampleCount,omitempty"`
  104. AspectRatio string `json:"aspectRatio,omitempty"`
  105. PersonGeneration string `json:"personGeneration,omitempty"`
  106. }
  107. type GeminiImageResponse struct {
  108. Predictions []GeminiImagePrediction `json:"predictions"`
  109. }
  110. type GeminiImagePrediction struct {
  111. MimeType string `json:"mimeType"`
  112. BytesBase64Encoded string `json:"bytesBase64Encoded"`
  113. RaiFilteredReason string `json:"raiFilteredReason,omitempty"`
  114. SafetyAttributes any `json:"safetyAttributes,omitempty"`
  115. }
  116. // Embedding related structs
  117. type GeminiEmbeddingRequest struct {
  118. Content GeminiChatContent `json:"content"`
  119. TaskType string `json:"taskType,omitempty"`
  120. Title string `json:"title,omitempty"`
  121. OutputDimensionality int `json:"outputDimensionality,omitempty"`
  122. }
  123. type GeminiEmbeddingResponse struct {
  124. Embedding ContentEmbedding `json:"embedding"`
  125. }
  126. type ContentEmbedding struct {
  127. Values []float64 `json:"values"`
  128. }