190proof 1.0.23 → 1.0.25

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 CHANGED
@@ -14,6 +14,9 @@ declare enum GPTModel {
14
14
  declare enum GroqModel {
15
15
  LLAMA_3_70B_8192 = "llama3-70b-8192"
16
16
  }
17
+ declare enum GeminiModel {
18
+ GEMINI_15_PRO = "gemini-1.5-pro-latest"
19
+ }
17
20
  interface GenericMessage {
18
21
  role: "user" | "assistant" | "system";
19
22
  content: string;
@@ -56,11 +59,11 @@ interface AnthropicAIConfig {
56
59
  }
57
60
  interface FunctionDefinition {
58
61
  name: string;
59
- description: string;
62
+ description?: string;
60
63
  parameters: Record<string, any>;
61
64
  }
62
65
  interface GenericPayload {
63
- model: GPTModel | ClaudeModel | GroqModel;
66
+ model: GPTModel | ClaudeModel | GroqModel | GeminiModel;
64
67
  messages: GenericMessage[];
65
68
  functions?: FunctionDefinition[];
66
69
  function_call?: "none" | "auto" | {
@@ -71,4 +74,4 @@ interface GenericPayload {
71
74
 
72
75
  declare function callWithRetries(identifier: string, aiPayload: GenericPayload, aiConfig?: OpenAIConfig | AnthropicAIConfig, retries?: number, chunkTimeoutMs?: number): Promise<ParsedResponseMessage>;
73
76
 
74
- export { ClaudeModel, type FunctionDefinition, GPTModel, type GenericMessage, type GenericPayload, GroqModel, type OpenAIConfig, callWithRetries };
77
+ export { ClaudeModel, type FunctionDefinition, GPTModel, GeminiModel, type GenericMessage, type GenericPayload, GroqModel, type OpenAIConfig, callWithRetries };
package/dist/index.d.ts CHANGED
@@ -14,6 +14,9 @@ declare enum GPTModel {
14
14
  declare enum GroqModel {
15
15
  LLAMA_3_70B_8192 = "llama3-70b-8192"
16
16
  }
17
+ declare enum GeminiModel {
18
+ GEMINI_15_PRO = "gemini-1.5-pro-latest"
19
+ }
17
20
  interface GenericMessage {
18
21
  role: "user" | "assistant" | "system";
19
22
  content: string;
@@ -56,11 +59,11 @@ interface AnthropicAIConfig {
56
59
  }
57
60
  interface FunctionDefinition {
58
61
  name: string;
59
- description: string;
62
+ description?: string;
60
63
  parameters: Record<string, any>;
61
64
  }
62
65
  interface GenericPayload {
63
- model: GPTModel | ClaudeModel | GroqModel;
66
+ model: GPTModel | ClaudeModel | GroqModel | GeminiModel;
64
67
  messages: GenericMessage[];
65
68
  functions?: FunctionDefinition[];
66
69
  function_call?: "none" | "auto" | {
@@ -71,4 +74,4 @@ interface GenericPayload {
71
74
 
72
75
  declare function callWithRetries(identifier: string, aiPayload: GenericPayload, aiConfig?: OpenAIConfig | AnthropicAIConfig, retries?: number, chunkTimeoutMs?: number): Promise<ParsedResponseMessage>;
73
76
 
74
- export { ClaudeModel, type FunctionDefinition, GPTModel, type GenericMessage, type GenericPayload, GroqModel, type OpenAIConfig, callWithRetries };
77
+ export { ClaudeModel, type FunctionDefinition, GPTModel, GeminiModel, type GenericMessage, type GenericPayload, GroqModel, type OpenAIConfig, callWithRetries };
package/dist/index.js CHANGED
@@ -27015,6 +27015,7 @@ var proof_exports = {};
27015
27015
  __export(proof_exports, {
27016
27016
  ClaudeModel: () => ClaudeModel,
27017
27017
  GPTModel: () => GPTModel,
27018
+ GeminiModel: () => GeminiModel,
27018
27019
  GroqModel: () => GroqModel,
27019
27020
  callWithRetries: () => callWithRetries
27020
27021
  });
@@ -27040,6 +27041,10 @@ var GroqModel = /* @__PURE__ */ ((GroqModel2) => {
27040
27041
  GroqModel2["LLAMA_3_70B_8192"] = "llama3-70b-8192";
27041
27042
  return GroqModel2;
27042
27043
  })(GroqModel || {});
27044
+ var GeminiModel = /* @__PURE__ */ ((GeminiModel2) => {
27045
+ GeminiModel2["GEMINI_15_PRO"] = "gemini-1.5-pro-latest";
27046
+ return GeminiModel2;
27047
+ })(GeminiModel || {});
27043
27048
 
27044
27049
  // ../node_modules/@aws-sdk/client-bedrock-runtime/dist-es/BedrockRuntimeClient.js
27045
27050
  init_dist_es3();
@@ -31430,6 +31435,7 @@ function isHeicImage(name, mime) {
31430
31435
  }
31431
31436
 
31432
31437
  // index.ts
31438
+ var { GoogleGenerativeAI } = require("@google/generative-ai");
31433
31439
  var sharp = require("sharp");
31434
31440
  var decode = require("heic-decode");
31435
31441
  function parseStreamedResponse(identifier, paragraph, functionCallName, functionCallArgs, allowedFunctionNames) {
@@ -31894,6 +31900,92 @@ Before answering you can reason about the instructions and answer using <thinkin
31894
31900
  }
31895
31901
  return jiggedMessages;
31896
31902
  }
31903
+ async function prepareGoogleAIPayload(payload) {
31904
+ var _a3;
31905
+ const preparedPayload = {
31906
+ model: payload.model,
31907
+ messages: [],
31908
+ tools: payload.functions ? {
31909
+ functionDeclarations: payload.functions.map((fn) => ({
31910
+ name: fn.name,
31911
+ parameters: {
31912
+ // Google puts their description in the parameters object rather than in a top-level field
31913
+ description: fn.description,
31914
+ ...fn.parameters
31915
+ }
31916
+ }))
31917
+ } : void 0
31918
+ };
31919
+ for (const message of payload.messages) {
31920
+ const googleAIContentParts = [];
31921
+ if (message.content) {
31922
+ googleAIContentParts.push({
31923
+ text: message.content
31924
+ });
31925
+ }
31926
+ for (const file of message.files || []) {
31927
+ if (!((_a3 = file.mimeType) == null ? void 0 : _a3.startsWith("image"))) {
31928
+ console.warn(
31929
+ "Google AI API does not support non-image file types. Skipping file."
31930
+ );
31931
+ continue;
31932
+ }
31933
+ if (file.url) {
31934
+ googleAIContentParts.push({
31935
+ inlineData: {
31936
+ mimeType: "image/png",
31937
+ data: await getNormalizedBase64PNG(file.url, file.mimeType)
31938
+ }
31939
+ });
31940
+ } else if (file.data) {
31941
+ if (!["image/png", "image/jpeg", "image/gif", "image/webp"].includes(
31942
+ file.mimeType
31943
+ )) {
31944
+ throw new Error(
31945
+ "Invalid image mimeType. Supported types are: image/png, image/jpeg, image/gif, image/webp"
31946
+ );
31947
+ }
31948
+ googleAIContentParts.push({
31949
+ inlineData: {
31950
+ mimeType: file.mimeType,
31951
+ data: file.data
31952
+ }
31953
+ });
31954
+ }
31955
+ }
31956
+ preparedPayload.messages.push({
31957
+ role: message.role === "user" ? "user" : "model",
31958
+ parts: googleAIContentParts
31959
+ });
31960
+ }
31961
+ return preparedPayload;
31962
+ }
31963
+ async function callGoogleAI(identifier, payload) {
31964
+ console.log(identifier, "Calling Google AI API");
31965
+ const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
31966
+ const model = genAI.getGenerativeModel({
31967
+ model: payload.model,
31968
+ tools: payload.tools
31969
+ });
31970
+ const history = payload.messages.slice(0, -1);
31971
+ const lastMessage = payload.messages.slice(-1)[0];
31972
+ const chat = model.startChat({
31973
+ history
31974
+ });
31975
+ const result = await chat.sendMessage(lastMessage.parts);
31976
+ const response = await result.response;
31977
+ const text = response.text();
31978
+ const functionCalls = response.functionCalls();
31979
+ const parsedFunctionCalls = functionCalls == null ? void 0 : functionCalls.map((fc) => ({
31980
+ name: fc.name,
31981
+ arguments: fc.args
31982
+ }));
31983
+ return {
31984
+ role: "assistant",
31985
+ content: text || null,
31986
+ function_call: (parsedFunctionCalls == null ? void 0 : parsedFunctionCalls[0]) || null
31987
+ };
31988
+ }
31897
31989
  async function callWithRetries(identifier, aiPayload, aiConfig, retries = 5, chunkTimeoutMs = 15e3) {
31898
31990
  if (isAnthropicPayload(aiPayload)) {
31899
31991
  console.log(identifier, "Delegating call to Anthropic API");
@@ -31918,6 +32010,12 @@ async function callWithRetries(identifier, aiPayload, aiConfig, retries = 5, chu
31918
32010
  identifier,
31919
32011
  await prepareGroqPayload(aiPayload)
31920
32012
  );
32013
+ } else if (isGoogleAIPayload(aiPayload)) {
32014
+ console.log(identifier, "Delegating call to Google AI API");
32015
+ return await callGoogleAI(
32016
+ identifier,
32017
+ await prepareGoogleAIPayload(aiPayload)
32018
+ );
31921
32019
  } else {
31922
32020
  throw new Error("Invalid AI payload: Unknown model type.");
31923
32021
  }
@@ -32019,10 +32117,6 @@ async function prepareOpenAIPayload(payload) {
32019
32117
  type: "image_url",
32020
32118
  image_url: {
32021
32119
  url: file.url
32022
- // url: `data:image/png;base64,${await getNormalizedBase64PNG(
32023
- // file.url,
32024
- // file.mimeType
32025
- // )}`,
32026
32120
  }
32027
32121
  });
32028
32122
  } else if (file.data) {
@@ -32066,6 +32160,9 @@ function prepareGroqPayload(payload) {
32066
32160
  function normalizeMessageContent(content) {
32067
32161
  return Array.isArray(content) ? content.map((c5) => c5.type === "text" ? c5.text : `[${c5.type}]`).join("\n") : content;
32068
32162
  }
32163
+ function isGoogleAIPayload(payload) {
32164
+ return Object.values(GeminiModel).includes(payload.model);
32165
+ }
32069
32166
  async function callGroq(identifier, payload) {
32070
32167
  const response = await axios_default.post(
32071
32168
  "https://api.groq.com/openai/v1/chat/completions",
@@ -32145,6 +32242,7 @@ async function getNormalizedBase64PNG(url2, mime) {
32145
32242
  0 && (module.exports = {
32146
32243
  ClaudeModel,
32147
32244
  GPTModel,
32245
+ GeminiModel,
32148
32246
  GroqModel,
32149
32247
  callWithRetries
32150
32248
  });