Documentation ¶
Index ¶
- Constants
- Variables
- func Handler(c *gin.Context, resp *http.Response, promptTokens int, modelName string) (*model.ErrorWithStatusCode, *model.Usage)
- func StreamHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusCode, string)
- type Adaptor
- func (a *Adaptor) ConvertImageRequest(request *model.ImageRequest) (any, error)
- func (a *Adaptor) ConvertRequest(c *gin.Context, relayMode int, request *model.GeneralOpenAIRequest) (any, error)
- func (a *Adaptor) DoRequest(c *gin.Context, meta *meta.Meta, requestBody io.Reader) (*http.Response, error)
- func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, meta *meta.Meta) (usage *model.Usage, err *model.ErrorWithStatusCode)
- func (a *Adaptor) GetChannelName() string
- func (a *Adaptor) GetModelList() []string
- func (a *Adaptor) GetRequestURL(meta *meta.Meta) (string, error)
- func (a *Adaptor) Init(meta *meta.Meta)
- func (a *Adaptor) SetupRequestHeader(c *gin.Context, req *http.Request, meta *meta.Meta) error
- type ChatCandidate
- type ChatContent
- type ChatGenerationConfig
- type ChatPromptFeedback
- type ChatRequest
- type ChatResponse
- type ChatSafetyRating
- type ChatSafetySettings
- type ChatTools
- type InlineData
- type Part
Constants ¶
View Source
const (
VisionMaxImageNum = 16
)
Variables ¶
View Source
var ModelList = []string{
"gemini-pro", "gemini-1.0-pro-001", "gemini-1.5-pro",
"gemini-pro-vision", "gemini-1.0-pro-vision-001",
}
Functions ¶
func StreamHandler ¶
Types ¶
type Adaptor ¶
type Adaptor struct { }
func (*Adaptor) ConvertImageRequest ¶
func (a *Adaptor) ConvertImageRequest(request *model.ImageRequest) (any, error)
func (*Adaptor) ConvertRequest ¶
func (*Adaptor) DoResponse ¶
func (*Adaptor) GetChannelName ¶
func (*Adaptor) GetModelList ¶
type ChatCandidate ¶
type ChatCandidate struct { Content ChatContent `json:"content"` FinishReason string `json:"finishReason"` Index int64 `json:"index"` SafetyRatings []ChatSafetyRating `json:"safetyRatings"` }
type ChatContent ¶
type ChatGenerationConfig ¶
type ChatGenerationConfig struct { Temperature float64 `json:"temperature,omitempty"` TopP float64 `json:"topP,omitempty"` TopK float64 `json:"topK,omitempty"` MaxOutputTokens int `json:"maxOutputTokens,omitempty"` CandidateCount int `json:"candidateCount,omitempty"` StopSequences []string `json:"stopSequences,omitempty"` }
type ChatPromptFeedback ¶
type ChatPromptFeedback struct {
SafetyRatings []ChatSafetyRating `json:"safetyRatings"`
}
type ChatRequest ¶
type ChatRequest struct { Contents []ChatContent `json:"contents"` SafetySettings []ChatSafetySettings `json:"safety_settings,omitempty"` GenerationConfig ChatGenerationConfig `json:"generation_config,omitempty"` Tools []ChatTools `json:"tools,omitempty"` }
func ConvertRequest ¶
func ConvertRequest(textRequest model.GeneralOpenAIRequest) *ChatRequest
Setting safety to the lowest possible values since Gemini is already powerless enough
type ChatResponse ¶
type ChatResponse struct { Candidates []ChatCandidate `json:"candidates"` PromptFeedback ChatPromptFeedback `json:"promptFeedback"` }
func (*ChatResponse) GetResponseText ¶
func (g *ChatResponse) GetResponseText() string
type ChatSafetyRating ¶
type ChatSafetySettings ¶
type ChatTools ¶
type ChatTools struct {
FunctionDeclarations any `json:"functionDeclarations,omitempty"`
}
type InlineData ¶
type Part ¶
type Part struct { Text string `json:"text,omitempty"` InlineData *InlineData `json:"inlineData,omitempty"` }
Click to show internal directories.
Click to hide internal directories.