Bundle Google Gemini API client. Supports text generation, multimodal inputs (image, audio, video), chat sessions, function calling, and caching. Set GOOGLE_API_KEY before use. Compile with -lib gemini.
Chat
Gemini chat session
Inherits: Content
Example
session := Chat->New("models/gemini-pro", EndPoint->GetApiKey());
content := session->SendPart(TextPart->New("What is the tallest mountain in the California?"), "user");
content->GetFirstPart()->ToString()->PrintLine();
content := session->SendPart(TextPart->New("How tall is it?"), "user");
content->GetFirstPart()->ToString()->PrintLine();
content := session->SendPart(TextPart->New("Why is it so tall?"), "user");
content->GetFirstPart()->ToString()->PrintLine();
content := session->SendPart(TextPart->New("Where is it located?"), "user");
content->GetFirstPart()->ToString()->PrintLine();
"======"->PrintLine();
session->ToString()->PrintLine();Operations
GetAllParts #
Get all chat parts
method : public : GetAllParts() ~ Vector<Content>Return
| Type | Description |
|---|---|
| Vector<Content> | list of all chat parts |
SendPart #
Send chat part
method : public : SendPart(part:Part, role:String) ~ CandidateParameters
| Name | Type | Description |
|---|---|---|
| part | Part | prompt chat part |
| role | String | prompt role |
Return
| Type | Description |
|---|---|
| Candidate | prompt response |
Example
session := Chat->New(Model->GEMINI_2_0_FLASH(), EndPoint->GetApiKey());
candidate := session->SendPart(TextPart->New("What is 2 + 2?"), "user");
candidate->GetAllText()->PrintLine();
candidate := session->SendPart(TextPart->New("Multiply that by 10."), "user");
candidate->GetAllText()->PrintLine();SetSystemInstruction #
Sets a system instruction for this chat session.
method : public : SetSystemInstruction(instruction:Content) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| instruction | Content | system instruction content (use TextPart for text instructions) |
Example
session := Chat->New(Model->GEMINI_2_0_FLASH(), EndPoint->GetApiKey());
sys_instr := Content->New("system")->AddPart(TextPart->New("You are a concise assistant."));
session->SetSystemInstruction(sys_instr);
session->SendPart(TextPart->New("Hello!"), "user")->GetAllText()->PrintLine();