Skip to content

Commit

Permalink
anthropic[patch]: Pass custom headers through to request
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jul 30, 2024
1 parent a151317 commit dc966c6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libs/langchain-anthropic/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export interface ChatAnthropicCallOptions
* @default "auto"
*/
tool_choice?: AnthropicToolChoice;
/**
* Custom headers to pass to the Anthropic API
* when making a request.
*/
headers?: Record<string, string>;
}

function _toolsInParams(params: AnthropicMessageCreateParams): boolean {
Expand Down Expand Up @@ -426,6 +431,8 @@ export class ChatAnthropicMessages<
...params,
...formattedMessages,
stream: true,
}, {
headers: options.headers,
});

for await (const data of stream) {
Expand Down Expand Up @@ -543,6 +550,7 @@ export class ChatAnthropicMessages<
} else {
return this._generateNonStreaming(messages, params, {
signal: options.signal,
headers: options.headers,
});
}
}
Expand Down

0 comments on commit dc966c6

Please sign in to comment.