190proof 1.0.3 → 1.0.5
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.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +20 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -67,10 +67,15 @@ interface OpenAIConfig {
|
|
|
67
67
|
interface AnthropicAIConfig {
|
|
68
68
|
service: "anthropic" | "bedrock";
|
|
69
69
|
}
|
|
70
|
+
interface FunctionDefinition {
|
|
71
|
+
name: string;
|
|
72
|
+
description: string;
|
|
73
|
+
parameters: Record<string, any>;
|
|
74
|
+
}
|
|
70
75
|
interface GenericPayload {
|
|
71
76
|
model: GPTModel | ClaudeModel | GroqModel;
|
|
72
77
|
messages: GenericMessage[];
|
|
73
|
-
functions?:
|
|
78
|
+
functions?: FunctionDefinition[];
|
|
74
79
|
function_call?: "none" | "auto" | {
|
|
75
80
|
name: string;
|
|
76
81
|
};
|
|
@@ -79,4 +84,4 @@ interface GenericPayload {
|
|
|
79
84
|
|
|
80
85
|
declare function callWithRetries(identifier: string, aiPayload: GenericPayload, aiConfig?: OpenAIConfig | AnthropicAIConfig, retries?: number, chunkTimeoutMs?: number): Promise<ParsedResponseMessage>;
|
|
81
86
|
|
|
82
|
-
export { ClaudeModel, GPTModel, GroqModel, type OpenAIConfig, callWithRetries };
|
|
87
|
+
export { ClaudeModel, type FunctionDefinition, GPTModel, GroqModel, type OpenAIConfig, callWithRetries };
|
package/dist/index.d.ts
CHANGED
|
@@ -67,10 +67,15 @@ interface OpenAIConfig {
|
|
|
67
67
|
interface AnthropicAIConfig {
|
|
68
68
|
service: "anthropic" | "bedrock";
|
|
69
69
|
}
|
|
70
|
+
interface FunctionDefinition {
|
|
71
|
+
name: string;
|
|
72
|
+
description: string;
|
|
73
|
+
parameters: Record<string, any>;
|
|
74
|
+
}
|
|
70
75
|
interface GenericPayload {
|
|
71
76
|
model: GPTModel | ClaudeModel | GroqModel;
|
|
72
77
|
messages: GenericMessage[];
|
|
73
|
-
functions?:
|
|
78
|
+
functions?: FunctionDefinition[];
|
|
74
79
|
function_call?: "none" | "auto" | {
|
|
75
80
|
name: string;
|
|
76
81
|
};
|
|
@@ -79,4 +84,4 @@ interface GenericPayload {
|
|
|
79
84
|
|
|
80
85
|
declare function callWithRetries(identifier: string, aiPayload: GenericPayload, aiConfig?: OpenAIConfig | AnthropicAIConfig, retries?: number, chunkTimeoutMs?: number): Promise<ParsedResponseMessage>;
|
|
81
86
|
|
|
82
|
-
export { ClaudeModel, GPTModel, GroqModel, type OpenAIConfig, callWithRetries };
|
|
87
|
+
export { ClaudeModel, type FunctionDefinition, GPTModel, GroqModel, type OpenAIConfig, callWithRetries };
|
package/dist/index.js
CHANGED
|
@@ -31432,11 +31432,15 @@ function parseStreamedResponse(identifier, paragraph, functionCallName, function
|
|
|
31432
31432
|
"Stream error: received function call with unknown name: " + functionCallName
|
|
31433
31433
|
);
|
|
31434
31434
|
}
|
|
31435
|
-
|
|
31436
|
-
|
|
31437
|
-
|
|
31438
|
-
|
|
31439
|
-
|
|
31435
|
+
try {
|
|
31436
|
+
functionCall = {
|
|
31437
|
+
name: functionCallName,
|
|
31438
|
+
arguments: JSON.parse(functionCallArgs)
|
|
31439
|
+
};
|
|
31440
|
+
} catch (error) {
|
|
31441
|
+
console.error("Error parsing functionCallArgs:", functionCallArgs);
|
|
31442
|
+
throw error;
|
|
31443
|
+
}
|
|
31440
31444
|
}
|
|
31441
31445
|
if (!paragraph && !functionCall) {
|
|
31442
31446
|
console.error(
|
|
@@ -31533,6 +31537,7 @@ async function callOpenAIStream(identifier, openAiPayload, openAiConfig, chunkTi
|
|
|
31533
31537
|
baseUrl: defaultOpenAIBaseUrl
|
|
31534
31538
|
};
|
|
31535
31539
|
}
|
|
31540
|
+
console.log("payload", openAiPayload);
|
|
31536
31541
|
let response;
|
|
31537
31542
|
const controller = new AbortController();
|
|
31538
31543
|
if (openAiConfig.service === "azure") {
|
|
@@ -31908,7 +31913,8 @@ function prepareOpenAIPayload(payload) {
|
|
|
31908
31913
|
content: normalizeMessageContent(message.content)
|
|
31909
31914
|
// TODO: Handle files
|
|
31910
31915
|
})),
|
|
31911
|
-
functions: payload.functions
|
|
31916
|
+
functions: payload.functions,
|
|
31917
|
+
function_call: payload.function_call
|
|
31912
31918
|
};
|
|
31913
31919
|
}
|
|
31914
31920
|
function isGroqPayload(payload) {
|
|
@@ -31922,10 +31928,15 @@ function prepareGroqPayload(payload) {
|
|
|
31922
31928
|
role: message.role,
|
|
31923
31929
|
content: normalizeMessageContent(message.content)
|
|
31924
31930
|
})),
|
|
31925
|
-
|
|
31931
|
+
tools: (_a3 = payload.functions) == null ? void 0 : _a3.map((fn) => ({
|
|
31926
31932
|
type: "function",
|
|
31927
31933
|
function: fn
|
|
31928
|
-
}))
|
|
31934
|
+
})),
|
|
31935
|
+
tool_choice: payload.function_call ? typeof payload.function_call === "string" ? payload.function_call : {
|
|
31936
|
+
type: "function",
|
|
31937
|
+
function: payload.function_call
|
|
31938
|
+
} : void 0,
|
|
31939
|
+
temperature: payload.temperature
|
|
31929
31940
|
};
|
|
31930
31941
|
}
|
|
31931
31942
|
function normalizeMessageContent(content) {
|
|
@@ -31934,11 +31945,7 @@ function normalizeMessageContent(content) {
|
|
|
31934
31945
|
async function callGroq(identifier, payload) {
|
|
31935
31946
|
const response = await axios_default.post(
|
|
31936
31947
|
"https://api.groq.com/openai/v1/chat/completions",
|
|
31937
|
-
|
|
31938
|
-
model: payload.model,
|
|
31939
|
-
messages: payload.messages,
|
|
31940
|
-
tools: payload.functions
|
|
31941
|
-
},
|
|
31948
|
+
payload,
|
|
31942
31949
|
{
|
|
31943
31950
|
headers: {
|
|
31944
31951
|
"content-type": "application/json",
|