All Bundles

Corpus

Google Gemini corpus

Derived from: OAuthEndPoint

Operations

Code example:

# clean up
corpuses := Corpus->List();
each(corpus in corpuses) {
documents := Document->List(corpus);
each(document in documents) {
chunks := Chunk->List(document);
each(chunk in chunks) {
chunk->Delete()->PrintLine();
};
document->Delete()->PrintLine();
};
corpus->Delete()->PrintLine();
};

# corups
corpus := Corpus->Create("Corpus 1");

metadata := Map->New()<String, String>;
metadata->Insert("about", "fruit, vegetable, vehicle, human, and animal");
document := Document->Create("Document 1", metadata, corpus);

metadata := Map->New()<String, String>;
metadata->Insert("category", "fruit");
Chunk->Create("Nature's candy! Seeds' sweet ride to spread, bursting with colors, sugars, and vitamins. Fuel for us, future for plants. Deliciously vital!", metadata, document)->ToString()->PrintLine();

metadata := Map->New()<String, String>;
metadata->Insert("category", "vegetable");
Chunk->Create("Not just leaves! Veggies sprout from roots, stems, flowers, and even bulbs. Packed with vitamins, minerals, and fiber galore, they fuel our bodies and keep us wanting more.", metadata, document)->ToString()->PrintLine();

metadata := Map->New()<String, String>;
metadata->Insert("category", "vehicle");
Chunk->Create("Metal chariots or whirring steeds, gliding on land, skimming seas, piercing clouds. Carrying souls near and far, vehicles weave paths for dreams and scars.", metadata, document)->ToString()->PrintLine();

metadata := Map->New()<String, String>;
metadata->Insert("category", "human");
Chunk->Create("Walking contradictions, minds aflame, built for laughter, prone to shame. Woven from stardust, shaped by clay, seeking answers, paving the way.", metadata, document)->ToString()->PrintLine();

metadata := Map->New()<String, String>;
metadata->Insert("category", "animal");
Chunk->Create("Sentient dance beneath the sun, from buzzing flies to whales that run. Flesh and feather, scale and claw, weaving instincts in nature's law. ", metadata, document)->ToString()->PrintLine();

metadata := Map->New()<String, String>;
metadata->Insert("category", "other");
Chunk->Create("Except for fruit, vegetable, vehicle, human, and animal", metadata, document)->ToString()->PrintLine();

# search
results := document->Query(query);
each(result in results) {
  relevance := result->GetFirst()->As(FloatRef);
  metadata := result->GetThird()->As(Map<String, String>);

  relevance->PrintLine();
  metadata->ToString()->PrintLine();
  "---"->PrintLine();
}

Create

Create a new corpus

function : Create(name:String) ~ Corpus
Parameters
NameTypeDescription
nameStringcorpus name

Return
TypeDescription
Corpusnew corpus

Delete

Delete existing corpus

method : public : Delete() ~ Bool
Return
TypeDescription
Booltrue if successful, false otherwise

Get

Get existing corpus

function : Get(name:String) ~ Corpus
Parameters
NameTypeDescription
nameStringcorpus name

Return
TypeDescription
Corpusexisting corpus

GetCreateTime

Get creation time

method : public : GetCreateTime() ~ System.Time.Date
Return
TypeDescription
Datecreation time

GetId

Get corpus ID

method : public : GetId() ~ String
Return
TypeDescription
Stringcorpus ID

GetName

Get the display name

method : public : GetName() ~ String
Return
TypeDescription
Stringdisplay name

GetUpdateTime

Get update time

method : public : GetUpdateTime() ~ System.Time.Date
Return
TypeDescription
Dateupdate time

Query

Query the corpus

method : public : Query(query:String) ~ Vector<Collection.Tuple.Triplet<FloatRef,String,Map<String,String>>>
Parameters
NameTypeDescription
queryStringstring query

Return
TypeDescription
Triplet<FloatRef,String,Map<String,String>>query results as triple, 1) relevance, 2) string content, 3) content metadata

ToString

String representation of the object

method : public : ToString() ~ String
Return
TypeDescription
Stringstring representation