@axiom-lattice/client-sdk 2.1.2 → 2.1.4

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/index.mjs CHANGED
@@ -1862,7 +1862,7 @@ var AbstractClient = class {
1862
1862
  send: async (options) => {
1863
1863
  try {
1864
1864
  const message = options.messages[options.messages.length - 1];
1865
- const { command, threadId, files, ...rest } = options;
1865
+ const { command, threadId, files, assistantId, ...rest } = options;
1866
1866
  const result = await this.run({
1867
1867
  threadId,
1868
1868
  message: typeof message.content === "string" ? message.content : JSON.stringify(message.content),
@@ -1889,6 +1889,7 @@ var AbstractClient = class {
1889
1889
  command,
1890
1890
  threadId,
1891
1891
  files,
1892
+ assistantId,
1892
1893
  background,
1893
1894
  enableReturnStateWhenSteamCompleted,
1894
1895
  ...rest
@@ -1896,7 +1897,8 @@ var AbstractClient = class {
1896
1897
  const message = options.messages[options.messages.length - 1];
1897
1898
  return this.streamRequest(
1898
1899
  {
1899
- threadId: options.threadId,
1900
+ threadId,
1901
+ assistantId,
1900
1902
  message: typeof message.content === "string" ? message.content : JSON.stringify(message.content),
1901
1903
  streaming: true,
1902
1904
  command,
@@ -1941,6 +1943,33 @@ var AbstractClient = class {
1941
1943
  };
1942
1944
  this.assistantId = config.assistantId;
1943
1945
  }
1946
+ /**
1947
+ * Set assistant ID for the client
1948
+ * @param assistantId - Assistant identifier
1949
+ */
1950
+ setAssistantId(assistantId) {
1951
+ this.assistantId = assistantId;
1952
+ }
1953
+ /**
1954
+ * Creates a clone of the current client instance
1955
+ * @param overrides - Optional configuration overrides for the cloned client
1956
+ * @returns A new client instance with the same configuration and state
1957
+ */
1958
+ clone(overrides) {
1959
+ const clonedConfig = {
1960
+ ...this.config,
1961
+ assistantId: this.assistantId,
1962
+ ...overrides
1963
+ };
1964
+ const clonedClient = this.createInstance(clonedConfig);
1965
+ if (this.tenantId) {
1966
+ clonedClient.setTenantId(this.tenantId);
1967
+ }
1968
+ this.registeredTools.forEach((tool, name) => {
1969
+ clonedClient.registeredTools.set(name, tool);
1970
+ });
1971
+ return clonedClient;
1972
+ }
1944
1973
  /**
1945
1974
  * Abstract method for streaming API requests
1946
1975
  * To be implemented by concrete client classes
@@ -2090,7 +2119,15 @@ var AbstractClient = class {
2090
2119
  */
2091
2120
  async run(options) {
2092
2121
  try {
2093
- const { command, threadId, message, files, background, ...rest } = options;
2122
+ const {
2123
+ command,
2124
+ threadId,
2125
+ assistantId,
2126
+ message,
2127
+ files,
2128
+ background,
2129
+ ...rest
2130
+ } = options;
2094
2131
  if (options.streaming) {
2095
2132
  throw new Error(
2096
2133
  "Streaming without callbacks is not supported. Use chat.stream with callbacks instead."
@@ -2099,7 +2136,7 @@ var AbstractClient = class {
2099
2136
  return await this.makeRequest("/api/runs", {
2100
2137
  method: "POST",
2101
2138
  body: {
2102
- assistant_id: this.assistantId,
2139
+ assistant_id: assistantId || this.assistantId,
2103
2140
  thread_id: threadId,
2104
2141
  message,
2105
2142
  files,
@@ -2193,6 +2230,14 @@ var Client = class extends AbstractClient {
2193
2230
  this.tenantId = tenantId;
2194
2231
  this.headers["x-tenant-id"] = tenantId;
2195
2232
  }
2233
+ /**
2234
+ * Creates a new instance of the client with the given configuration
2235
+ * @param config - Configuration options for the client
2236
+ * @returns A new Client instance
2237
+ */
2238
+ createInstance(config) {
2239
+ return new Client(config);
2240
+ }
2196
2241
  /**
2197
2242
  * Implementation of the abstract makeRequest method for web clients
2198
2243
  * @param url - The URL to make the request to
@@ -2437,6 +2482,14 @@ var WeChatClient = class extends AbstractClient {
2437
2482
  setTenantId(tenantId) {
2438
2483
  this.tenantId = tenantId;
2439
2484
  }
2485
+ /**
2486
+ * Creates a new instance of the client with the given configuration
2487
+ * @param config - Configuration options for the client
2488
+ * @returns A new WeChatClient instance
2489
+ */
2490
+ createInstance(config) {
2491
+ return new WeChatClient(config);
2492
+ }
2440
2493
  /**
2441
2494
  * Implementation of the abstract makeRequest method for WeChat clients
2442
2495
  * @param url - The URL to make the request to