ravendb
Version:
RavenDB client for Node.js
65 lines • 2.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AiOperations = void 0;
const index_js_1 = require("./Agents/index.js");
const StringUtil_js_1 = require("../../../Utility/StringUtil.js");
const AiConversation_js_1 = require("./AiConversation.js");
class AiOperations {
_store;
_databaseName;
_executor;
/**
* Initializes a new instance of AiOperations for a given document store and optional database name.
*/
constructor(store, databaseName) {
this._store = store;
this._databaseName = databaseName || store.database;
this._executor = this._store.maintenance.forDatabase(this._databaseName);
}
/**
* Returns an AiOperations instance for a different database.
*/
forDatabase(databaseName) {
if (StringUtil_js_1.StringUtil.equalsIgnoreCase(this._databaseName, databaseName)) {
return this;
}
return new AiOperations(this._store, databaseName);
}
/**
* Creates or updates an AI agent configuration (with the given schema) on the database.
*/
async createAgent(configuration, sampleObject) {
const operation = new index_js_1.AddOrUpdateAiAgentOperation(configuration, sampleObject);
return await this._executor.send(operation);
}
/**
* Retrieves the AI agent configuration for a specific agent.
*/
async getAgent(agentId) {
const operation = new index_js_1.GetAiAgentsOperation(agentId);
const response = await this._executor.send(operation);
return response.aiAgents && response.aiAgents.length > 0 ? response.aiAgents[0] : null;
}
/**
* Retrieves all AI agents and their configurations.
*/
async getAgents() {
const operation = new index_js_1.GetAiAgentsOperation();
return await this._executor.send(operation);
}
/**
* Deletes an AI agent configuration.
*/
async deleteAgent(identifier) {
const operation = new index_js_1.DeleteAiAgentOperation(identifier);
return await this._executor.send(operation);
}
/**
* Opens an AI conversation for an agent.
*/
conversation(agentId, conversationId, creationOptions, changeVector) {
return new AiConversation_js_1.AiConversation(this._store, this._databaseName, agentId, conversationId, creationOptions, changeVector);
}
}
exports.AiOperations = AiOperations;
//# sourceMappingURL=AiOperations.js.map