Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions source/cpp/ios/ai_features/OfflineAISystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ class OfflineAISystem {
*/
std::unordered_map<std::string, std::string> GetScriptTemplates() const;

/**
* @brief Get template cache
* @return Map of template names to templates
*/
std::unordered_map<std::string, std::string> GetTemplateCache() const;

/**
* @brief Generate response for a detection event
* @param detectionType Detection type
Expand Down
18 changes: 11 additions & 7 deletions source/cpp/ios/ai_features/OfflineAISystem.mm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

if (scriptGenInitialized) {
m_scriptGeneratorModel = scriptGenerator.get();
m_modelCache["script_generator"] = scriptGenerator;
m_modelCache["script_generator"] = scriptGenerator.get();
m_loadedModelNames.push_back("script_generator");
} else {
std::cerr << "OfflineAISystem: Failed to initialize script generator model" << std::endl;
Expand All @@ -82,7 +82,7 @@

if (vulnerabilityInitialized) {
m_patternRecognitionModel = vulnerabilityDetector.get();
m_modelCache["vulnerability_detector"] = vulnerabilityDetector;
m_modelCache["vulnerability_detector"] = vulnerabilityDetector.get();
m_loadedModelNames.push_back("vulnerability_detector");
} else {
std::cerr << "OfflineAISystem: Failed to initialize vulnerability detector" << std::endl;
Expand Down Expand Up @@ -368,6 +368,7 @@
std::regex varRegex("\\b([a-zA-Z][a-zA-Z0-9_]*)\\s*=");
std::regex useRegex("\\b([a-zA-Z][a-zA-Z0-9_]*)\\b");

// Define variable sets before using them
std::set<std::string> definedVars;
std::set<std::string> usedVars;
std::set<std::string> builtinVars = {
Expand Down Expand Up @@ -405,7 +406,9 @@
// Find undefined variables
std::vector<std::string> undefinedVars;
for (const auto& var : usedVars) {
if (definedVars.find(var) == definedVars.end()) {
// Check if this variable is defined
auto it = definedVars.find(var);
if (it == definedVars.end()) {
undefinedVars.push_back(var);
}
}
Expand Down Expand Up @@ -661,7 +664,8 @@
void* OfflineAISystem::GetModel(const std::string& modelName) const {
auto it = m_modelCache.find(modelName);
if (it != m_modelCache.end()) {
return it->second.get();
// Direct access to pointer instead of using get() since we're storing raw pointers now
return it->second;
}
return nullptr;
}
Expand Down Expand Up @@ -871,11 +875,11 @@ local function getClosestPlayer()

// Get script templates
std::unordered_map<std::string, std::string> OfflineAISystem::GetScriptTemplates() const {
return m_templateCache;
return m_scriptTemplates;
}

// Get a list of script templates
std::unordered_map<std::string, std::string> OfflineAISystem::GetScriptTemplates() const {
// Get template cache
std::unordered_map<std::string, std::string> OfflineAISystem::GetTemplateCache() const {
return m_templateCache;
}

Expand Down
Loading