Documentation ¶
Index ¶
- Constants
- Variables
- func EmbeddingHandler(c *gin.Context, resp *http.Response) (*model.ErrorWithStatusCode, *model.Usage)
- 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 BatchEmbeddingRequest
- type ChatCandidate
- type ChatContent
- type ChatGenerationConfig
- type ChatPromptFeedback
- type ChatRequest
- type ChatResponse
- type ChatSafetyRating
- type ChatSafetySettings
- type ChatTools
- type EmbeddingData
- type EmbeddingRequest
- type EmbeddingResponse
- type Error
- type FunctionCall
- 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", "embedding-001", "text-embedding-004",
}
Functions ¶
func EmbeddingHandler ¶
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 BatchEmbeddingRequest ¶
type BatchEmbeddingRequest struct {
Requests []EmbeddingRequest `json:"requests"`
}
func ConvertEmbeddingRequest ¶
func ConvertEmbeddingRequest(request model.GeneralOpenAIRequest) *BatchEmbeddingRequest
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:"function_declarations,omitempty"`
}
type EmbeddingData ¶
type EmbeddingData struct {
Values []float64 `json:"values"`
}
type EmbeddingRequest ¶
type EmbeddingRequest struct { Model string `json:"model"` Content ChatContent `json:"content"` TaskType string `json:"taskType,omitempty"` Title string `json:"title,omitempty"` OutputDimensionality int `json:"outputDimensionality,omitempty"` }
type EmbeddingResponse ¶
type EmbeddingResponse struct { Embeddings []EmbeddingData `json:"embeddings"` Error *Error `json:"error,omitempty"` }
type FunctionCall ¶
type InlineData ¶
type Part ¶
type Part struct { Text string `json:"text,omitempty"` InlineData *InlineData `json:"inlineData,omitempty"` FunctionCall *FunctionCall `json:"functionCall,omitempty"` }
Click to show internal directories.
Click to hide internal directories.