Creates a new GraphQLAIClient instance.
The GraphQL data provider to use for queries
Check the values a person is entering for a new record against the entity's existing records, and get back the ones to flag as possible duplicates.
This calls the CheckDuplicateEntry mutation. The server finds vector candidates for the
values, keeps those the current user can read, and asks a typed decision about them. It only
flags: nothing is saved, merged or blocked. An entity whose documents do not turn the check on
answers NotConfigured; a caller who may not run the check answers NotAuthorized.
The method never throws. A failure on the server or in transport is Status: 'Failed' with an
ErrorMessage and no candidates. It sets no timeout of its own: a caller with a latency budget
abandons the promise when the budget runs out. The server bounds each check with its own
budget, a little above the form's, so it stops working on an abandoned check soon after.
The entity and the values entered so far
The flagged candidates, most probable first, or why there are none
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 a typed decision (Likelihood, Choice, Score) on the server in one round trip.
This calls the RunDecision mutation, the fast path for browser features with a tight latency
budget such as routing a message or checking for a duplicate: it carries none of the
Run Decision action's execution overhead. The questions and the state are serialized for the
wire and the answers parsed back.
The method never throws. A failure on the server or in transport is Success: false with an
ErrorMessage and empty Answers.
The questions, the state, and optionally the prompt and a timeout
A Promise that resolves to the answers by question key, or the reason there are none
const result = await aiClient.RunDecision({
State: { message: "Show me last quarter's renewals" },
Questions: {
route: {
Kind: 'Choice',
Instructions: 'Which agent should answer this message?',
Options: [
{ Value: 'sage', Description: 'General questions about the product' },
{ Value: 'analyst', Description: 'Questions about data and reports' }
]
}
},
TimeoutMS: 250
});
const route = result.Answers.route;
if (result.Success && route?.Kind === 'Choice') {
console.log(`Route to ${route.Value} (confidence ${route.Confidence})`);
}
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