graphlit-client 1.0.20250613008 → 1.0.20250615001

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -973,6 +973,7 @@ export const GetContent = gql `
973
973
  mimeType
974
974
  format
975
975
  formatName
976
+ fileExtension
976
977
  fileName
977
978
  fileSize
978
979
  masterUri
@@ -988,6 +989,7 @@ export const GetContent = gql `
988
989
  posts
989
990
  chapters
990
991
  questions
992
+ quotes
991
993
  video {
992
994
  width
993
995
  height
@@ -1642,6 +1644,7 @@ export const LookupContents = gql `
1642
1644
  mimeType
1643
1645
  format
1644
1646
  formatName
1647
+ fileExtension
1645
1648
  fileName
1646
1649
  fileSize
1647
1650
  masterUri
@@ -1657,6 +1660,7 @@ export const LookupContents = gql `
1657
1660
  posts
1658
1661
  chapters
1659
1662
  questions
1663
+ quotes
1660
1664
  video {
1661
1665
  width
1662
1666
  height
@@ -2156,6 +2160,9 @@ export const QueryContents = gql `
2156
2160
  type
2157
2161
  fileType
2158
2162
  mimeType
2163
+ format
2164
+ formatName
2165
+ fileExtension
2159
2166
  fileName
2160
2167
  fileSize
2161
2168
  masterUri
@@ -15059,6 +15059,7 @@ export type GetContentQuery = {
15059
15059
  mimeType?: string | null;
15060
15060
  format?: string | null;
15061
15061
  formatName?: string | null;
15062
+ fileExtension?: string | null;
15062
15063
  fileName?: string | null;
15063
15064
  fileSize?: any | null;
15064
15065
  masterUri?: any | null;
@@ -15074,6 +15075,7 @@ export type GetContentQuery = {
15074
15075
  posts?: Array<string> | null;
15075
15076
  chapters?: Array<string> | null;
15076
15077
  questions?: Array<string> | null;
15078
+ quotes?: Array<string> | null;
15077
15079
  error?: string | null;
15078
15080
  owner: {
15079
15081
  __typename?: 'Owner';
@@ -15817,6 +15819,7 @@ export type LookupContentsQuery = {
15817
15819
  mimeType?: string | null;
15818
15820
  format?: string | null;
15819
15821
  formatName?: string | null;
15822
+ fileExtension?: string | null;
15820
15823
  fileName?: string | null;
15821
15824
  fileSize?: any | null;
15822
15825
  masterUri?: any | null;
@@ -15832,6 +15835,7 @@ export type LookupContentsQuery = {
15832
15835
  posts?: Array<string> | null;
15833
15836
  chapters?: Array<string> | null;
15834
15837
  questions?: Array<string> | null;
15838
+ quotes?: Array<string> | null;
15835
15839
  error?: string | null;
15836
15840
  owner: {
15837
15841
  __typename?: 'Owner';
@@ -16402,6 +16406,9 @@ export type QueryContentsQuery = {
16402
16406
  type?: ContentTypes | null;
16403
16407
  fileType?: FileTypes | null;
16404
16408
  mimeType?: string | null;
16409
+ format?: string | null;
16410
+ formatName?: string | null;
16411
+ fileExtension?: string | null;
16405
16412
  fileName?: string | null;
16406
16413
  fileSize?: any | null;
16407
16414
  masterUri?: any | null;
@@ -77,11 +77,63 @@ const GOOGLE_MODEL_MAP = {
77
77
  // Gemini 2.0 Flash models
78
78
  [Types.GoogleModels.Gemini_2_0Flash]: "gemini-2.0-flash-exp",
79
79
  [Types.GoogleModels.Gemini_2_0Flash_001]: "gemini-2.0-flash-001",
80
- [Types.GoogleModels.Gemini_2_0FlashExperimental]: "gemini-2.0-flash-exp",
81
80
  // Gemini 2.5 models
82
81
  [Types.GoogleModels.Gemini_2_5FlashPreview]: "gemini-2.5-flash-preview-05-20",
83
82
  [Types.GoogleModels.Gemini_2_5ProPreview]: "gemini-2.5-pro-preview-06-05",
84
83
  };
84
+ // Groq model mappings
85
+ const GROQ_MODEL_MAP = {
86
+ [Types.GroqModels.Llama_4Scout_17B]: "meta-llama/llama-4-scout-17b-16e-instruct",
87
+ [Types.GroqModels.Llama_4Maverick_17B]: "meta-llama/llama-4-maverick-17b-128e-instruct",
88
+ [Types.GroqModels.DeepseekR1Llama_70BPreview]: "deepseek-r1-distill-llama-70b",
89
+ [Types.GroqModels.Llama_3_3_70B]: "llama-3.3-70b-versatile",
90
+ [Types.GroqModels.Mixtral_8X7BInstruct]: "mixtral-8x7b-32768",
91
+ [Types.GroqModels.Llama_3_1_8B]: "llama-3.1-8b-instant",
92
+ [Types.GroqModels.Llama_3_70B]: "llama3-70b-8192",
93
+ [Types.GroqModels.Llama_3_8B]: "llama3-8b-8192",
94
+ };
95
+ // Cerebras model mappings
96
+ const CEREBRAS_MODEL_MAP = {
97
+ [Types.CerebrasModels.Llama_3_3_70B]: "llama3.3-70b",
98
+ [Types.CerebrasModels.Llama_3_1_8B]: "llama3.1-8b",
99
+ };
100
+ // Cohere model mappings
101
+ const COHERE_MODEL_MAP = {
102
+ [Types.CohereModels.CommandRPlus]: "command-r-plus",
103
+ [Types.CohereModels.CommandRPlus_202404]: "command-r-plus-04-2024",
104
+ [Types.CohereModels.CommandRPlus_202408]: "command-r-plus-08-2024",
105
+ [Types.CohereModels.CommandR]: "command-r",
106
+ [Types.CohereModels.CommandR_202403]: "command-r-03-2024",
107
+ [Types.CohereModels.CommandR_202408]: "command-r-08-2024",
108
+ [Types.CohereModels.CommandR7B_202412]: "command-r7b-12-2024",
109
+ [Types.CohereModels.CommandA]: "command-light",
110
+ [Types.CohereModels.CommandA_202503]: "command-light-nightly",
111
+ };
112
+ // Mistral model mappings
113
+ const MISTRAL_MODEL_MAP = {
114
+ [Types.MistralModels.MistralEmbed]: "mistral-embed",
115
+ [Types.MistralModels.PixtralLarge]: "pixtral-large-latest",
116
+ [Types.MistralModels.Pixtral_12B_2409]: "pixtral-12b-2409",
117
+ [Types.MistralModels.MistralNemo]: "open-mistral-nemo",
118
+ [Types.MistralModels.MistralSmall]: "mistral-small-latest",
119
+ [Types.MistralModels.MistralMedium]: "mistral-medium-latest",
120
+ [Types.MistralModels.MistralLarge]: "mistral-large-latest",
121
+ };
122
+ // Bedrock model mappings
123
+ // Note: These use "us." prefix for us-east-2 region. For other regions,
124
+ // use the modelName field in specification to override with correct region prefix
125
+ const BEDROCK_MODEL_MAP = {
126
+ [Types.BedrockModels.NovaPremier]: "us.amazon.nova-premier-v1:0",
127
+ [Types.BedrockModels.NovaPro]: "us.amazon.nova-pro-v1:0",
128
+ [Types.BedrockModels.Claude_3_7Sonnet]: "us.anthropic.claude-3-7-sonnet-20250219-v1:0",
129
+ [Types.BedrockModels.Llama_4Scout_17B]: "us.meta.llama4-scout-17b-instruct-v1:0",
130
+ [Types.BedrockModels.Llama_4Maverick_17B]: "us.meta.llama4-maverick-17b-instruct-v1:0",
131
+ };
132
+ // Deepseek model mappings (uses OpenAI-compatible API)
133
+ const DEEPSEEK_MODEL_MAP = {
134
+ [Types.DeepseekModels.Chat]: "deepseek-chat",
135
+ [Types.DeepseekModels.Reasoner]: "deepseek-reasoner",
136
+ };
85
137
  /**
86
138
  * Get the actual model name for a given specification
87
139
  * @param specification - The Graphlit specification object
@@ -99,6 +151,24 @@ export function getModelName(specification) {
99
151
  if (specification?.google?.modelName) {
100
152
  return specification.google.modelName;
101
153
  }
154
+ if (specification?.groq?.modelName) {
155
+ return specification.groq.modelName;
156
+ }
157
+ if (specification?.cerebras?.modelName) {
158
+ return specification.cerebras.modelName;
159
+ }
160
+ if (specification?.cohere?.modelName) {
161
+ return specification.cohere.modelName;
162
+ }
163
+ if (specification?.mistral?.modelName) {
164
+ return specification.mistral.modelName;
165
+ }
166
+ if (specification?.bedrock?.modelName) {
167
+ return specification.bedrock.modelName;
168
+ }
169
+ if (specification?.deepseek?.modelName) {
170
+ return specification.deepseek.modelName;
171
+ }
102
172
  // Map based on service type and model enum
103
173
  switch (serviceType) {
104
174
  case Types.ModelServiceTypes.OpenAi:
@@ -110,6 +180,25 @@ export function getModelName(specification) {
110
180
  case Types.ModelServiceTypes.Google:
111
181
  const googleModel = specification?.google?.model;
112
182
  return googleModel ? GOOGLE_MODEL_MAP[googleModel] : undefined;
183
+ case Types.ModelServiceTypes.Groq:
184
+ const groqModel = specification?.groq?.model;
185
+ return groqModel ? GROQ_MODEL_MAP[groqModel] : undefined;
186
+ case Types.ModelServiceTypes.Cerebras:
187
+ const cerebrasModel = specification?.cerebras?.model;
188
+ return cerebrasModel ? CEREBRAS_MODEL_MAP[cerebrasModel] : undefined;
189
+ case Types.ModelServiceTypes.Cohere:
190
+ const cohereModel = specification?.cohere?.model;
191
+ return cohereModel ? COHERE_MODEL_MAP[cohereModel] : undefined;
192
+ case Types.ModelServiceTypes.Mistral:
193
+ const mistralModel = specification?.mistral?.model;
194
+ return mistralModel ? MISTRAL_MODEL_MAP[mistralModel] : undefined;
195
+ case Types.ModelServiceTypes.Bedrock:
196
+ // For Bedrock, we use the bedrock model field
197
+ const bedrockModel = specification?.bedrock?.model;
198
+ return bedrockModel ? BEDROCK_MODEL_MAP[bedrockModel] : undefined;
199
+ case Types.ModelServiceTypes.Deepseek:
200
+ const deepseekModel = specification?.deepseek?.model;
201
+ return deepseekModel ? DEEPSEEK_MODEL_MAP[deepseekModel] : undefined;
113
202
  default:
114
203
  return undefined;
115
204
  }
@@ -124,6 +213,12 @@ export function isStreamingSupported(serviceType) {
124
213
  Types.ModelServiceTypes.OpenAi,
125
214
  Types.ModelServiceTypes.Anthropic,
126
215
  Types.ModelServiceTypes.Google,
216
+ Types.ModelServiceTypes.Groq,
217
+ Types.ModelServiceTypes.Cerebras,
218
+ Types.ModelServiceTypes.Cohere,
219
+ Types.ModelServiceTypes.Mistral,
220
+ Types.ModelServiceTypes.Bedrock,
221
+ Types.ModelServiceTypes.Deepseek,
127
222
  ];
128
223
  return streamingServices.includes(serviceType);
129
224
  }
@@ -77,3 +77,60 @@ export declare function formatMessagesForAnthropic(messages: ConversationMessage
77
77
  * Format GraphQL conversation messages for Google SDK
78
78
  */
79
79
  export declare function formatMessagesForGoogle(messages: ConversationMessage[]): GoogleMessage[];
80
+ /**
81
+ * Cohere message format
82
+ */
83
+ export interface CohereMessage {
84
+ role: "USER" | "CHATBOT" | "SYSTEM";
85
+ message: string;
86
+ }
87
+ /**
88
+ * Format GraphQL conversation messages for Cohere SDK
89
+ */
90
+ export declare function formatMessagesForCohere(messages: ConversationMessage[]): CohereMessage[];
91
+ /**
92
+ * Mistral message format
93
+ */
94
+ export interface MistralMessage {
95
+ role: "system" | "user" | "assistant" | "tool";
96
+ content: string | Array<{
97
+ type: "text" | "image_url";
98
+ text?: string;
99
+ image_url?: string;
100
+ }>;
101
+ tool_calls?: Array<{
102
+ id: string;
103
+ function: {
104
+ name: string;
105
+ arguments: string;
106
+ };
107
+ }>;
108
+ tool_call_id?: string;
109
+ }
110
+ /**
111
+ * Format GraphQL conversation messages for Mistral SDK
112
+ */
113
+ export declare function formatMessagesForMistral(messages: ConversationMessage[]): MistralMessage[];
114
+ /**
115
+ * Bedrock Claude message format (similar to Anthropic)
116
+ */
117
+ export interface BedrockMessage {
118
+ role: "user" | "assistant";
119
+ content: string | Array<{
120
+ type: "text" | "image";
121
+ text?: string;
122
+ image?: {
123
+ format: "png" | "jpeg" | "gif" | "webp";
124
+ source: {
125
+ bytes: string;
126
+ };
127
+ };
128
+ }>;
129
+ }
130
+ /**
131
+ * Format GraphQL conversation messages for Bedrock SDK (Claude models)
132
+ */
133
+ export declare function formatMessagesForBedrock(messages: ConversationMessage[]): {
134
+ system?: string;
135
+ messages: BedrockMessage[];
136
+ };
@@ -267,3 +267,175 @@ export function formatMessagesForGoogle(messages) {
267
267
  }
268
268
  return formattedMessages;
269
269
  }
270
+ /**
271
+ * Format GraphQL conversation messages for Cohere SDK
272
+ */
273
+ export function formatMessagesForCohere(messages) {
274
+ const formattedMessages = [];
275
+ for (const message of messages) {
276
+ if (!message.role || !message.message?.trim())
277
+ continue;
278
+ const trimmedMessage = message.message.trim();
279
+ switch (message.role) {
280
+ case ConversationRoleTypes.System:
281
+ formattedMessages.push({
282
+ role: "SYSTEM",
283
+ message: trimmedMessage,
284
+ });
285
+ break;
286
+ case ConversationRoleTypes.Assistant:
287
+ formattedMessages.push({
288
+ role: "CHATBOT",
289
+ message: trimmedMessage,
290
+ });
291
+ break;
292
+ default: // User messages
293
+ formattedMessages.push({
294
+ role: "USER",
295
+ message: trimmedMessage,
296
+ });
297
+ break;
298
+ }
299
+ }
300
+ return formattedMessages;
301
+ }
302
+ /**
303
+ * Format GraphQL conversation messages for Mistral SDK
304
+ */
305
+ export function formatMessagesForMistral(messages) {
306
+ const formattedMessages = [];
307
+ for (const message of messages) {
308
+ if (!message.role)
309
+ continue;
310
+ const hasContent = message.message?.trim();
311
+ const hasToolCalls = message.toolCalls && message.toolCalls.length > 0;
312
+ if (!hasContent && !hasToolCalls)
313
+ continue;
314
+ const trimmedMessage = message.message?.trim() || "";
315
+ switch (message.role) {
316
+ case ConversationRoleTypes.System:
317
+ formattedMessages.push({
318
+ role: "system",
319
+ content: trimmedMessage,
320
+ });
321
+ break;
322
+ case ConversationRoleTypes.Assistant:
323
+ const assistantMessage = {
324
+ role: "assistant",
325
+ content: trimmedMessage,
326
+ };
327
+ // Add tool calls if present
328
+ if (message.toolCalls && message.toolCalls.length > 0) {
329
+ assistantMessage.tool_calls = message.toolCalls
330
+ .filter((tc) => tc !== null)
331
+ .map((toolCall) => ({
332
+ id: toolCall.id,
333
+ function: {
334
+ name: toolCall.name,
335
+ arguments: toolCall.arguments,
336
+ },
337
+ }));
338
+ }
339
+ formattedMessages.push(assistantMessage);
340
+ break;
341
+ case ConversationRoleTypes.Tool:
342
+ formattedMessages.push({
343
+ role: "tool",
344
+ content: trimmedMessage,
345
+ tool_call_id: message.toolCallId || "",
346
+ });
347
+ break;
348
+ default: // User messages
349
+ // Check if this message has image data
350
+ if (message.mimeType && message.data) {
351
+ // Multi-modal message with image
352
+ const contentParts = [];
353
+ // Add text content if present
354
+ if (trimmedMessage) {
355
+ contentParts.push({
356
+ type: "text",
357
+ text: trimmedMessage,
358
+ });
359
+ }
360
+ // Add image content
361
+ contentParts.push({
362
+ type: "image_url",
363
+ image_url: `data:${message.mimeType};base64,${message.data}`,
364
+ });
365
+ formattedMessages.push({
366
+ role: "user",
367
+ content: contentParts,
368
+ });
369
+ }
370
+ else {
371
+ // Text-only message
372
+ formattedMessages.push({
373
+ role: "user",
374
+ content: trimmedMessage,
375
+ });
376
+ }
377
+ break;
378
+ }
379
+ }
380
+ return formattedMessages;
381
+ }
382
+ /**
383
+ * Format GraphQL conversation messages for Bedrock SDK (Claude models)
384
+ */
385
+ export function formatMessagesForBedrock(messages) {
386
+ let systemPrompt;
387
+ const formattedMessages = [];
388
+ for (const message of messages) {
389
+ if (!message.role || !message.message?.trim())
390
+ continue;
391
+ const trimmedMessage = message.message.trim();
392
+ switch (message.role) {
393
+ case ConversationRoleTypes.System:
394
+ systemPrompt = trimmedMessage;
395
+ break;
396
+ case ConversationRoleTypes.Assistant:
397
+ formattedMessages.push({
398
+ role: "assistant",
399
+ content: trimmedMessage,
400
+ });
401
+ break;
402
+ default: // User messages
403
+ // Check if this message has image data
404
+ if (message.mimeType && message.data) {
405
+ // Multi-modal message with image
406
+ const contentParts = [];
407
+ // Add text content if present
408
+ if (trimmedMessage) {
409
+ contentParts.push({
410
+ type: "text",
411
+ text: trimmedMessage,
412
+ });
413
+ }
414
+ // Add image content
415
+ const format = message.mimeType.split("/")[1];
416
+ contentParts.push({
417
+ type: "image",
418
+ image: {
419
+ format,
420
+ source: {
421
+ bytes: message.data,
422
+ },
423
+ },
424
+ });
425
+ formattedMessages.push({
426
+ role: "user",
427
+ content: contentParts,
428
+ });
429
+ }
430
+ else {
431
+ // Text-only message
432
+ formattedMessages.push({
433
+ role: "user",
434
+ content: trimmedMessage,
435
+ });
436
+ }
437
+ break;
438
+ }
439
+ }
440
+ return { system: systemPrompt, messages: formattedMessages };
441
+ }
@@ -1,5 +1,5 @@
1
1
  import { ConversationToolCall, Specification, ToolDefinitionInput } from "../generated/graphql-types.js";
2
- import { OpenAIMessage, AnthropicMessage, GoogleMessage } from "./llm-formatters.js";
2
+ import { OpenAIMessage, AnthropicMessage, GoogleMessage, CohereMessage, MistralMessage, BedrockMessage } from "./llm-formatters.js";
3
3
  import { StreamEvent } from "../types/internal.js";
4
4
  /**
5
5
  * Stream with OpenAI SDK
@@ -16,3 +16,33 @@ onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls:
16
16
  */
17
17
  export declare function streamWithGoogle(specification: Specification, messages: GoogleMessage[], systemPrompt: string | undefined, tools: ToolDefinitionInput[] | undefined, googleClient: any, // Google GenerativeAI client instance
18
18
  onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
19
+ /**
20
+ * Stream with Groq SDK (OpenAI-compatible)
21
+ */
22
+ export declare function streamWithGroq(specification: Specification, messages: OpenAIMessage[], tools: ToolDefinitionInput[] | undefined, groqClient: any, // Groq client instance (OpenAI-compatible)
23
+ onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
24
+ /**
25
+ * Stream with Cerebras SDK (OpenAI-compatible)
26
+ */
27
+ export declare function streamWithCerebras(specification: Specification, messages: OpenAIMessage[], tools: ToolDefinitionInput[] | undefined, cerebrasClient: any, // OpenAI client instance configured for Cerebras
28
+ onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
29
+ /**
30
+ * Stream with Deepseek SDK (OpenAI-compatible)
31
+ */
32
+ export declare function streamWithDeepseek(specification: Specification, messages: OpenAIMessage[], tools: ToolDefinitionInput[] | undefined, deepseekClient: any, // OpenAI client instance configured for Deepseek
33
+ onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
34
+ /**
35
+ * Stream with Cohere SDK
36
+ */
37
+ export declare function streamWithCohere(specification: Specification, messages: CohereMessage[], tools: ToolDefinitionInput[] | undefined, cohereClient: any, // CohereClient instance
38
+ onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
39
+ /**
40
+ * Stream with Mistral SDK
41
+ */
42
+ export declare function streamWithMistral(specification: Specification, messages: MistralMessage[], tools: ToolDefinitionInput[] | undefined, mistralClient: any, // Mistral client instance
43
+ onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;
44
+ /**
45
+ * Stream with Bedrock SDK (for Claude models)
46
+ */
47
+ export declare function streamWithBedrock(specification: Specification, messages: BedrockMessage[], systemPrompt: string | undefined, tools: ToolDefinitionInput[] | undefined, bedrockClient: any, // BedrockRuntimeClient instance
48
+ onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[]) => void): Promise<void>;