@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.cjs CHANGED
@@ -117,14 +117,15 @@ async function* streamFromOpenAI(client, req, options) {
117
117
  model: req.model,
118
118
  messages,
119
119
  stream: true,
120
- stream_options: { include_usage: true }
120
+ ...options.includeStreamOptions !== false ? { stream_options: { include_usage: true } } : {}
121
121
  };
122
122
  if (tools) {
123
123
  body.tools = tools;
124
124
  body.tool_choice = "auto";
125
125
  }
126
126
  if (req.temperature !== void 0) body.temperature = req.temperature;
127
- if (req.maxTokens !== void 0) body.max_tokens = req.maxTokens;
127
+ const effectiveMaxTokens = req.maxTokens ?? options.defaultMaxTokens;
128
+ if (effectiveMaxTokens !== void 0) body.max_tokens = effectiveMaxTokens;
128
129
  let stream;
129
130
  try {
130
131
  stream = await client.chat.completions.create(body, { signal: req.signal });
@@ -1609,7 +1610,7 @@ var VertexOpenAIAdapter = class {
1609
1610
  if (!auth.location) {
1610
1611
  throw new Error("VertexOpenAIAdapter: location is required");
1611
1612
  }
1612
- const baseURL = `https://${auth.location}-aiplatform.googleapis.com/v1/projects/${auth.projectId}/locations/${auth.location}/endpoints/openapi`;
1613
+ const baseURL = `https://${auth.location}-aiplatform.googleapis.com/v1beta1/projects/${auth.projectId}/locations/${auth.location}/endpoints/openapi`;
1613
1614
  const googleAuth = new import_google_auth_library.GoogleAuth({
1614
1615
  credentials: auth.credentials,
1615
1616
  scopes: ["https://www.googleapis.com/auth/cloud-platform"]
@@ -1631,7 +1632,8 @@ var VertexOpenAIAdapter = class {
1631
1632
  }
1632
1633
  stream(req) {
1633
1634
  return streamFromOpenAI(this.ensureClient(), req, {
1634
- knownModels: vertexOpenAIManifest.knownModels
1635
+ knownModels: vertexOpenAIManifest.knownModels,
1636
+ defaultMaxTokens: 4096
1635
1637
  });
1636
1638
  }
1637
1639
  appendAssistantToolCall(history, toolCalls) {