graphlit-client 1.0.20250924001 → 1.0.20250924002

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.
package/dist/client.js CHANGED
@@ -6,7 +6,7 @@ import { RetryLink } from "@apollo/client/link/retry/index.js";
6
6
  import * as Types from "./generated/graphql-types.js";
7
7
  import * as Documents from "./generated/graphql-documents.js";
8
8
  import * as dotenv from "dotenv";
9
- import { getServiceType, getModelName } from "./model-mapping.js";
9
+ import { getServiceType, getModelName, getModelEnum } from "./model-mapping.js";
10
10
  import { UIEventAdapter } from "./streaming/ui-event-adapter.js";
11
11
  import { formatMessagesForOpenAI, formatMessagesForAnthropic, formatMessagesForGoogle, formatMessagesForMistral, formatMessagesForBedrock, } from "./streaming/llm-formatters.js";
12
12
  import { streamWithOpenAI, streamWithAnthropic, streamWithGoogle, streamWithGroq, streamWithCerebras, streamWithCohere, streamWithMistral, streamWithBedrock, streamWithDeepseek, streamWithXai, } from "./streaming/providers.js";
@@ -2174,12 +2174,14 @@ class Graphlit {
2174
2174
  }
2175
2175
  // Create UI event adapter with model information
2176
2176
  const modelName = fullSpec ? getModelName(fullSpec) : undefined;
2177
+ const modelEnum = fullSpec ? getModelEnum(fullSpec) : undefined;
2177
2178
  const serviceType = fullSpec ? getServiceType(fullSpec) : undefined;
2178
2179
  uiAdapter = new UIEventAdapter(onEvent, actualConversationId, {
2179
2180
  smoothingEnabled: options?.smoothingEnabled ?? true,
2180
2181
  chunkingStrategy: options?.chunkingStrategy ?? "word",
2181
2182
  smoothingDelay: options?.smoothingDelay ?? 30,
2182
- model: modelName,
2183
+ model: modelEnum,
2184
+ modelName: modelName,
2183
2185
  modelService: serviceType,
2184
2186
  });
2185
2187
  // Start the streaming conversation
@@ -16,3 +16,9 @@ export declare function isStreamingSupported(serviceType?: string): boolean;
16
16
  * @returns The service type string
17
17
  */
18
18
  export declare function getServiceType(specification: any): string | undefined;
