Model
Gemini model interactions
content := Content->New("user")->AddPart(TextPart->New("What number is this image showing?"))
->AddPart(BinaryPart->New(FileReader->ReadBinaryFile("thirdteen.png"), "image/png"));
candidates := Model->GenerateContent("models/gemini-1.5-flash", content, EndPoint->GetApiKey());
each(candidate in candidates) {
candidate->ToString()->PrintLine();
};
Operations
- CountTokens
- EmbedContent
- GenerateContent
- Get
- GetDescription
- GetDisplayName
- GetGenerationMethods
- GetInputTokenLimit
- GetName
- GetOutputTokenLimit
- GetTemperature
- GetTopK
- GetTopP
- GetVersion
- List
- ToString
CountTokens
Runs a model's tokenizer on input content and returns the token count
function : CountTokens(model_name:String, content:Content, key:String) ~ Int
Parameters
Name | Type | Description |
---|---|---|
model_name | String | model name |
content | Content | content for the model |
key | String | API key |
CountTokens
Runs a model's tokenizer on input content and returns the token count
function : CountTokens(model_name:String, contents:Vector<Content>, key:String) ~ Int
Parameters
Name | Type | Description |
---|---|---|
model_name | String | model name |
contents | Vector<Content> | list of content for the model |
key | String | API key |
EmbedContent
Generates an embedding from the model given an input Content
function : EmbedContent(content:Content, key:String) ~ Float[]
Parameters
Name | Type | Description |
---|---|---|
content | Content | model content= |
key | String | API key |
EmbedContent
Generates an embedding from the model given an input Content
function : EmbedContent(content:Content, title:String, type:Model->TaskType, key:String) ~ Float[]
Parameters
Name | Type | Description |
---|---|---|
content | Content | model content= |
title | String | title for the text. Only applicable when TaskType is RETRIEVAL_DOCUMENT |
type | Model->TaskType | task type for which the embeddings will be used |
key | String | API key |
GenerateContent
Generates a response from the model given an input
function : GenerateContent(model_name:String, content:Content, key:String) ~ Vector<Candidate>
Parameters
Name | Type | Description |
---|---|---|
model_name | String | model name |
content | Content | content for the model |
key | String | API key |
GenerateContent
Generates a response from the model given an input
function : GenerateContent(model_name:String, content:Content, resp_schema:Pair<String,ParameterType>, key:String) ~ Vector<Candidate>
Parameters
Name | Type | Description |
---|---|---|
model_name | String | model name |
content | Content | content for the model |
resp_schema | Pair<String,ParameterType> | response format |
key | String | API key |
GenerateContent
Generates a response from the model given an input
function : GenerateContent(model_name:String, content:Content, funcs:Map<String,Pair<FunctionType,Func2Ref<JsonElement,JsonElement>>>) ~ Vector<Candidate>
Parameters
Name | Type | Description |
---|---|---|
model_name | String | model name |
content | Content | content for the model |
funcs | Map<String,Pair<FunctionType,Func2Ref<JsonElement,JsonElement>>> | map of function callbacks, name must to map to function callback name |
GenerateContent
Generates a response from the model given an input
function : GenerateContent(model_name:String, content:Content, funcs:Map<String,Pair<FunctionType,Func2Ref<JsonElement,JsonElement>>>) ~ Vector<Candidate>
Parameters
Name | Type | Description |
---|---|---|
model_name | String | model name |
content | Content | model content |
funcs | Map<String,Pair<FunctionType,Func2Ref<JsonElement,JsonElement>>> | map of function callbacks, name must to map to function callback name |
GenerateContent
Generates a response from the model given an input
function : GenerateContent(model_name:String, contents:Vector<Content>, funcs:Map<String,Pair<FunctionType,Func2Ref<JsonElement,JsonElement>>>) ~ Vector<Candidate>
Parameters
Name | Type | Description |
---|---|---|
model_name | String | model name |
contents | Vector<Content> | list of content for the model |
funcs | Map<String,Pair<FunctionType,Func2Ref<JsonElement,JsonElement>>> | map of function callbacks, name must to map to function callback name |
Get
Gets a model by name
function : Get(model_name:String, key:String) ~ Model
Parameters
Name | Type | Description |
---|---|---|
model_name | String | model name |
key | String | API key |
Return
Type | Description |
---|---|
Model | available models |
GetDescription
Get the model's description
method : public : GetDescription() ~ String
Return
Type | Description |
---|---|
String | model's description |
GetDisplayName
Get the model's display name
method : public : GetDisplayName() ~ String
Return
Type | Description |
---|---|
String | model's display name |
GetGenerationMethods
The model's supported generation methods.
method : public : GetGenerationMethods() ~ Vector<String>
Return
Type | Description |
---|---|
Vector<String> | generation methods |
GetInputTokenLimit
Get the model's input token limit
method : public : GetInputTokenLimit() ~ Int
Return
Type | Description |
---|---|
Int | model's input token limit |
GetName
Get the model's name
method : public : GetName() ~ String
Return
Type | Description |
---|---|
String | model's name |
GetOutputTokenLimit
Maximum number of output tokens available for this model
method : public : GetOutputTokenLimit() ~ Int
Return
Type | Description |
---|---|
Int | maximum number of output tokens |
GetTemperature
Controls the randomness of the output. Values can range over [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied, while a value closer to 0.0 will typically result in less surprising responses from the model.
method : public : GetTemperature() ~ Float
Return
Type | Description |
---|---|
Float | model temperature |
GetTopK
Get the top-k sampling of the most probable tokens.
method : public : GetTopK() ~ Int
Return
Type | Description |
---|---|
Int | top-k sampling |
GetTopP
Nucleus sampling considers the smallest set of tokens whose probability sum is at least topP.
method : public : GetTopP() ~ Float
GetVersion
Get the model version
method : public : GetVersion() ~ String
Return
Type | Description |
---|---|
String | model version |
List
Lists available models
function : List(key:String) ~ Vector<Model>
Parameters
Name | Type | Description |
---|---|---|
key | String | API key |
Return
Type | Description |
---|---|
Vector<Model> | available models |
ToString
String representation of the object
method : public : ToString() ~ String
Return
Type | Description |
---|---|
String | string representation |