Skip to content

Commit

Permalink
api_refs[minor]: Hide all properties and non whitelisted methods of c…
Browse files Browse the repository at this point in the history
…hat models
  • Loading branch information
bracesproul committed Aug 8, 2024
1 parent 7696d4f commit 67b0b85
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions docs/api_refs/typedoc_plugins/hide_underscore_lc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ const {
const fs = require("fs");
const path = require("path");

const WHITELISTED_CHAT_MODEL_INHERITED_METHODS = [
"invoke",
"stream",
"batch",
"streamLog",
"streamEvents",
"bind",
"bindTools",
"asTool",
"pipe",
"withConfig",
"withRetry",
"assign",
"getNumTokens",
"getGraph",
"pick",
"withFallbacks",
"withStructuredOutput",
"withListeners",
"transform",
];

const PATH_TO_LANGCHAIN_PKG_JSON = "../../langchain/package.json";
const BASE_OUTPUT_DIR = "./public";
const SCRIPT_HTML = `<script>
Expand Down Expand Up @@ -113,6 +135,40 @@ function load(application) {
*/
function resolveReflection(_context, reflection) {
const reflectionKind = reflection.kind;

if (
reflectionKind === ReflectionKind.Method &&
reflection?.parent &&
reflection.parent.kind === ReflectionKind.Class &&
reflection.parent.name.includes("Chat")
) {
if (
!WHITELISTED_CHAT_MODEL_INHERITED_METHODS.find(
(n) => n === reflection.name
)
) {
reflectionsToHide.push(reflection);
}
}

if (
reflectionKind === ReflectionKind.Property &&
reflection?.parent &&
reflection.parent.kind === ReflectionKind.Class &&
reflection.parent.name.includes("Chat")
) {
// Hide all properties of chat models
reflectionsToHide.push(reflection);
}

if (
reflectionKind === ReflectionKind.Accessor &&
reflection.name === "callKeys"
) {
// Hide all `callKeys` accessors
reflectionsToHide.push(reflection);
}

if (reflectionKindsToHide.includes(reflectionKind)) {
if (
reflection.name.startsWith("_") ||
Expand Down

0 comments on commit 67b0b85

Please sign in to comment.