Skip to content

fix: Make sure params get passed through for compiled prompt#1558

Open
Abhijeet Prasad (AbhiPrasad) wants to merge 1 commit intomainfrom
abhi-fix-prompt-build-types
Open

fix: Make sure params get passed through for compiled prompt#1558
Abhijeet Prasad (AbhiPrasad) wants to merge 1 commit intomainfrom
abhi-fix-prompt-build-types

Conversation

@AbhiPrasad
Copy link
Member

resolves https://linear.app/braintrustdata/issue/BT-4378/typescript-sdk-promptbuild-fields-response-format-tool-choice

This fixes a bug with typings where params were not being passed through correctly.

import OpenAI from "openai";
import { Prompt } from "braintrust";

declare const prompt: Prompt;

const params = prompt.build(
  { topic: "TypeScript" },
  { flavor: "chat" },
);

// Before the fix, these would fail
// Property 'temperature' does not exist on type 'CompiledPrompt<"chat">'
const temperature = params.temperature;
const responseFormat = params.response_format;
const toolChoice = params.tool_choice;

I didn't add a test for this because it's just a types change, but lmk and I can add a set of type check tests.

@AbhiPrasad
Copy link
Member Author

Hmm, this is a breaking change, but it's one for correctness. We can just leave this PR until the next major version though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant