@jambonz/llm 0.2.2 → 0.2.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.js CHANGED
@@ -73,14 +73,15 @@ async function* streamFromOpenAI(client, req, options) {
73
73
  model: req.model,
74
74
  messages,
75
75
  stream: true,
76
- stream_options: { include_usage: true }
76
+ ...options.includeStreamOptions !== false ? { stream_options: { include_usage: true } } : {}
77
77
  };
78
78
  if (tools) {
79
79
  body.tools = tools;
80
80
  body.tool_choice = "auto";
81
81
  }
82
82
  if (req.temperature !== void 0) body.temperature = req.temperature;
83
- if (req.maxTokens !== void 0) body.max_tokens = req.maxTokens;
83
+ const effectiveMaxTokens = req.maxTokens ?? options.defaultMaxTokens;
84
+ if (effectiveMaxTokens !== void 0) body.max_tokens = effectiveMaxTokens;
84
85
  let stream;
85
86
  try {
86
87
  stream = await client.chat.completions.create(body, { signal: req.signal });
@@ -1565,7 +1566,7 @@ var VertexOpenAIAdapter = class {
1565
1566
  if (!auth.location) {
1566
1567
  throw new Error("VertexOpenAIAdapter: location is required");
1567
1568
  }
1568
- const baseURL = `https://${auth.location}-aiplatform.googleapis.com/v1/projects/${auth.projectId}/locations/${auth.location}/endpoints/openapi`;
1569
+ const baseURL = `https://${auth.location}-aiplatform.googleapis.com/v1beta1/projects/${auth.projectId}/locations/${auth.location}/endpoints/openapi`;
1569
1570
  const googleAuth = new GoogleAuth({
1570
1571
  credentials: auth.credentials,
1571
1572
  scopes: ["https://www.googleapis.com/auth/cloud-platform"]
@@ -1587,7 +1588,8 @@ var VertexOpenAIAdapter = class {
1587
1588
  }
1588
1589
  stream(req) {
1589
1590
  return streamFromOpenAI(this.ensureClient(), req, {
1590
- knownModels: vertexOpenAIManifest.knownModels
1591
+ knownModels: vertexOpenAIManifest.knownModels,
1592
+ defaultMaxTokens: 4096
1591
1593
  });
1592
1594
  }
1593
1595
  appendAssistantToolCall(history, toolCalls) {