@@ -49,6 +49,82 @@ const VERSION_DROPDOWN_HTML = `<div class="version-select">
49
49
</select>
50
50
</div>` ;
51
51
52
+ /**
53
+ * Checks if the reflection is a property of a chat model class,
54
+ * and returns true (to hide the reflection) if it is.
55
+ *
56
+ * @param {DeclarationReflection } reflection
57
+ * @returns {boolean } Whether or not to hide the reflection
58
+ */
59
+ function hideChatModelProperties ( reflection ) {
60
+ if (
61
+ reflection . kind === ReflectionKind . Property &&
62
+ reflection ?. parent &&
63
+ reflection . parent . kind === ReflectionKind . Class &&
64
+ reflection . parent . name . includes ( "Chat" )
65
+ ) {
66
+ return true ;
67
+ }
68
+ return false ;
69
+ }
70
+
71
+ /**
72
+ * Checks if the reflection is a method on a chat model class,
73
+ * and returns true (to hide the reflection) if it is.
74
+ *
75
+ * @param {DeclarationReflection } reflection
76
+ * @returns {boolean } Whether or not to hide the reflection
77
+ */
78
+ function hideChatModelMethods ( reflection ) {
79
+ if (
80
+ reflection . kind === ReflectionKind . Method &&
81
+ reflection ?. parent &&
82
+ reflection . parent . kind === ReflectionKind . Class &&
83
+ reflection . parent . name . includes ( "Chat" )
84
+ ) {
85
+ if (
86
+ ! WHITELISTED_CHAT_MODEL_INHERITED_METHODS . find (
87
+ ( n ) => n === reflection . name
88
+ )
89
+ ) {
90
+ return true ;
91
+ }
92
+ }
93
+ return false ;
94
+ }
95
+
96
+ /**
97
+ * Checks if the reflection is an accessor and is named `callKeys`,
98
+ * and returns true (to hide the reflection) if it is.
99
+ *
100
+ * @param {DeclarationReflection } reflection
101
+ * @returns {boolean } Whether or not to hide the reflection
102
+ */
103
+ function hideChatModelAccessors ( reflection ) {
104
+ if (
105
+ reflection . kind === ReflectionKind . Accessor &&
106
+ reflection . name === "callKeys"
107
+ ) {
108
+ return true ;
109
+ }
110
+ return false ;
111
+ }
112
+
113
+ /**
114
+ * Check if the reflection should be hidden. If it should, it
115
+ * returns true.
116
+ *
117
+ * @param {DeclarationReflection } reflection
118
+ * @returns {boolean } Whether or not to hide the reflection
119
+ */
120
+ function hideChatModelReflection ( reflection ) {
121
+ return (
122
+ hideChatModelProperties ( reflection ) ||
123
+ hideChatModelMethods ( reflection ) ||
124
+ hideChatModelAccessors ( reflection )
125
+ ) ;
126
+ }
127
+
52
128
/**
53
129
* @param {string | undefined } deprecationText
54
130
* @returns {string }
@@ -136,36 +212,7 @@ function load(application) {
136
212
function resolveReflection ( _context , reflection ) {
137
213
const reflectionKind = reflection . kind ;
138
214
139
- if (
140
- reflectionKind === ReflectionKind . Method &&
141
- reflection ?. parent &&
142
- reflection . parent . kind === ReflectionKind . Class &&
143
- reflection . parent . name . includes ( "Chat" )
144
- ) {
145
- if (
146
- ! WHITELISTED_CHAT_MODEL_INHERITED_METHODS . find (
147
- ( n ) => n === reflection . name
148
- )
149
- ) {
150
- reflectionsToHide . push ( reflection ) ;
151
- }
152
- }
153
-
154
- if (
155
- reflectionKind === ReflectionKind . Property &&
156
- reflection ?. parent &&
157
- reflection . parent . kind === ReflectionKind . Class &&
158
- reflection . parent . name . includes ( "Chat" )
159
- ) {
160
- // Hide all properties of chat models
161
- reflectionsToHide . push ( reflection ) ;
162
- }
163
-
164
- if (
165
- reflectionKind === ReflectionKind . Accessor &&
166
- reflection . name === "callKeys"
167
- ) {
168
- // Hide all `callKeys` accessors
215
+ if ( hideChatModelReflection ( reflection ) ) {
169
216
reflectionsToHide . push ( reflection ) ;
170
217
}
171
218
0 commit comments