LLM for Unity  v2.4.0
Create characters in Unity with LLMs!
Loading...
Searching...
No Matches
LLMUnity.Searchable Class Referenceabstract

Class implementing the search template. More...

Inheritance diagram for LLMUnity.Searchable:
[legend]

Public Member Functions

string Get (int key)
 Retrieves the phrase with the specific id.
 
Task< int > Add (string inputString, string group="")
 Adds a phrase to the search.
 
int Remove (string inputString, string group="")
 Removes a phrase from the search.
 
void Remove (int key)
 Removes a phrase from the search.
 
int Count ()
 Returns a count of the phrases.
 
int Count (string group)
 Returns a count of the phrases in a specific data group.
 
void Clear ()
 Clears the search object.
 
Task< int > IncrementalSearch (string queryString, string group="")
 Allows to do search and retrieve results in batches (incremental search).
 
ValueTuple< int[], float[], bool > IncrementalFetchKeys (int fetchKey, int k)
 Retrieves the most similar search results in batches (incremental search). The phrase keys and distances are retrieved, as well as a parameter that dictates whether the search is exhausted.
 
void IncrementalSearchComplete (int fetchKey)
 Completes the search and clears the cached results for an incremental search.
 
async Task<(string[], float[])> Search (string queryString, int k, string group="")
 Search for similar results to the provided query. The most similar results and their distances (dissimilarity) to the query are retrieved.
 
virtual ValueTuple< string[], float[], bool > IncrementalFetch (int fetchKey, int k)
 Retrieves the most similar search results in batches (incremental search). The most similar results and their distances (dissimilarity) to the query are retrieved as well as a parameter that dictates whether the search is exhausted.
 
void Save (string filePath)
 Saves the state of the search object.
 
async Task< bool > Load (string filePath)
 Loads the state of the search object.
 

Detailed Description

Class implementing the search template.

Definition at line 21 of file Search.cs.

Member Function Documentation

◆ Add()

Task< int > LLMUnity.Searchable.Add ( string inputString,
string group = "" )
abstract

Adds a phrase to the search.

Parameters
inputStringinput phrase
groupdata group to add it to
Returns
phrase id

◆ Count() [1/2]

int LLMUnity.Searchable.Count ( )
abstract

Returns a count of the phrases.

Returns
phrase count

◆ Count() [2/2]

int LLMUnity.Searchable.Count ( string group)
abstract

Returns a count of the phrases in a specific data group.

Parameters
groupdata group
Returns
phrase count

◆ Get()

string LLMUnity.Searchable.Get ( int key)
abstract

Retrieves the phrase with the specific id.

Parameters
keyphrase id
Returns
phrase

◆ IncrementalFetch()

virtual ValueTuple< string[], float[], bool > LLMUnity.Searchable.IncrementalFetch ( int fetchKey,
int k )
inlinevirtual

Retrieves the most similar search results in batches (incremental search). The most similar results and their distances (dissimilarity) to the query are retrieved as well as a parameter that dictates whether the search is exhausted.

Parameters
fetchKeyincremental search key
knumber of results to retrieve
Returns
A tuple containing:
  • Array of retrieved results (string[]).
  • Array of distances for each result (float[]).
  • bool indicating if the search is exhausted.

Reimplemented in LLMUnity.Chunking.

Definition at line 137 of file Search.cs.

◆ IncrementalFetchKeys()

ValueTuple< int[], float[], bool > LLMUnity.Searchable.IncrementalFetchKeys ( int fetchKey,
int k )
abstract

Retrieves the most similar search results in batches (incremental search). The phrase keys and distances are retrieved, as well as a parameter that dictates whether the search is exhausted.

Parameters
fetchKeyincremental search key
knumber of results to retrieve
Returns
A tuple containing:
  • Array of retrieved keys (int[]).
  • Array of distances for each result (float[]).
  • bool indicating if the search is exhausted.

◆ IncrementalSearch()

Task< int > LLMUnity.Searchable.IncrementalSearch ( string queryString,
string group = "" )
abstract

Allows to do search and retrieve results in batches (incremental search).

Parameters
queryStringsearch query
groupdata group to search in
Returns
incremental search key

◆ IncrementalSearchComplete()

void LLMUnity.Searchable.IncrementalSearchComplete ( int fetchKey)
abstract

Completes the search and clears the cached results for an incremental search.

Parameters
fetchKeyincremental search key

◆ Load()

async Task< bool > LLMUnity.Searchable.Load ( string filePath)
inline

Loads the state of the search object.

Parameters
archivefile to load from

Definition at line 166 of file Search.cs.

◆ Remove() [1/2]

void LLMUnity.Searchable.Remove ( int key)
abstract

Removes a phrase from the search.

Parameters
keyphrase id

◆ Remove() [2/2]

int LLMUnity.Searchable.Remove ( string inputString,
string group = "" )
abstract

Removes a phrase from the search.

Parameters
inputStringinput phrase
groupdata group to remove it from
Returns
number of removed entries/returns>

◆ Save()

void LLMUnity.Searchable.Save ( string filePath)
inline

Saves the state of the search object.

Parameters
archivefile to save to

Definition at line 149 of file Search.cs.

◆ Search()

async Task<(string[], float[])> LLMUnity.Searchable.Search ( string queryString,
int k,
string group = "" )
inline

Search for similar results to the provided query. The most similar results and their distances (dissimilarity) to the query are retrieved.

Parameters
queryStringquery
knumber of results to retrieve
groupdata group to search in
Returns
A tuple containing:
  • Array of retrieved results (string[]).
  • Array of distances for each result (float[]).
  • bool indicating if the search is exhausted.

Definition at line 115 of file Search.cs.


The documentation for this class was generated from the following file: