Skip to content

Commit

Permalink
moved isOpenAITool to existing entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jun 13, 2024
1 parent 82cd2bb commit 592dba9
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 35 deletions.
4 changes: 0 additions & 4 deletions langchain-core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@ utils/types.cjs
utils/types.js
utils/types.d.ts
utils/types.d.cts
utils/is_openai_tool.cjs
utils/is_openai_tool.js
utils/is_openai_tool.d.ts
utils/is_openai_tool.d.cts
vectorstores.cjs
vectorstores.js
vectorstores.d.ts
Expand Down
1 change: 0 additions & 1 deletion langchain-core/langchain.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export const config = {
"utils/testing": "utils/testing/index",
"utils/tiktoken": "utils/tiktoken",
"utils/types": "utils/types/index",
"utils/is_openai_tool": "utils/is_openai_tool",
vectorstores: "vectorstores",
},
tsConfigPath: resolve("./tsconfig.json"),
Expand Down
13 changes: 0 additions & 13 deletions langchain-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -581,15 +581,6 @@
"import": "./utils/types.js",
"require": "./utils/types.cjs"
},
"./utils/is_openai_tool": {
"types": {
"import": "./utils/is_openai_tool.d.ts",
"require": "./utils/is_openai_tool.d.cts",
"default": "./utils/is_openai_tool.d.ts"
},
"import": "./utils/is_openai_tool.js",
"require": "./utils/is_openai_tool.cjs"
},
"./vectorstores": {
"types": {
"import": "./vectorstores.d.ts",
Expand Down Expand Up @@ -819,10 +810,6 @@
"utils/types.js",
"utils/types.d.ts",
"utils/types.d.cts",
"utils/is_openai_tool.cjs",
"utils/is_openai_tool.js",
"utils/is_openai_tool.d.ts",
"utils/is_openai_tool.d.cts",
"vectorstores.cjs",
"vectorstores.js",
"vectorstores.d.ts",
Expand Down
21 changes: 21 additions & 0 deletions langchain-core/src/language_models/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ export const getModelContextSize = (modelName: string): number => {
}
};

/**
* Whether or not the input matches the OpenAI tool definition.
* @param {unknown} tool The input to check.
* @returns {boolean} Whether the input is an OpenAI tool definition.
*/
export function isOpenAITool(tool: unknown): tool is ToolDefinition {
if (typeof tool !== "object" || !tool) return false;
if (
"type" in tool &&
tool.type === "function" &&
"function" in tool &&
typeof tool.function === "object" &&
tool.function &&
"name" in tool.function &&
"parameters" in tool.function
) {
return true;
}
return false;
}

interface CalculateMaxTokenProps {
prompt: string;
modelName: TiktokenModel;
Expand Down
17 changes: 0 additions & 17 deletions langchain-core/src/utils/is_openai_tool.ts

This file was deleted.

1 change: 1 addition & 0 deletions langchain-core/utils/is_openai_tool.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../dist/utils/is_openai_tool.cjs');
1 change: 1 addition & 0 deletions langchain-core/utils/is_openai_tool.d.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../dist/utils/is_openai_tool.js'
1 change: 1 addition & 0 deletions langchain-core/utils/is_openai_tool.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../dist/utils/is_openai_tool.js'
1 change: 1 addition & 0 deletions langchain-core/utils/is_openai_tool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../dist/utils/is_openai_tool.js'

0 comments on commit 592dba9

Please sign in to comment.