Skip to content

Commit

Permalink
Update AnthropicChatModel, relax OpenAIChatModel (#541)
Browse files Browse the repository at this point in the history
- Update Anthropic SDK, switch to messages API, add support for beta
tool use API
- Relax OpenAI function calling restrictions (all models support
function calling now)
- Add `maxInputTokens` prop to `OpenAIChatModel` to support explicitly
limiting prompt size
- Add new GPT-4 models to enum
  • Loading branch information
petersalas committed Apr 9, 2024
1 parent c595ade commit feecd64
Show file tree
Hide file tree
Showing 11 changed files with 627 additions and 216 deletions.
4 changes: 2 additions & 2 deletions packages/ai-jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"repository": "fixie-ai/ai-jsx",
"bugs": "https://github.com/fixie-ai/ai-jsx/issues",
"homepage": "https://ai-jsx.com",
"version": "0.29.0",
"version": "0.30.0",
"volta": {
"extends": "../../package.json"
},
Expand Down Expand Up @@ -375,7 +375,7 @@
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"dependencies": {
"@anthropic-ai/sdk": "^0.5.10",
"@anthropic-ai/sdk": "^0.20.1",
"@mdx-js/mdx": "^2.3.0",
"@nick.heiner/wandb-fork": "^0.5.2-5",
"@opentelemetry/api": "^1.4.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/ai-jsx/src/batteries/constrained-output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export async function* JsonChatCompletionFunctionCall(
functionDefinitions={{
print: {
description: 'Prints the response in a human readable format.',
parameters: schema,
parameters: schema as any,
},
}}
forcedFunction="print"
Expand Down
12 changes: 12 additions & 0 deletions packages/ai-jsx/src/core/completion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface ModelProps {
maxTokens?: number;
/** The number of tokens to reserve for the generation. */
reservedTokens?: number;
/** Maximum number of input tokens to allow. */
maxInputTokens?: number;
/** A list of stop tokens. */
stop?: string[];

Expand All @@ -37,6 +39,16 @@ export interface ModelProps {
*
* @see https://platform.openai.com/docs/api-reference/chat/create#chat/create-top_p */
topP?: number;

/**
* Any function definitions (tools) that the model can choose to invoke.
*/
functionDefinitions?: Record<string, FunctionDefinition>;

/**
* If specified, the model will be forced to use this function.
*/
forcedFunction?: string;
}

/**
Expand Down

0 comments on commit feecd64

Please sign in to comment.