19
+ /**
20
+ * Get the model enum value from specification
21
+ * @param specification - The specification object
22
+ * @returns The model enum value
23
+ */
24
+ export declare function getModelEnum(specification: any): string | undefined;
@@ -264,3 +264,35 @@ export function isStreamingSupported(serviceType) {
264
264
  export function getServiceType(specification) {
265
265
  return specification?.serviceType;
266
266
  }
267
+ /**
268
+ * Get the model enum value from specification
269
+ * @param specification - The specification object
270
+ * @returns The model enum value
271
+ */
272
+ export function getModelEnum(specification) {
273
+ const serviceType = specification?.serviceType;
274
+ switch (serviceType) {
275
+ case Types.ModelServiceTypes.OpenAi:
276
+ return specification?.openAI?.model;
277
+ case Types.ModelServiceTypes.Anthropic:
278
+ return specification?.anthropic?.model;
279
+ case Types.ModelServiceTypes.Google:
280
+ return specification?.google?.model;
281
+ case Types.ModelServiceTypes.Groq:
282
+ return specification?.groq?.model;
283
+ case Types.ModelServiceTypes.Cerebras:
284
+ return specification?.cerebras?.model;
285
+ case Types.ModelServiceTypes.Cohere:
286
+ return specification?.cohere?.model;
287
+ case Types.ModelServiceTypes.Mistral:
288
+ return specification?.mistral?.model;
289
+ case Types.ModelServiceTypes.Bedrock:
290
+ return specification?.bedrock?.model;
291
+ case Types.ModelServiceTypes.Deepseek:
292
+ return specification?.deepseek?.model;
293
+ case Types.ModelServiceTypes.Xai:
294
+ return specification?.xai?.model;
295
+ default:
296
+ return undefined;
297
+ }
298
+ }
@@ -9,6 +9,7 @@ export declare class UIEventAdapter {
9
9
  private onEvent;
10
10
  private conversationId;
11
11
  private model?;
12
+ private modelName?;
12
13
  private modelService?;
13
14
  private tokenCount;
14
15
  private currentMessage;
@@ -39,6 +40,7 @@ export declare class UIEventAdapter {
39
40
  chunkingStrategy?: ChunkingStrategy;
40
41
  smoothingDelay?: number;
41
42
  model?: string;
43
+ modelName?: string;
42
44
  modelService?: string;
43
45
  });
44
46
  /**
@@ -7,7 +7,8 @@ import { ChunkBuffer } from "./chunk-buffer.js";
7
7
  export class UIEventAdapter {
8
8
  onEvent;
9
9
  conversationId;
10
- model;
10
+ model; // This will now be the enum value
11
+ modelName; // This will be the actual model name (e.g., "claude-sonnet-4-0")
11
12
  modelService;
12
13
  tokenCount = 0;
13
14
  currentMessage = "";
@@ -38,6 +39,7 @@ export class UIEventAdapter {
38
39
  this.conversationId = conversationId;
39
40
  this.smoothingDelay = options.smoothingDelay ?? 30;
40
41
  this.model = options.model;
42
+ this.modelName = options.modelName;
41
43
  this.modelService = options.modelService;
42
44
  this.conversationStartTime = Date.now(); // Capture when conversation began
43
45
  if (options.smoothingEnabled) {
@@ -333,6 +335,7 @@ export class UIEventAdapter {
333
335
  tokens: tokens, // Now we have the actual LLM token count!
334
336
  toolCalls: Array.from(this.activeToolCalls.values()).map((t) => t.toolCall),
335
337
  model: this.model,
338
+ modelName: this.modelName,
336
339
  modelService: this.modelService,
337
340
  };
338
341
  // Add final timing metadata
@@ -514,6 +517,9 @@ export class UIEventAdapter {
514
517
  if (this.model) {
515
518
  message.model = this.model;
516
519
  }
520
+ if (this.modelName) {
521
+ message.modelName = this.modelName;
522
+ }
517
523
  if (this.modelService) {
518
524
  message.modelService = this.modelService;
519
525
  }
@@ -20,6 +20,13 @@ export type ContextWindowEvent = {
20
20
  };
21
21
  timestamp: Date;
22
22
  };
23
+ /**
24
+ * Extended conversation message with additional streaming metadata
25
+ */
26
+ export type StreamingConversationMessage = Partial<ConversationMessage> & {
27
+ message: string;
28
+ modelName?: string;
29
+ };
23
30
  /**
24
31
  * Simplified UI-focused streaming events using GraphQL types
25
32
  */
@@ -30,9 +37,7 @@ export type AgentStreamEvent = {
30
37
  model?: string;
31
38
  } | ContextWindowEvent | {
32
39
  type: "message_update";
33
- message: Partial<ConversationMessage> & {
34
- message: string;
35
- };
40
+ message: StreamingConversationMessage;
36
41
  isStreaming: boolean;
37
42
  metrics?: {
38
43
  ttft?: number;
@@ -55,7 +60,7 @@ export type AgentStreamEvent = {
55
60
  isComplete: boolean;
56
61
  } | {
57
62
  type: "conversation_completed";
58
- message: ConversationMessage;
63
+ message: StreamingConversationMessage;
59
64
  metrics?: {
60
65
  ttft?: number;
61
66
  totalTime: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphlit-client",
3
- "version": "1.0.20250924001",
3
+ "version": "1.0.20250924002",
4
4
  "description": "Graphlit API Client for TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/client.js",