graphlit-client
Version:
Graphlit API Client for TypeScript
1,268 lines • 131 kB
JavaScript
import jwt from "jsonwebtoken";
// Apollo core (React-free) - ESM import
import { ApolloClient, InMemoryCache, createHttpLink, ApolloLink, ApolloError, } from "@apollo/client/core/index.js";
// Apollo retry link for resilient error handling
import { RetryLink } from "@apollo/client/link/retry/index.js";
import * as Types from "./generated/graphql-types.js";
import * as Documents from "./generated/graphql-documents.js";
import * as dotenv from "dotenv";
import { getServiceType, getModelName } from "./model-mapping.js";
import { UIEventAdapter } from "./streaming/ui-event-adapter.js";
import { formatMessagesForOpenAI, formatMessagesForAnthropic, formatMessagesForGoogle, formatMessagesForCohere, formatMessagesForMistral, formatMessagesForBedrock, } from "./streaming/llm-formatters.js";
import { streamWithOpenAI, streamWithAnthropic, streamWithGoogle, streamWithGroq, streamWithCerebras, streamWithCohere, streamWithMistral, streamWithBedrock, streamWithDeepseek, } from "./streaming/providers.js";
// Optional imports for streaming LLM clients
// These are peer dependencies and may not be installed
// We need to use createRequire for optional dependencies to avoid build errors
import { createRequire } from "node:module";
const optionalRequire = createRequire(import.meta.url);
let OpenAI;
let Anthropic;
let GoogleGenerativeAI;
let Groq;
let CohereClient;
let Mistral;
let BedrockRuntimeClient;
try {
OpenAI = optionalRequire("openai").default || optionalRequire("openai");
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] OpenAI SDK loaded successfully");
}
}
catch (e) {
// OpenAI not installed
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] OpenAI SDK not found:", e.message);
}
}
try {
Anthropic =
optionalRequire("@anthropic-ai/sdk").default ||
optionalRequire("@anthropic-ai/sdk");
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] Anthropic SDK loaded successfully");
}
}
catch (e) {
// Anthropic SDK not installed
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] Anthropic SDK not found:", e.message);
}
}
try {
GoogleGenerativeAI = optionalRequire("@google/generative-ai").GoogleGenerativeAI;
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] Google Generative AI SDK loaded successfully");
}
}
catch (e) {
// Google Generative AI not installed
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] Google Generative AI SDK not found:", e.message);
}
}
try {
Groq = optionalRequire("groq-sdk").default || optionalRequire("groq-sdk");
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] Groq SDK loaded successfully");
}
}
catch (e) {
// Groq SDK not installed
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] Groq SDK not found:", e.message);
}
}
try {
CohereClient = optionalRequire("cohere-ai").CohereClient;
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] Cohere SDK loaded successfully");
}
}
catch (e) {
// Cohere SDK not installed
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] Cohere SDK not found:", e.message);
}
}
try {
Mistral = optionalRequire("@mistralai/mistralai").Mistral;
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] Mistral SDK loaded successfully");
}
}
catch (e) {
// Mistral SDK not installed
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] Mistral SDK not found:", e.message);
}
}
try {
BedrockRuntimeClient = optionalRequire("@aws-sdk/client-bedrock-runtime").BedrockRuntimeClient;
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] Bedrock SDK loaded successfully");
}
}
catch (e) {
// Bedrock SDK not installed
if (process.env.DEBUG_GRAPHLIT_SDK_INITIALIZATION) {
console.log("[SDK Loading] Bedrock SDK not found:", e.message);
}
}
const DEFAULT_MAX_TOOL_ROUNDS = 1000;
// Define the Graphlit class
class Graphlit {
client;
token;
apiUri;
organizationId;
environmentId;
ownerId;
userId;
jwtSecret;
retryConfig;
// Streaming client instances (optional - can be provided by user)
openaiClient;
anthropicClient;
googleClient;
groqClient;
cerebrasClient;
cohereClient;
mistralClient;
bedrockClient;
deepseekClient;
constructor(organizationIdOrOptions, environmentId, jwtSecret, ownerId, userId, apiUri) {
// Handle both old constructor signature and new options object
let options;
if (typeof organizationIdOrOptions === "object" &&
organizationIdOrOptions !== null) {
// New constructor with options object
options = organizationIdOrOptions;
}
else {
// Legacy constructor with individual parameters
options = {
organizationId: organizationIdOrOptions,
environmentId,
jwtSecret,
ownerId,
userId,
apiUri,
};
}
this.apiUri =
options.apiUri ||
(typeof process !== "undefined"
? process.env.GRAPHLIT_API_URL
: undefined) ||
"https://data-scus.graphlit.io/api/v1/graphql";
if (typeof process !== "undefined") {
dotenv.config();
this.organizationId =
options.organizationId || process.env.GRAPHLIT_ORGANIZATION_ID;
this.environmentId =
options.environmentId || process.env.GRAPHLIT_ENVIRONMENT_ID;
this.jwtSecret = options.jwtSecret || process.env.GRAPHLIT_JWT_SECRET;
// optional: for multi-tenant support
this.ownerId = options.ownerId || process.env.GRAPHLIT_OWNER_ID;
this.userId = options.userId || process.env.GRAPHLIT_USER_ID;
}
else {
this.organizationId = options.organizationId;
this.environmentId = options.environmentId;
this.jwtSecret = options.jwtSecret;
// optional: for multi-tenant support
this.ownerId = options.ownerId;
this.userId = options.userId;
}
// Set default retry configuration
this.retryConfig = {
maxAttempts: 5,
initialDelay: 300,
maxDelay: 30000,
retryableStatusCodes: [429, 502, 503, 504],
jitter: true,
...options.retryConfig,
};
if (!this.organizationId) {
throw new Error("Graphlit organization identifier is required.");
}
if (!this.environmentId) {
throw new Error("Graphlit environment identifier is required.");
}
if (!this.jwtSecret) {
throw new Error("Graphlit environment JWT secret is required.");
}
this.refreshClient();
}
refreshClient() {
this.client = undefined;
this.generateToken();
const httpLink = createHttpLink({
uri: this.apiUri,
});
// Create retry link with configuration
const retryLink = new RetryLink({
delay: {
initial: this.retryConfig.initialDelay || 300,
max: this.retryConfig.maxDelay || 30000,
jitter: this.retryConfig.jitter !== false,
},
attempts: {
max: this.retryConfig.maxAttempts || 5,
retryIf: (error, _operation) => {
// Check if we should retry this error
if (!error)
return false;
// Check for network errors
const hasNetworkError = !!error.networkError;
if (!hasNetworkError)
return false;
// Get status code from different possible locations
const statusCode = error.networkError?.statusCode ||
error.networkError?.response?.status ||
error.statusCode;
// Check if status code is retryable
if (statusCode && this.retryConfig.retryableStatusCodes) {
const shouldRetry = this.retryConfig.retryableStatusCodes.includes(statusCode);
// Call onRetry callback if provided
if (shouldRetry &&
this.retryConfig.onRetry &&
_operation.getContext().retryCount !== undefined) {
const attempt = _operation.getContext().retryCount + 1;
this.retryConfig.onRetry(attempt, error, _operation);
}
return shouldRetry;
}
// Default: retry on network errors without specific status codes
return true;
},
},
});
const authLink = new ApolloLink((operation, forward) => {
operation.setContext({
headers: {
Authorization: this.token ? `Bearer ${this.token}` : "",
},
});
return forward(operation);
});
// Chain links: retry -> auth -> http
this.client = new ApolloClient({
link: ApolloLink.from([retryLink, authLink, httpLink]),
cache: new InMemoryCache(),
defaultOptions: {
watchQuery: {
errorPolicy: "all",
fetchPolicy: "no-cache",
},
query: {
errorPolicy: "all",
fetchPolicy: "no-cache",
},
mutate: {
errorPolicy: "all",
fetchPolicy: "no-cache",
},
},
});
}
/**
* Set a custom OpenAI client instance for streaming
* @param client - OpenAI client instance (e.g., new OpenAI({ apiKey: "..." }))
*/
setOpenAIClient(client) {
this.openaiClient = client;
}
/**
* Set a custom Anthropic client instance for streaming
* @param client - Anthropic client instance (e.g., new Anthropic({ apiKey: "..." }))
*/
setAnthropicClient(client) {
this.anthropicClient = client;
}
/**
* Set a custom Google Generative AI client instance for streaming
* @param client - Google GenerativeAI client instance (e.g., new GoogleGenerativeAI(apiKey))
*/
setGoogleClient(client) {
this.googleClient = client;
}
/**
* Set a custom Groq client instance for streaming
* @param client - Groq client instance (e.g., new Groq({ apiKey: "..." }))
*/
setGroqClient(client) {
this.groqClient = client;
}
/**
* Set a custom Cerebras client instance for streaming (OpenAI-compatible)
* @param client - OpenAI client instance configured for Cerebras (e.g., new OpenAI({ apiKey: "...", baseURL: "https://api.cerebras.ai/v1" }))
*/
setCerebrasClient(client) {
this.cerebrasClient = client;
}
/**
* Set a custom Cohere client instance for streaming
* @param client - Cohere client instance (e.g., new CohereClient({ token: "..." }))
*/
setCohereClient(client) {
this.cohereClient = client;
}
/**
* Set a custom Mistral client instance for streaming
* @param client - Mistral client instance (e.g., new Mistral({ apiKey: "..." }))
*/
setMistralClient(client) {
this.mistralClient = client;
}
/**
* Set a custom Bedrock client instance for streaming
* @param client - BedrockRuntimeClient instance (e.g., new BedrockRuntimeClient({ region: "us-east-2" }))
*/
setBedrockClient(client) {
this.bedrockClient = client;
}
/**
* Set a custom Deepseek client instance for streaming
* @param client - OpenAI client instance configured for Deepseek (e.g., new OpenAI({ baseURL: "https://api.deepseek.com", apiKey: "..." }))
*/
setDeepseekClient(client) {
this.deepseekClient = client;
}
/**
* Update retry configuration and refresh the Apollo client
* @param retryConfig - New retry configuration
*/
setRetryConfig(retryConfig) {
this.retryConfig = {
...this.retryConfig,
...retryConfig,
};
// Refresh client to apply new retry configuration
this.refreshClient();
}
generateToken() {
if (!this.jwtSecret) {
throw new Error("Graphlit environment JWT secret is required.");
}
const expiration = Math.floor(Date.now() / 1000) + 24 * 60 * 60; // one day from now
const payload = {
"https://graphlit.io/jwt/claims": {
"x-graphlit-organization-id": this.organizationId,
"x-graphlit-environment-id": this.environmentId,
...(this.ownerId && { "x-graphlit-owner-id": this.ownerId }),
...(this.userId && { "x-graphlit-user-id": this.userId }),
"x-graphlit-role": "Owner",
},
exp: expiration,
iss: "graphlit",
aud: "https://portal.graphlit.io",
};
this.token = jwt.sign(payload, this.jwtSecret, { algorithm: "HS256" });
}
async getProject() {
return this.queryAndCheckError(Documents.GetProject, {});
}
async updateProject(project) {
return this.mutateAndCheckError(Documents.UpdateProject, { project: project });
}
async lookupProjectUsage(correlationId) {
return this.queryAndCheckError(Documents.LookupUsage, { correlationId: correlationId });
}
async lookupProjectCredits(correlationId) {
return this.queryAndCheckError(Documents.LookupCredits, { correlationId: correlationId });
}
async queryProjectTokens(startDate, duration) {
return this.queryAndCheckError(Documents.QueryTokens, { startDate: startDate, duration: duration });
}
async queryProjectUsage(startDate, duration, names, excludedNames, offset, limit) {
return this.queryAndCheckError(Documents.QueryUsage, {
startDate: startDate,
duration: duration,
names: names,
excludedNames: excludedNames,
offset: offset,
limit: limit,
});
}
async queryProjectCredits(startDate, duration) {
return this.queryAndCheckError(Documents.QueryCredits, { startDate: startDate, duration: duration });
}
async sendNotification(connector, text, textType) {
return this.mutateAndCheckError(Documents.SendNotification, {
connector: connector,
text: text,
textType: textType,
});
}
async mapWeb(uri, allowedPaths, excludedPaths, correlationId) {
return this.queryAndCheckError(Documents.MapWeb, {
uri: uri,
allowedPaths: allowedPaths,
excludedPaths: excludedPaths,
correlationId: correlationId,
});
}
async searchWeb(text, service, limit, correlationId) {
return this.queryAndCheckError(Documents.SearchWeb, {
text: text,
service: service,
limit: limit,
correlationId: correlationId,
});
}
async createAlert(alert, correlationId) {
return this.mutateAndCheckError(Documents.CreateAlert, { alert: alert, correlationId: correlationId });
}
async updateAlert(alert) {
return this.mutateAndCheckError(Documents.UpdateAlert, { alert: alert });
}
async deleteAlert(id) {
return this.mutateAndCheckError(Documents.DeleteAlert, { id: id });
}
async deleteAlerts(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteAlerts, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllAlerts(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllAlerts, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async enableAlert(id) {
return this.mutateAndCheckError(Documents.EnableAlert, { id: id });
}
async disableAlert(id) {
return this.mutateAndCheckError(Documents.DisableAlert, { id: id });
}
async getAlert(id) {
return this.queryAndCheckError(Documents.GetAlert, { id: id });
}
async queryAlerts(filter) {
return this.queryAndCheckError(Documents.QueryAlerts, { filter: filter });
}
async countAlerts(filter) {
return this.queryAndCheckError(Documents.CountAlerts, { filter: filter });
}
async createCollection(collection) {
return this.mutateAndCheckError(Documents.CreateCollection, { collection: collection });
}
async updateCollection(collection) {
return this.mutateAndCheckError(Documents.UpdateCollection, { collection: collection });
}
async deleteCollection(id) {
return this.mutateAndCheckError(Documents.DeleteCollection, { id: id });
}
async deleteCollections(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteCollections, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllCollections(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllCollections, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async addContentsToCollections(contents, collections) {
return this.mutateAndCheckError(Documents.AddContentsToCollections, {
contents: contents,
collections: collections,
});
}
async removeContentsFromCollection(contents, collection) {
return this.mutateAndCheckError(Documents.RemoveContentsFromCollection, {
contents: contents,
collection: collection,
});
}
async getCollection(id) {
return this.queryAndCheckError(Documents.GetCollection, { id: id });
}
async queryCollections(filter) {
return this.queryAndCheckError(Documents.QueryCollections, { filter: filter });
}
async countCollections(filter) {
return this.queryAndCheckError(Documents.CountCollections, { filter: filter });
}
async describeImage(prompt, uri, specification, correlationId) {
return this.mutateAndCheckError(Documents.DescribeImage, {
prompt: prompt,
uri: uri,
specification: specification,
correlationId: correlationId,
});
}
async describeEncodedImage(prompt, mimeType, data, specification, correlationId) {
return this.mutateAndCheckError(Documents.DescribeEncodedImage, {
prompt: prompt,
mimeType: mimeType,
data: data,
specification: specification,
correlationId: correlationId,
});
}
async screenshotPage(uri, maximumHeight, isSynchronous, workflow, collections, correlationId) {
return this.mutateAndCheckError(Documents.ScreenshotPage, {
uri: uri,
maximumHeight: maximumHeight,
isSynchronous: isSynchronous,
workflow: workflow,
collections: collections,
correlationId: correlationId,
});
}
async ingestTextBatch(batch, textType, collections, observations, correlationId) {
return this.mutateAndCheckError(Documents.IngestTextBatch, {
batch: batch,
textType: textType,
collections: collections,
observations: observations,
correlationId: correlationId,
});
}
async ingestBatch(uris, workflow, collections, observations, correlationId) {
return this.mutateAndCheckError(Documents.IngestBatch, {
uris: uris,
workflow: workflow,
collections: collections,
observations: observations,
correlationId: correlationId,
});
}
async ingestUri(uri, name, id, isSynchronous, workflow, collections, observations, correlationId) {
return this.mutateAndCheckError(Documents.IngestUri, {
uri: uri,
name: name,
id: id,
isSynchronous: isSynchronous,
workflow: workflow,
collections: collections,
observations: observations,
correlationId: correlationId,
});
}
async ingestText(text, name, textType, uri, id, isSynchronous, workflow, collections, observations, correlationId) {
return this.mutateAndCheckError(Documents.IngestText, {
name: name,
text: text,
textType: textType,
uri: uri,
id: id,
isSynchronous: isSynchronous,
workflow: workflow,
collections: collections,
observations: observations,
correlationId: correlationId,
});
}
async ingestMemory(text, name, textType, id, collections, correlationId) {
return this.mutateAndCheckError(Documents.IngestMemory, {
name: name,
text: text,
textType: textType,
id: id,
collections: collections,
correlationId: correlationId,
});
}
async ingestEvent(markdown, name, description, eventDate, id, collections, correlationId) {
return this.mutateAndCheckError(Documents.IngestEvent, {
name: name,
markdown: markdown,
description: description,
eventDate: eventDate,
id: id,
collections: collections,
correlationId: correlationId,
});
}
async ingestEncodedFile(name, data, mimeType, fileCreationDate, fileModifiedDate, id, isSynchronous, workflow, collections, observations, correlationId) {
return this.mutateAndCheckError(Documents.IngestEncodedFile, {
name: name,
data: data,
mimeType: mimeType,
fileCreationDate: fileCreationDate,
fileModifiedDate: fileModifiedDate,
id: id,
isSynchronous: isSynchronous,
workflow: workflow,
collections: collections,
observations: observations,
correlationId: correlationId,
});
}
async updateContent(content) {
return this.mutateAndCheckError(Documents.UpdateContent, { content: content });
}
async deleteContent(id) {
return this.mutateAndCheckError(Documents.DeleteContent, { id: id });
}
async deleteContents(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteContents, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllContents(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllContents, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async summarizeText(summarization, text, textType, correlationId) {
return this.mutateAndCheckError(Documents.SummarizeText, {
summarization: summarization,
text: text,
textType: textType,
correlationId: correlationId,
});
}
async summarizeContents(summarizations, filter, correlationId) {
return this.mutateAndCheckError(Documents.SummarizeContents, {
summarizations: summarizations,
filter: filter,
correlationId: correlationId,
});
}
async extractText(prompt, text, tools, specification, textType, correlationId) {
return this.mutateAndCheckError(Documents.ExtractText, {
prompt: prompt,
text: text,
textType: textType,
specification: specification,
tools: tools,
correlationId: correlationId,
});
}
async extractContents(prompt, tools, specification, filter, correlationId) {
return this.mutateAndCheckError(Documents.ExtractContents, {
prompt: prompt,
filter: filter,
specification: specification,
tools: tools,
correlationId: correlationId,
});
}
async publishContents(publishPrompt, connector, summaryPrompt, summarySpecification, publishSpecification, name, filter, workflow, isSynchronous, includeDetails, correlationId) {
return this.mutateAndCheckError(Documents.PublishContents, {
summaryPrompt: summaryPrompt,
summarySpecification: summarySpecification,
connector: connector,
publishPrompt: publishPrompt,
publishSpecification: publishSpecification,
name: name,
filter: filter,
workflow: workflow,
isSynchronous: isSynchronous,
includeDetails: includeDetails,
correlationId: correlationId,
});
}
async publishText(text, textType, connector, name, workflow, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.PublishText, {
text: text,
textType: textType,
connector: connector,
name: name,
workflow: workflow,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async getContent(id) {
return this.queryAndCheckError(Documents.GetContent, { id: id });
}
async lookupContents(ids) {
return this.queryAndCheckError(Documents.LookupContents, { ids: ids });
}
async queryContents(filter) {
return this.queryAndCheckError(Documents.QueryContents, { filter: filter });
}
async queryContentsFacets(filter) {
return this.queryAndCheckError(Documents.QueryContentsFacets, { filter: filter });
}
async queryContentsGraph(filter) {
return this.queryAndCheckError(Documents.QueryContentsGraph, {
filter: filter,
graph: {
/* return everything */
},
});
}
async countContents(filter) {
return this.queryAndCheckError(Documents.CountContents, { filter: filter });
}
async isContentDone(id) {
return this.queryAndCheckError(Documents.IsContentDone, { id: id });
}
async createConversation(conversation, correlationId) {
return this.mutateAndCheckError(Documents.CreateConversation, {
conversation: conversation,
correlationId: correlationId,
});
}
async updateConversation(conversation) {
return this.mutateAndCheckError(Documents.UpdateConversation, { conversation: conversation });
}
async deleteConversation(id) {
return this.mutateAndCheckError(Documents.DeleteConversation, { id: id });
}
async deleteConversations(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteConversations, {
ids: ids,
isSynchronous: isSynchronous,
});
}
async deleteAllConversations(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllConversations, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async clearConversation(id) {
return this.mutateAndCheckError(Documents.ClearConversation, { id: id });
}
async closeConversation(id) {
return this.mutateAndCheckError(Documents.CloseConversation, { id: id });
}
async getConversation(id) {
return this.queryAndCheckError(Documents.GetConversation, { id: id });
}
async queryConversations(filter) {
return this.queryAndCheckError(Documents.QueryConversations, { filter: filter });
}
async countConversations(filter) {
return this.queryAndCheckError(Documents.CountConversations, { filter: filter });
}
async reviseImage(prompt, uri, id, specification, correlationId) {
return this.mutateAndCheckError(Documents.ReviseImage, {
prompt: prompt,
uri: uri,
id: id,
specification: specification,
correlationId: correlationId,
});
}
async reviseEncodedImage(prompt, mimeType, data, id, specification, correlationId) {
return this.mutateAndCheckError(Documents.ReviseEncodedImage, {
prompt: prompt,
mimeType: mimeType,
data: data,
id: id,
specification: specification,
correlationId: correlationId,
});
}
async reviseText(prompt, text, id, specification, correlationId) {
return this.mutateAndCheckError(Documents.ReviseText, {
prompt: prompt,
text: text,
id: id,
specification: specification,
correlationId: correlationId,
});
}
async reviseContent(prompt, content, id, specification, correlationId) {
return this.mutateAndCheckError(Documents.ReviseContent, {
prompt: prompt,
content: content,
id: id,
specification: specification,
correlationId: correlationId,
});
}
async prompt(prompt, mimeType, data, specification, messages, correlationId) {
return this.mutateAndCheckError(Documents.Prompt, {
prompt: prompt,
mimeType: mimeType,
data: data,
specification: specification,
messages: messages,
correlationId: correlationId,
});
}
async retrieveSources(prompt, filter, augmentedFilter, retrievalStrategy, rerankingStrategy, correlationId) {
return this.mutateAndCheckError(Documents.RetrieveSources, {
prompt: prompt,
filter: filter,
augmentedFilter: augmentedFilter,
retrievalStrategy: retrievalStrategy,
rerankingStrategy: rerankingStrategy,
correlationId: correlationId,
});
}
async formatConversation(prompt, id, specification, tools, includeDetails, correlationId) {
return this.mutateAndCheckError(Documents.FormatConversation, {
prompt: prompt,
id: id,
specification: specification,
tools: tools,
includeDetails: includeDetails,
correlationId: correlationId,
});
}
async completeConversation(completion, id, correlationId) {
return this.mutateAndCheckError(Documents.CompleteConversation, {
completion: completion,
id: id,
correlationId: correlationId,
});
}
async askGraphlit(prompt, type, id, specification, correlationId) {
return this.mutateAndCheckError(Documents.AskGraphlit, {
prompt: prompt,
type: type,
id: id,
specification: specification,
correlationId: correlationId,
});
}
async branchConversation(id) {
return this.mutateAndCheckError(Documents.BranchConversation, {
id: id,
});
}
async promptConversation(prompt, id, specification, mimeType, data, tools, requireTool, includeDetails, correlationId) {
return this.mutateAndCheckError(Documents.PromptConversation, {
prompt: prompt,
id: id,
specification: specification,
mimeType: mimeType,
data: data,
tools: tools,
requireTool: requireTool,
includeDetails: includeDetails,
correlationId: correlationId,
});
}
async continueConversation(id, responses, correlationId) {
return this.mutateAndCheckError(Documents.ContinueConversation, {
id: id,
responses: responses,
correlationId: correlationId,
});
}
async publishConversation(id, connector, name, workflow, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.PublishConversation, {
id: id,
connector: connector,
name: name,
workflow: workflow,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async suggestConversation(id, count, correlationId) {
return this.mutateAndCheckError(Documents.SuggestConversation, {
id: id,
count: count,
correlationId: correlationId,
});
}
async queryOneDriveFolders(properties, folderId) {
return this.queryAndCheckError(Documents.QueryOneDriveFolders, {
properties: properties,
folderId: folderId,
});
}
async querySharePointFolders(properties, libraryId, folderId) {
return this.queryAndCheckError(Documents.QuerySharePointFolders, {
properties: properties,
libraryId: libraryId,
folderId: folderId,
});
}
async querySharePointLibraries(properties) {
return this.queryAndCheckError(Documents.QuerySharePointLibraries, { properties: properties });
}
async queryMicrosoftTeamsTeams(properties) {
return this.queryAndCheckError(Documents.QueryMicrosoftTeamsTeams, { properties: properties });
}
async queryMicrosoftTeamsChannels(properties, teamId) {
return this.queryAndCheckError(Documents.QueryMicrosoftTeamsChannels, {
properties: properties,
teamId: teamId,
});
}
async querySlackChannels(properties) {
return this.queryAndCheckError(Documents.QuerySlackChannels, { properties: properties });
}
async queryLinearProjects(properties) {
return this.queryAndCheckError(Documents.QueryLinearProjects, { properties: properties });
}
async queryNotionDatabases(properties) {
return this.queryAndCheckError(Documents.QueryNotionDatabases, { properties: properties });
}
async queryNotionPages(properties, identifier) {
return this.queryAndCheckError(Documents.QueryNotionPages, {
properties: properties,
identifier: identifier,
});
}
async createFeed(feed, correlationId) {
return this.mutateAndCheckError(Documents.CreateFeed, { feed: feed, correlationId: correlationId });
}
async updateFeed(feed) {
return this.mutateAndCheckError(Documents.UpdateFeed, { feed: feed });
}
async deleteFeed(id) {
return this.mutateAndCheckError(Documents.DeleteFeed, { id: id });
}
async deleteFeeds(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteFeeds, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllFeeds(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllFeeds, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async enableFeed(id) {
return this.mutateAndCheckError(Documents.EnableFeed, { id: id });
}
async disableFeed(id) {
return this.mutateAndCheckError(Documents.DisableFeed, { id: id });
}
async getFeed(id) {
return this.queryAndCheckError(Documents.GetFeed, { id: id });
}
async queryFeeds(filter) {
return this.queryAndCheckError(Documents.QueryFeeds, { filter: filter });
}
async countFeeds(filter) {
return this.queryAndCheckError(Documents.CountFeeds, { filter: filter });
}
async feedExists(filter) {
return this.queryAndCheckError(Documents.FeedExists, { filter: filter });
}
async isFeedDone(id) {
return this.queryAndCheckError(Documents.IsFeedDone, { id: id });
}
async promptSpecifications(prompt, ids) {
return this.mutateAndCheckError(Documents.PromptSpecifications, { prompt: prompt, ids: ids });
}
async createSpecification(specification) {
return this.mutateAndCheckError(Documents.CreateSpecification, { specification: specification });
}
async updateSpecification(specification) {
return this.mutateAndCheckError(Documents.UpdateSpecification, { specification: specification });
}
async upsertSpecification(specification) {
return this.mutateAndCheckError(Documents.UpsertSpecification, { specification: specification });
}
async deleteSpecification(id) {
return this.mutateAndCheckError(Documents.DeleteSpecification, { id: id });
}
async deleteSpecifications(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteSpecifications, {
ids: ids,
isSynchronous: isSynchronous,
});
}
async deleteAllSpecifications(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllSpecifications, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async getSpecification(id) {
return this.queryAndCheckError(Documents.GetSpecification, { id: id });
}
async querySpecifications(filter) {
return this.queryAndCheckError(Documents.QuerySpecifications, { filter: filter });
}
async countSpecifications(filter) {
return this.queryAndCheckError(Documents.CountSpecifications, { filter: filter });
}
async specificationExists(filter) {
return this.queryAndCheckError(Documents.SpecificationExists, { filter: filter });
}
async queryModels(filter) {
return this.queryAndCheckError(Documents.QueryModels, { filter: filter });
}
async createWorkflow(workflow) {
return this.mutateAndCheckError(Documents.CreateWorkflow, { workflow: workflow });
}
async updateWorkflow(workflow) {
return this.mutateAndCheckError(Documents.UpdateWorkflow, { workflow: workflow });
}
async upsertWorkflow(workflow) {
return this.mutateAndCheckError(Documents.UpsertWorkflow, { workflow: workflow });
}
async deleteWorkflow(id) {
return this.mutateAndCheckError(Documents.DeleteWorkflow, { id: id });
}
async deleteWorkflows(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteWorkflows, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllWorkflows(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllWorkflows, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async getWorkflow(id) {
return this.queryAndCheckError(Documents.GetWorkflow, { id: id });
}
async queryWorkflows(filter) {
return this.queryAndCheckError(Documents.QueryWorkflows, { filter: filter });
}
async countWorkflows(filter) {
return this.queryAndCheckError(Documents.CountWorkflows, { filter: filter });
}
async workflowExists(filter) {
return this.queryAndCheckError(Documents.WorkflowExists, { filter: filter });
}
async createUser(user) {
return this.mutateAndCheckError(Documents.CreateUser, { user: user });
}
async updateUser(user) {
return this.mutateAndCheckError(Documents.UpdateUser, { user: user });
}
async deleteUser(id) {
return this.mutateAndCheckError(Documents.DeleteUser, { id: id });
}
async getUser() {
return this.queryAndCheckError(Documents.GetUser, {});
}
async queryUsers(filter) {
return this.queryAndCheckError(Documents.QueryUsers, { filter: filter });
}
async countUsers(filter) {
return this.queryAndCheckError(Documents.CountUsers, { filter: filter });
}
async enableUser(id) {
return this.mutateAndCheckError(Documents.EnableUser, { id: id });
}
async disableUser(id) {
return this.mutateAndCheckError(Documents.DisableUser, { id: id });
}
async createCategory(category) {
return this.mutateAndCheckError(Documents.CreateCategory, { category: category });
}
async updateCategory(category) {
return this.mutateAndCheckError(Documents.UpdateCategory, { category: category });
}
async upsertCategory(category) {
return this.mutateAndCheckError(Documents.UpsertCategory, { category: category });
}
async deleteCategory(id) {
return this.mutateAndCheckError(Documents.DeleteCategory, { id: id });
}
async deleteCategories(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteCategories, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllCategories(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllCategories, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async getCategory(id) {
return this.queryAndCheckError(Documents.GetCategory, { id: id });
}
async queryCategories(filter) {
return this.queryAndCheckError(Documents.QueryCategories, { filter: filter });
}
async createLabel(label) {
return this.mutateAndCheckError(Documents.CreateLabel, { label: label });
}
async updateLabel(label) {
return this.mutateAndCheckError(Documents.UpdateLabel, { label: label });
}
async upsertLabel(label) {
return this.mutateAndCheckError(Documents.UpsertLabel, { label: label });
}
async deleteLabel(id) {
return this.mutateAndCheckError(Documents.DeleteLabel, { id: id });
}
async deleteLabels(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteLabels, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllLabels(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllLabels, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async getLabel(id) {
return this.queryAndCheckError(Documents.GetLabel, { id: id });
}
async queryLabels(filter) {
return this.queryAndCheckError(Documents.QueryLabels, { filter: filter });
}
async createPerson(person) {
return this.mutateAndCheckError(Documents.CreatePerson, { person: person });
}
async updatePerson(person) {
return this.mutateAndCheckError(Documents.UpdatePerson, { person: person });
}
async deletePerson(id) {
return this.mutateAndCheckError(Documents.DeletePerson, { id: id });
}
async deletePersons(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeletePersons, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllPersons(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllPersons, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async getPerson(id) {
return this.queryAndCheckError(Documents.GetPerson, { id: id });
}
async queryPersons(filter) {
return this.queryAndCheckError(Documents.QueryPersons, { filter: filter });
}
async createOrganization(organization) {
return this.mutateAndCheckError(Documents.CreateOrganization, { organization: organization });
}
async updateOrganization(organization) {
return this.mutateAndCheckError(Documents.UpdateOrganization, { organization: organization });
}
async deleteOrganization(id) {
return this.mutateAndCheckError(Documents.DeleteOrganization, { id: id });
}
async deleteOrganizations(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteOrganizations, {
ids: ids,
isSynchronous: isSynchronous,
});
}
async deleteAllOrganizations(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllOrganizations, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async getOrganization(id) {
return this.queryAndCheckError(Documents.GetOrganization, { id: id });
}
async queryOrganizations(filter) {
return this.queryAndCheckError(Documents.QueryOrganizations, { filter: filter });
}
async createPlace(place) {
return this.mutateAndCheckError(Documents.CreatePlace, { place: place });
}
async updatePlace(place) {
return this.mutateAndCheckError(Documents.UpdatePlace, { place: place });
}
async deletePlace(id) {
return this.mutateAndCheckError(Documents.DeletePlace, { id: id });
}
async deletePlaces(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeletePlaces, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllPlaces(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllPlaces, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async getPlace(id) {
return this.queryAndCheckError(Documents.GetPlace, { id: id });
}
async queryPlaces(filter) {
return this.queryAndCheckError(Documents.QueryPlaces, { filter: filter });
}
async createEvent(event) {
return this.mutateAndCheckError(Documents.CreateEvent, { event: event });
}
async updateEvent(event) {
return this.mutateAndCheckError(Documents.UpdateEvent, { event: event });
}
async deleteEvent(id) {
return this.mutateAndCheckError(Documents.DeleteEvent, { id: id });
}
async deleteEvents(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteEvents, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllEvents(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllEvents, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async getEvent(id) {
return this.queryAndCheckError(Documents.GetEvent, { id: id });
}
async queryEvents(filter) {
return this.queryAndCheckError(Documents.QueryEvents, { filter: filter });
}
async createProduct(product) {
return this.mutateAndCheckError(Documents.CreateProduct, { product: product });
}
async updateProduct(product) {
return this.mutateAndCheckError(Documents.UpdateProduct, { product: product });
}
async deleteProduct(id) {
return this.mutateAndCheckError(Documents.DeleteProduct, { id: id });
}
async deleteProducts(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteProducts, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllProducts(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllProducts, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async getProduct(id) {
return this.queryAndCheckError(Documents.GetProduct, { id: id });
}
async queryProducts(filter) {
return this.queryAndCheckError(Documents.QueryProducts, { filter: filter });
}
async createRepo(repo) {
return this.mutateAndCheckError(Documents.CreateRepo, { repo: repo });
}
async updateRepo(repo) {
return this.mutateAndCheckError(Documents.UpdateRepo, { repo: repo });
}
async deleteRepo(id) {
return this.mutateAndCheckError(Documents.DeleteRepo, { id: id });
}
async deleteRepos(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteRepos, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllRepos(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllRepos, {
filter: filter,
isSynchronous: isSynchronous,
correlationId: correlationId,
});
}
async getRepo(id) {
return this.queryAndCheckError(Documents.GetRepo, { id: id });
}
async queryRepos(filter) {
return this.queryAndCheckError(Documents.QueryRepos, { filter: filter });
}
async createSoftware(software) {
return this.mutateAndCheckError(Documents.CreateSoftware, { software: software });
}
async updateSoftware(software) {
return this.mutateAndCheckError(Documents.UpdateSoftware, { software: software });
}
async deleteSoftware(id) {
return this.mutateAndCheckError(Documents.DeleteSoftware, { id: id });
}
async deleteSoftwares(ids, isSynchronous) {
return this.mutateAndCheckError(Documents.DeleteSoftwares, { ids: ids, isSynchronous: isSynchronous });
}
async deleteAllSoftwares(filter, isSynchronous, correlationId) {
return this.mutateAndCheckError(Documents.DeleteAllSoftwares, {
filter: filter,
isSynchronous: isSynchronous,
co