67 std::vector<float>
rankify(
const std::vector<float>& x)
const;
98 static void updateTabLabel(ValueTree& root,
int index,
const String& label);
139 const String& estimatedTimeRemaining) = 0;
222 StringArray
getLLMLayers(std::unique_ptr<InputStream>& stream);
234 float dot(
const std::vector<float>& a,
const std::vector<float>& b)
const;
237 void normalise(std::vector<float>& x)
const;
240 std::vector<float>
getVectorScores(String catID,
const std::vector<float>& x)
const;
246 std::vector<std::pair<float, int>>
topk(std::vector<std::pair<float, int>> data,
int topk)
const;
250 const std::vector<float>& scores2,
float k = 2.0f,
251 float alpha = 0.5f)
const;
294 std::vector<int>
argsort(
const std::vector<float>& x)
const;
303 void excludeLayers(
const StringArray& excludeList, std::vector<Layer>& layers);
312 std::tuple<float, int, bool>
findLayer(
const std::vector<float>& queryEmbedding,
313 const std::vector<float>& presetEmbedding,
314 const std::vector<Layer>& layers,
315 const std::vector<float>& layerScoresLLM);
337 void notifyProgressUpdate(
const int processedFiles,
const int totalFiles,
const String& estimatedTimeRemaining);
365 SharedResourcePointer<UniversalCategorySystem>
m_UCS;
Definition TextToAssets.h:399
AnthropicAPIException(const String &message)
Definition TextToAssets.h:401
Definition TextToAssets.h:404
LLMJsonParseException(const String &message)
Definition TextToAssets.h:406
Listener for the TextToAssets module.
Definition TextToAssets.h:123
virtual void onTextToAssetsProcessingStatusChanged(bool isAvailable)=0
called when the text to assets module has finished processing files
virtual void onTextToAssetsProgressUpdate(int processedFiles, int totalFiles, const String &estimatedTimeRemaining)=0
Callback to notify progress updates on file processing.
virtual ~Listener()=default
take a user text query and return 4 assets that can be loaded as an ambience preset
Definition TextToAssets.h:41
std::vector< std::pair< String, std::vector< float > > > m_queryEmbeddings
Definition TextToAssets.h:374
std::tuple< String, StringArray > preprocessQuery(String query) const
return preprocessed query and exclude tags
bool m_synchronousUpdates
Definition TextToAssets.h:185
bool matchesCategory(const String &catID, StringArray tags) const
check if UCS catID matches one of our target tags
static void searchForTagAndProperty(ValueTree &root, Identifier tag, Identifier property, String newSample, Identifier target)
this will add a sample that comes from ttp to the corresponding core egine but it also update the xyp...
Definition TextToAssets.cpp:1240
virtual bool isModelFileAvailable() const
Returns whether there is a model file available for use, in order to generate embeddings.
Definition TextToAssets.h:179
void loadFileEmbeddings()
will load embeddings data from file to all modules that need it
~TextToAssets()
Definition TextToAssets.cpp:18
bool readFromFile(File file)
load embeddings from file
String capitalize(const String &text)
make first letter of string upper case and the rest lower case
virtual void calculateEmbeddingsForFile(const File &file)
create text embeddings file for the given file
StringArray m_samplePaths
Definition TextToAssets.h:353
void notifyAvailabilityStatus(bool isAvailable)
Update TTA availability status and notify listeners. TTA should not available whilst file processing ...
Definition TextToAssets.cpp:1339
SentenceTransformer m_sentenceTransformer
Definition TextToAssets.h:362
std::tuple< String, std::array< TTPAsset, 4 > > findPresetFiles(String searchTerm)
find 4 assets suitable for the given query
void run() override
run thread
virtual File createFilePath(String filename)
creates the path for the embeddings file
void clear()
clears internal data
static std::unique_ptr< XmlElement > getInitTTPData()
xml for automated preset generation
Definition TextToAssets.cpp:1333
std::tuple< float, int, bool > findLayer(const std::vector< float > &queryEmbedding, const std::vector< float > &presetEmbedding, const std::vector< Layer > &layers, const std::vector< float > &layerScoresLLM)
find a relevant preset layer
String m_claudeApiKeyEncrypted
Definition TextToAssets.h:379
std::vector< float > rankify(const std::vector< float > &x) const
output the rank of each vector element
static void updateTabLabel(ValueTree &root, int index, const String &label)
This function searches for a specific TABLABEL by index within the CUSTOMDATA node and updates its te...
Definition TextToAssets.cpp:1273
bool m_strictMode
Definition TextToAssets.h:389
void maskLayersContainingTag(String tag, std::vector< Layer > &layers)
set layer.isValid to false for layers containing tag.
void removeListener(Listener *listener)
Definition TextToAssets.cpp:1373
String sanitizeString(String text)
removes digits and underscores from a string
bool m_shouldSave
Definition TextToAssets.h:359
std::vector< float > calculateLLMLayerScores(const std::vector< Layer > &layers, const StringArray &generatedLayerNames)
return similarity scores for layers based on the LLM generated layer names
std::map< String, int > m_assetCounter
Definition TextToAssets.h:350
void setStrictMode(bool isStrictMode)
Sets whether "Strict Mode" is enabled or disabled (default: disabled).
Definition TextToAssets.h:171
bool isAvailable()
Returns the status of the file processing.
Definition TextToAssets.h:153
std::unordered_map< String, std::vector< std::size_t > > m_datasetIDMap
Definition TextToAssets.h:347
bool isStrictMode()
Returns if "Strict Mode" is enabled (default: disabled).
Definition TextToAssets.h:162
CriticalSection m_cs
Definition TextToAssets.h:368
void normalise(std::vector< float > &x) const
L2 normalise the input vector.
Definition TextToAssets.cpp:1214
float dot(const std::vector< float > &a, const std::vector< float > &b) const
return dot product between a and b
Definition TextToAssets.cpp:1209
void addBiasToLayers(const String &query, std::vector< Layer > &layers)
add a non-zero bias to layers that match certain keywords
static void updateCoreEngineParamValue(ValueTree &tree, const var &coreEngineID, const var ¶mID, const String &value)
update a CoreEngine PARAM value
Definition TextToAssets.cpp:1302
std::tuple< String, String > findClosestAmbienceCatID(const String &query, const std::vector< float > &queryEmbedding)
search for closest match to query
bool isUCSValid(String catID)
check UCS CatID is valid
void setClaudeApiKey(const String &key)
Set the encrypted API key string for the Claude API.
Definition TextToAssets.h:117
bool appendDataToEmbeddingsFile()
appends data to the main embeddings file
StringArray getLLMLayers(std::unique_ptr< InputStream > &stream)
returns a StringArray of preset layer names generated by an LLM
Definition TextToAssets.cpp:80
std::vector< float > calculateReciprocalRankFusion(const std::vector< float > &scores1, const std::vector< float > &scores2, float k=2.0f, float alpha=0.5f) const
calculate the reciprocal rank fusion for scores1 and scores2
StringArray anthropicAPICall(String query)
send query to an LLM using the anthropic API
Definition TextToAssets.cpp:115
bool processFileList(Array< File > &filesToProcess)
processes a file list to create text embeddings
StringArray parseAnthropicResponse(std::unique_ptr< InputStream > &stream)
parse Anthropic API response and return results in a StringArray
Definition TextToAssets.cpp:31
std::vector< std::pair< float, int > > topk(std::vector< std::pair< float, int > > data, int topk) const
return topk elements
bool m_modelFileAvailable
Definition TextToAssets.h:182
AsyncListenerUpdater< Listener > m_progressUpdater
Definition TextToAssets.h:386
std::unordered_map< String, std::vector< Layer > > m_layersMap
Definition TextToAssets.h:377
std::vector< float > getVectorScores(String catID, const std::vector< float > &x) const
return vector scores between query embedding and dataset embeddings
Definition TextToAssets.cpp:1223
AsyncListenerUpdater< Listener > m_statusUpdater
Definition TextToAssets.h:386
bool containsKeyword(const String &text, const StringArray &keywords)
returns true if the text contains any keyword in keywords.
void addListener(Listener *listener)
Definition TextToAssets.cpp:1371
std::unique_ptr< BM25 > m_bm25
Definition TextToAssets.h:340
bool m_ttaAvailable
Definition TextToAssets.h:371
void notifyProgressUpdate(const int processedFiles, const int totalFiles, const String &estimatedTimeRemaining)
Notifies listeners of the progress of the current file processing operation.
Definition TextToAssets.cpp:1353
std::vector< int > argsort(const std::vector< float > &x) const
returns the indices that would sort the vector.
std::unordered_map< String, std::vector< Data > > m_datasetMap
Definition TextToAssets.h:346
void excludeLayers(const StringArray &excludeList, std::vector< Layer > &layers)
uses the contents of exclude list to set some preset layers as invalid if certain keywords are detect...
Definition TextToAssets.cpp:1193
void loadPresetLayers()
load preset layers from json stored as binary data
StringArray m_sampleFilenames
Definition TextToAssets.h:356
std::tuple< String, float > findAsset(const Layer &layer)
find a relevant asset for a given preset layer
void loadQueryEmbeddings()
load quer embeddings from json stored as binary data
ListenerList< Listener > m_listeners
Definition TextToAssets.h:381
std::vector< String > m_bm25Corpus
Definition TextToAssets.h:343
TextToAssets()
Definition TextToAssets.cpp:5
SharedResourcePointer< UniversalCategorySystem > m_UCS
Definition TextToAssets.h:365
wrapper class for text to file module shared resource pointer
Definition TextToAssets.h:394
SharedResourcePointer< TextToAssets > textToAssets
Definition TextToAssets.h:396
Definition AirAbsorptionFilter.cpp:2
static const Identifier layer3Identifier
Definition TextToAssets.h:25
static const Identifier fileNameIdentifier
Definition TextToAssets.h:13
constexpr char ttfStatusDateProperty[]
Definition TextToAssets.h:8
static const Identifier customParamIdentifier
Definition TextToAssets.h:16
static const Identifier layer1Identifier
Definition TextToAssets.h:23
static const Identifier layer4Identifier
Definition TextToAssets.h:26
constexpr char ttfEmbeddingsFileName[]
Definition TextToAssets.h:6
static const Identifier soundscapeIdentifier
Definition TextToAssets.h:22
constexpr char ttfNumericalMetadata[]
Definition TextToAssets.h:10
AssetsStatus
Definition TextToAssets.h:29
@ kAssetsRemoved
Definition TextToAssets.h:30
@ kAssetsAdded
Definition TextToAssets.h:31
@ kAssetsInit
Definition TextToAssets.h:33
@ kAssetsNoChange
Definition TextToAssets.h:32
static const Identifier samplePathsIdentifier
Definition TextToAssets.h:17
static const Identifier contentIdentifier
Definition TextToAssets.h:20
constexpr char ttfStatusFileName[]
Definition TextToAssets.h:7
static const Identifier textIdentifier
Definition TextToAssets.h:21
constexpr char ttfStatusSizeProperty[]
Definition TextToAssets.h:9
static const Identifier ttfEmbeddingsNameIdentifier
Definition TextToAssets.h:15
static const Identifier layer2Identifier
Definition TextToAssets.h:24
static const Identifier catIDNameIdentifier
Definition TextToAssets.h:14
static const Identifier FilesEmbeddingsIdentifier
Definition TextToAssets.h:12
Definition TextToAssets.h:190
Data(String catID=String(), String path=String(), std::vector< float > embeddings=std::vector< float >())
Definition TextToAssets.h:194
std::vector< float > embeddings
Definition TextToAssets.h:193
String catID
Definition TextToAssets.h:191
String path
Definition TextToAssets.h:192
Definition TextToAssets.h:201
bool isValid
Definition TextToAssets.h:202
std::vector< float > assetEmbedding
Definition TextToAssets.h:212
String assetCatID
Definition TextToAssets.h:208
String collection
Definition TextToAssets.h:205
String engine
Definition TextToAssets.h:210
String parentCatID
Definition TextToAssets.h:204
float bias
Definition TextToAssets.h:203
String layerDescription
Definition TextToAssets.h:207
std::vector< float > layerEmbedding
Definition TextToAssets.h:211
String layerName
Definition TextToAssets.h:206
String assetDescription
Definition TextToAssets.h:209
Definition TextToAssets.h:45
String path
Definition TextToAssets.h:46
String engine
Definition TextToAssets.h:48
String label
Definition TextToAssets.h:47