Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anthropic[patch]: Allow 8K maxtokens header for Anthropic while using tools #6480

Merged
merged 7 commits into from
Aug 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Removed unnecessary header for tools to allow for maxtokens header
renebrandel authored Aug 9, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit e6c820d3b908f9b908379f6efe87ab7b30abd05c
12 changes: 1 addition & 11 deletions libs/langchain-anthropic/src/chat_models.ts
Original file line number Diff line number Diff line change
@@ -841,23 +841,13 @@ export class ChatAnthropicMessages<
Kwargs,
requestOptions: AnthropicRequestOptions
) {
const options =
params.tools !== undefined
? {
...requestOptions,
headers: {
...requestOptions.headers,
"anthropic-beta": "tools-2024-04-04",
},
}
: requestOptions;
const response = await this.completionWithRetry(
{
...params,
stream: false,
..._formatMessagesForAnthropic(messages),
},
options
options: requestOptions
);

const { content, ...additionalKwargs } = response;

Unchanged files with check annotations Beta

/**
* Install a internal template to a given `root` directory.
*/
export async function installTemplate({ appName, root }: any) {

Check warning on line 10 in libs/create-langchain-integration/helpers/templates.ts

GitHub Actions / Check linting

Unexpected any. Specify a different type
/**
* Copy the template files to the target directory.
*/
* Update the package.json scripts.
*/
const packageJsonFile = path.join(root, "package.json");
const packageJson: any = JSON.parse(

Check warning on line 28 in libs/create-langchain-integration/helpers/templates.ts

GitHub Actions / Check linting

Unexpected any. Specify a different type
await fs.readFile(packageJsonFile, "utf8")
);
} from "@langchain/core/language_models/chat_models";
import { BaseMessageChunk } from "@langchain/core/messages";
export type RecordStringAny = Record<string, any>;

Check warning on line 7 in libs/langchain-standard-tests/src/base.ts

GitHub Actions / Check linting

Unexpected any. Specify a different type
export type BaseChatModelConstructor<
CallOptions extends BaseChatModelCallOptions = BaseChatModelCallOptions,
return;
}
const chatModel = new this.Cls(this.constructorArgs);
expect((chatModel as any).withStructuredOutput?.(person)).toBeDefined();

Check warning on line 108 in libs/langchain-standard-tests/src/unit_tests/chat_models.ts

GitHub Actions / Check linting

Unexpected any. Specify a different type
}
testStandardParams() {
const expectedParams = this.expectedLsParams();
const chatModel = new this.Cls(this.constructorArgs);
const lsParams = chatModel.getLsParams({} as any);

Check warning on line 115 in libs/langchain-standard-tests/src/unit_tests/chat_models.ts

GitHub Actions / Check linting

Unexpected any. Specify a different type
expect(lsParams).toBeDefined();
expect(Object.keys(lsParams).sort()).toEqual(
Object.keys(expectedParams).sort()
let allTestsPassed = true;
try {
this.testChatModelInit();
} catch (e: any) {

Check warning on line 132 in libs/langchain-standard-tests/src/unit_tests/chat_models.ts

GitHub Actions / Check linting

Unexpected any. Specify a different type
allTestsPassed = false;
console.error("testChatModelInit failed", e);
}
try {
this.testChatModelInitApiKey();
} catch (e: any) {

Check warning on line 139 in libs/langchain-standard-tests/src/unit_tests/chat_models.ts

GitHub Actions / Check linting

Unexpected any. Specify a different type
allTestsPassed = false;
console.error("testChatModelInitApiKey failed", e);
}
try {
this.testChatModelInitStreaming();
} catch (e: any) {

Check warning on line 146 in libs/langchain-standard-tests/src/unit_tests/chat_models.ts

GitHub Actions / Check linting

Unexpected any. Specify a different type
allTestsPassed = false;
console.error("testChatModelInitStreaming failed", e);
}
try {
this.testChatModelWithBindTools();
} catch (e: any) {

Check warning on line 153 in libs/langchain-standard-tests/src/unit_tests/chat_models.ts

GitHub Actions / Check linting

Unexpected any. Specify a different type
allTestsPassed = false;
console.error("testChatModelWithBindTools failed", e);
}
try {
this.testChatModelWithStructuredOutput();
} catch (e: any) {

Check warning on line 160 in libs/langchain-standard-tests/src/unit_tests/chat_models.ts

GitHub Actions / Check linting

Unexpected any. Specify a different type
allTestsPassed = false;
console.error("testChatModelWithStructuredOutput failed", e);
}