@@ -2,6 +2,7 @@ package logging
22
33import (
44 "encoding/json"
5+ "fmt"
56 "log"
67 "time"
78)
@@ -165,6 +166,11 @@ type Generation struct {
165166}
166167
167168func newGeneration (c * GenerationConfig , w * writer ) * Generation {
169+ // Validating provider
170+ if c .Provider != ProviderOpenAI && c .Provider != ProviderAzure && c .Provider != ProviderBedrock && c .Provider != ProviderAnthropic && c .Provider != ProviderGemini {
171+ fmt .Printf ("[MaximSDK] Invalid provider %s, allowed providers are %s, %s, %s, %s, %s\n " , c .Provider , ProviderOpenAI , ProviderAzure , ProviderBedrock , ProviderAnthropic , ProviderGemini )
172+ return nil
173+ }
168174 return & Generation {
169175 base : newBase (EntityGeneration , c .Id , & baseConfig {
170176 SpanId : c .SpanId ,
@@ -219,6 +225,11 @@ func (g *Generation) handleAnthropicResult(jsonData []byte) (*MaximLLMResult, er
219225 return ParseAnthropicResult (jsonData )
220226}
221227
228+ // handleGeminiResult extracts and logs data from a Gemini completion
229+ func (g * Generation ) handleGeminiResult (jsonData []byte ) (* MaximLLMResult , error ) {
230+ return ParseGeminiResult (jsonData )
231+ }
232+
222233// handleAzure extracts and logs data from an Azure OpenAI completion
223234func (g * Generation ) handleAzure (jsonData []byte , _ time.Duration ) (* MaximLLMResult , error ) {
224235 // Azure OpenAI has the same response format as OpenAI
@@ -255,6 +266,8 @@ func (g *Generation) SetResult(r interface{}) {
255266 finalResult , err = g .handleBedrockConverseResult (jsonData )
256267 case ProviderAnthropic :
257268 finalResult , err = g .handleAnthropicResult (jsonData )
269+ case ProviderGemini :
270+ finalResult , err = g .handleGeminiResult (jsonData )
258271 }
259272 if err != nil {
260273 log .Println ("[MaximSDK] Failed to parse result" , err )
0 commit comments