Creates a new GraphQLAIClient instance.
The GraphQL data provider to use for queries
Generate embeddings for text using local embedding models. This method is designed for interactive components that need fast similarity calculations.
The parameters for embedding generation
A Promise that resolves to an EmbedTextResult object
Execute a simple prompt without requiring a stored AI Prompt entity. This method is designed for interactive components that need quick AI responses.
The parameters for the simple prompt execution
A Promise that resolves to a SimplePromptResult object
const result = await aiClient.ExecuteSimplePrompt({
systemPrompt: "You are a helpful assistant",
messages: [
{ message: "What's the weather?", role: "user" }
],
modelPower: "medium"
});
if (result.success) {
console.log('Response:', result.result);
if (result.resultObject) {
console.log('Parsed JSON:', JSON.parse(result.resultObject));
}
}
Fetch vectors with metadata from Pinecone for a given entity document. Returns the vector IDs, embedding values, and metadata stored in the vector index.
The parameters for fetching entity vectors
A Promise that resolves to a FetchEntityVectorsResult
Pause a running classification pipeline. Sets CancellationRequested on the process run so the engine pauses after the current batch.
Approve a pending tag suggestion. The server-side TagGovernanceEngine either creates a new tag (when strategy is 'create-new') or merges into an existing tag (when strategy is 'merge-into-existing'), then re-points any existing free-text ContentItemTag rows whose Tag matches ProposedName.
Rebuild persisted tag embeddings for tags whose EmbeddingModelID doesn't match the configured embedding model. Run after a global model change.
Resume a paused classification pipeline from its last completed offset.
Run an AI agent with the specified parameters.
This method invokes an AI agent on the server through GraphQL and returns the result. The agent can maintain conversation context across multiple interactions.
If a progress callback is provided in params.onProgress, this method will subscribe to real-time progress updates from the GraphQL server and forward them to the callback.
The parameters for running the AI agent
OptionalsourceArtifactId: stringOptionalsourceArtifactVersionId: stringA Promise that resolves to a RunAIAgentResult object
const result = await aiClient.RunAIAgent({
agentId: "agent-id",
messages: [
{ role: "user", content: "What's the weather like?" }
],
sessionId: "session-123",
data: { location: "New York" },
onProgress: (progress) => {
console.log(`Progress: ${progress.message} (${progress.percentage}%)`);
}
});
if (result.success) {
console.log('Response:', result.payload);
console.log('Execution time:', result.executionTimeMs, 'ms');
} else {
console.error('Error:', result.errorMessage);
}
Run an AI agent using an existing conversation detail ID. This is an optimized method that loads conversation history server-side, avoiding the need to send large attachment data from client to server.
Use this method when:
The parameters for running the AI agent from conversation detail
A Promise that resolves to an ExecuteAgentResult object
Run an AI prompt with the specified parameters.
This method invokes an AI prompt on the server through GraphQL and returns the result. Parameters are automatically serialized as needed, and results are parsed for consumption.
The parameters for running the AI prompt
A Promise that resolves to a RunAIPromptResult object
Trigger the autotagging pipeline (fire-and-forget). Returns a PipelineRunID that can be used to subscribe to PipelineProgress.
Optionaloptions: { contentSourceIDs?: string[]; forceReprocess?: boolean }Run the Tag Health emitters (merge / low-usage / wide-node) on demand. All threshold parameters fall back to DEFAULT_TAG_HEALTH_THRESHOLDS server-side.
Optionalparams: {Trigger vectorization for an entity document. Calls the server-side EntityVectorSyncer to embed and upsert entity records.
Client for executing AI operations through GraphQL. This class provides an easy way to execute AI prompts and agents from a client application.
The GraphQLAIClient follows the same naming convention as other GraphQL clients in the MemberJunction ecosystem, such as GraphQLActionClient and GraphQLSystemUserClient.
Example