@xsai/shared-chat 0.2.0-beta.1 → 0.2.0-beta.2

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.
Files changed (2) hide show
  1. package/dist/index.js +8 -14
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- // src/utils/chat.ts
2
- import { clean, requestBody, requestHeaders, requestURL, responseCatch } from "@xsai/shared";
3
- var chat = async (options) => (options.fetch ?? globalThis.fetch)(requestURL("chat/completions", options.baseURL), {
1
+ import { requestURL, requestHeaders, requestBody, clean, responseCatch } from '@xsai/shared';
2
+
3
+ const chat = async (options) => (options.fetch ?? globalThis.fetch)(requestURL("chat/completions", options.baseURL), {
4
4
  body: requestBody({
5
5
  ...options,
6
6
  tools: options.tools?.map((tool) => ({
@@ -19,8 +19,7 @@ var chat = async (options) => (options.fetch ?? globalThis.fetch)(requestURL("ch
19
19
  signal: options.abortSignal
20
20
  }).then(responseCatch);
21
21
 
22
- // src/utils/determine-step-type.ts
23
- var determineStepType = ({ finishReason, maxSteps, stepsLength, toolCallsLength }) => {
22
+ const determineStepType = ({ finishReason, maxSteps, stepsLength, toolCallsLength }) => {
24
23
  if (stepsLength === 0) {
25
24
  return "initial";
26
25
  } else if (stepsLength < maxSteps) {
@@ -32,8 +31,7 @@ var determineStepType = ({ finishReason, maxSteps, stepsLength, toolCallsLength
32
31
  return "done";
33
32
  };
34
33
 
35
- // src/utils/internal/wrap-tool-result.ts
36
- var wrapToolResult = (result) => {
34
+ const wrapToolResult = (result) => {
37
35
  if (typeof result === "string")
38
36
  return result;
39
37
  if (Array.isArray(result)) {
@@ -44,8 +42,7 @@ var wrapToolResult = (result) => {
44
42
  return JSON.stringify(result);
45
43
  };
46
44
 
47
- // src/utils/execute-tool.ts
48
- var executeTool = async ({ abortSignal, messages, toolCall, tools }) => {
45
+ const executeTool = async ({ abortSignal, messages, toolCall, tools }) => {
49
46
  const tool = tools?.find((tool2) => tool2.function.name === toolCall.function.name);
50
47
  if (!tool) {
51
48
  const availableTools = tools?.map((tool2) => tool2.function.name);
@@ -60,8 +57,5 @@ var executeTool = async ({ abortSignal, messages, toolCall, tools }) => {
60
57
  }));
61
58
  return { parsedArgs, result, toolName: toolCall.function.name };
62
59
  };
63
- export {
64
- chat,
65
- determineStepType,
66
- executeTool
67
- };
60
+
61
+ export { chat, determineStepType, executeTool };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xsai/shared-chat",
3
3
  "type": "module",
4
- "version": "0.2.0-beta.1",
4
+ "version": "0.2.0-beta.2",
5
5
  "description": "extra-small AI SDK for Browser, Node.js, Deno, Bun or Edge Runtime.",
6
6
  "author": "Moeru AI",
7
7
  "license": "MIT",
@@ -32,7 +32,7 @@
32
32
  "@xsai/shared": ""
33
33
  },
34
34
  "scripts": {
35
- "build": "tsup"
35
+ "build": "pkgroll"
36
36
  },
37
37
  "main": "./dist/index.js",
38
38
  "types": "./dist/index.d.ts"