Google Gemini corpus
Derived from: OAuthEndPoint
OperationsCode 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 a new corpus
function : Create(name:String) ~ Corpus
Name | Type | Description |
---|---|---|
name | String | corpus name |
Type | Description |
---|---|
Corpus | new corpus |
Delete existing corpus
method : public : Delete() ~ Bool
Type | Description |
---|---|
Bool | true if successful, false otherwise |
Get existing corpus
function : Get(name:String) ~ Corpus
Name | Type | Description |
---|---|---|
name | String | corpus name |
Type | Description |
---|---|
Corpus | existing corpus |
Get creation time
method : public : GetCreateTime() ~ System.Time.Date
Type | Description |
---|---|
Date | creation time |
Get corpus ID
method : public : GetId() ~ String
Type | Description |
---|---|
String | corpus ID |
Get the display name
method : public : GetName() ~ String
Type | Description |
---|---|
String | display name |
Get update time
method : public : GetUpdateTime() ~ System.Time.Date
Type | Description |
---|---|
Date | update time |
Query the corpus
method : public : Query(query:String) ~ Vector<Collection.Tuple.Triplet<FloatRef,String,Map<String,String>>>
Name | Type | Description |
---|---|---|
query | String | string query |
Type | Description |
---|---|
Triplet<FloatRef,String,Map<String,String>> | query results as triple, 1) relevance, 2) string content, 3) content metadata |
String representation of the object
method : public : ToString() ~ String
Type | Description |
---|---|
String | string representation |