Member Junction
    Preparing search index...

    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.

    // Create the client
    const aiClient = new GraphQLAIClient(graphQLProvider);

    // Run an AI prompt
    const promptResult = await aiClient.RunAIPrompt({
    promptId: "prompt-id",
    data: { context: "user data" },
    temperature: 0.7
    });

    // Run an AI agent
    const agentResult = await aiClient.RunAIAgent({
    agentId: "agent-id",
    messages: [{ role: "user", content: "Hello" }],
    sessionId: "session-123"
    });
    Index

    Constructors

    Methods

    • Generate embeddings for text using local embedding models. This method is designed for interactive components that need fast similarity calculations.

      Parameters

      Returns Promise<EmbedTextResult>

      A Promise that resolves to an EmbedTextResult object

      const result = await aiClient.EmbedText({
      textToEmbed: ["Hello world", "How are you?"],
      modelSize: "small"
      });

      console.log('Embeddings:', result.embeddings);
      console.log('Model used:', result.modelName);
      console.log('Dimensions:', result.vectorDimensions);
    • Execute a simple prompt without requiring a stored AI Prompt entity. This method is designed for interactive components that need quick AI responses.

      Parameters

      Returns Promise<SimplePromptResult>

      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.

      Parameters

      • params: FetchEntityVectorsParams

        The parameters for fetching entity vectors

      Returns Promise<FetchEntityVectorsResult>

      A Promise that resolves to a FetchEntityVectorsResult

    • 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.

      Parameters

      • params: {
            strategy: "create-new" | "merge-into-existing";
            suggestionID: string;
            targetTagID?: string;
        }

      Returns Promise<PromoteSuggestionResult>

    • Rebuild persisted tag embeddings for tags whose EmbeddingModelID doesn't match the configured embedding model. Run after a global model change.

      Returns Promise<RebuildTagEmbeddingsResult>

    • Reject a pending tag suggestion with optional reviewer notes.

      Parameters

      • params: { reviewerNotes?: string; suggestionID: string }

      Returns Promise<RejectSuggestionResult>

    • 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.

      Parameters

      • params: ExecuteAgentParams

        The parameters for running the AI agent

      • OptionalsourceArtifactId: string
      • OptionalsourceArtifactVersionId: string

      Returns Promise<ExecuteAgentResult>

      A 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 user's message has already been saved as a ConversationDetail
      • The conversation may have attachments (images, documents, etc.)
      • You want optimal performance by loading history on the server

      Parameters

      Returns Promise<ExecuteAgentResult>

      A Promise that resolves to an ExecuteAgentResult object

      const result = await aiClient.RunAIAgentFromConversationDetail({
      conversationDetailId: "detail-id-123",
      agentId: "agent-id",
      maxHistoryMessages: 20,
      createArtifacts: true,
      onProgress: (progress) => {
      console.log(`Progress: ${progress.message}`);
      }
      });
    • 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.

      Parameters

      Returns Promise<RunAIPromptResult>

      A Promise that resolves to a RunAIPromptResult object

      const result = await aiClient.RunAIPrompt({
      promptId: "prompt-id",
      data: { key: "value" },
      temperature: 0.7,
      topP: 0.9
      });

      if (result.success) {
      console.log('Output:', result.output);
      console.log('Parsed Result:', result.parsedResult);
      } else {
      console.error('Error:', result.error);
      }
    • Run the Tag Health emitters (merge / low-usage / wide-node) on demand. All threshold parameters fall back to DEFAULT_TAG_HEALTH_THRESHOLDS server-side.

      Parameters

      • Optionalparams: {
            maxImplicitChildren?: number;
            maxUsage?: number;
            minCoOccurrence?: number;
            minEmbeddingSimilarity?: number;
            minNameSimilarity?: number;
        }

      Returns Promise<RunTagHealthResult>