Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 29 additions & 0 deletions payloads/cases/advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,35 @@ export const advancedCases: TestCaseCollection = {
],
tool_choice: "auto",
},
"baseten-responses": {
model: BASETEN_MODEL,
input: [
{
role: "user",
content:
"Before doing anything else, reply with one short sentence telling me you are about to look up the weather. Then call the get_weather tool for San Francisco, CA.",
},
],
tools: [
{
type: "function",
name: "get_weather",
description: "Get the current weather for a location",
parameters: {
type: "object",
properties: {
location: {
type: "string",
description: "The city and state, e.g. San Francisco, CA",
},
},
required: ["location"],
},
strict: false,
},
],
tool_choice: "auto",
},
},

parallelToolCallsRequest: {
Expand Down
3 changes: 3 additions & 0 deletions payloads/cases/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export interface TestCase {
"vertex-anthropic"?: AnthropicMessageCreateParams | null;
// Baseten serves OSS models via an OpenAI-compatible chat-completions API.
baseten?: ChatCompletionCreateParams | null;
// Baseten's OpenAI-compatible Responses API.
"baseten-responses"?: OpenAI.Responses.ResponseCreateParams | null;
// Optional expectations for proxy compatibility tests
expect?: TestExpectation;
}
Expand All @@ -104,4 +106,5 @@ export const PROVIDER_TYPES = [
"bedrock",
"bedrock-anthropic",
"vertex-anthropic",
"baseten-responses",
] as const;
2 changes: 2 additions & 0 deletions payloads/scripts/capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { bedrockExecutor } from "./providers/bedrock";
import { bedrockAnthropicExecutor } from "./providers/bedrock-anthropic";
import { vertexAnthropicExecutor } from "./providers/vertex-anthropic";
import { basetenExecutor } from "./providers/baseten";
import { basetenResponsesExecutor } from "./providers/baseten-responses";
import { type ProviderExecutor } from "./types";

// Update provider names to be more descriptive
Expand All @@ -27,6 +28,7 @@ const allProviders = [
bedrockAnthropicExecutor,
vertexAnthropicExecutor,
basetenExecutor,
basetenResponsesExecutor,
] as const;

interface CaptureOptions {
Expand Down
70 changes: 70 additions & 0 deletions payloads/scripts/providers/baseten-responses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import OpenAI from "openai";
import { CaptureResult, ExecuteOptions, ProviderExecutor } from "../types";
import {
allTestCases,
getCaseNames,
getCaseForProvider,
hasExpectation,
} from "../../cases";
import { BASETEN_BASE_URL, BASETEN_MODEL } from "../../cases/models";
import {
executeOpenAIResponses,
openaiResponsesExecutor,
} from "./openai-responses";

type BasetenResponsesRequest = OpenAI.Responses.ResponseCreateParams;
type BasetenResponsesResponse = OpenAI.Responses.Response;

export const basetenResponsesCases: Record<string, BasetenResponsesRequest> =
{};

getCaseNames(allTestCases).forEach((caseName) => {
if (hasExpectation(allTestCases, caseName)) {
return;
}

const explicitCase = getCaseForProvider(
allTestCases,
caseName,
"baseten-responses"
);
if (explicitCase) {
basetenResponsesCases[caseName] = explicitCase;
return;
}

const responsesCase = getCaseForProvider(allTestCases, caseName, "responses");
if (responsesCase) {
basetenResponsesCases[caseName] = {
...responsesCase,
model: BASETEN_MODEL,
};
}
});

const BASETEN_HOST = BASETEN_BASE_URL.replace(/\/v1\/?$/, "");

export function executeBasetenResponses(
caseName: string,
payload: BasetenResponsesRequest,
options?: ExecuteOptions
): Promise<
CaptureResult<BasetenResponsesRequest, BasetenResponsesResponse, unknown>
> {
return executeOpenAIResponses(caseName, payload, {
...options,
baseURL: BASETEN_HOST,
apiKey: process.env.BASETEN_API_KEY,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require a Baseten key before calling Baseten

When BASETEN_API_KEY is unset but OPENAI_API_KEY is set, this passes undefined into executeOpenAIResponses; that helper defaults apiKey to process.env.OPENAI_API_KEY while the base URL is still BASETEN_HOST, so ordinary OpenAI-only capture environments can send an OpenAI key to Baseten and create/overwrite auth-error snapshots. Add an explicit BASETEN_API_KEY check here, like the transform capture path does, instead of falling through to the OpenAI key fallback.

Useful? React with 👍 / 👎.

});
}

export const basetenResponsesExecutor: ProviderExecutor<
BasetenResponsesRequest,
BasetenResponsesResponse,
unknown
> = {
name: "baseten-responses",
cases: basetenResponsesCases,
execute: executeBasetenResponses,
ignoredFields: openaiResponsesExecutor.ignoredFields,
};
15 changes: 14 additions & 1 deletion payloads/scripts/providers/baseten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getCaseForProvider,
hasExpectation,
} from "../../cases";
import { BASETEN_BASE_URL } from "../../cases/models";
import { BASETEN_BASE_URL, BASETEN_MODEL } from "../../cases/models";
import { executeOpenAI, openaiExecutor } from "./openai";

// Baseten serves OSS models behind an OpenAI-compatible chat-completions API, so the
Expand All @@ -24,6 +24,19 @@ getCaseNames(allTestCases).forEach((caseName) => {
const caseData = getCaseForProvider(allTestCases, caseName, "baseten");
if (caseData) {
basetenCases[caseName] = caseData;
return;
}

const chatCompletionsCase = getCaseForProvider(
allTestCases,
caseName,
"chat-completions"
);
if (chatCompletionsCase) {
basetenCases[caseName] = {
...chatCompletionsCase,
model: BASETEN_MODEL,
};
}
});

Expand Down
10 changes: 7 additions & 3 deletions payloads/scripts/transforms/capture-transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,13 @@ export async function captureTransforms(
targetModel
) as Record<string, unknown>;

const streamResponse = await callProvider(captureProvider, streamRequest, {
stream: true,
});
const streamResponse = await callProvider(
captureProvider,
streamRequest,
{
stream: true,
}
);
const chunks = await collectStreamChunks(streamResponse);

writeFileSync(streamingPath, JSON.stringify(chunks, null, 2));
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading