Update chat_template.jinja to correctly parse types nested in arrays
#116
by
daohanlu
- opened
- chat_template.jinja +4 -14
chat_template.jinja
CHANGED
@@ -10,21 +10,11 @@
|
|
10 |
{%- macro render_typescript_type(param_spec, required_params, is_nullable=false) -%}
|
11 |
{%- if param_spec.type == "array" -%}
|
12 |
{%- if param_spec['items'] -%}
|
13 |
-
{%-
|
14 |
-
|
15 |
-
|
16 |
-
{{- "number[]" }}
|
17 |
-
{%- elif param_spec['items']['type'] == "integer" -%}
|
18 |
-
{{- "number[]" }}
|
19 |
-
{%- elif param_spec['items']['type'] == "boolean" -%}
|
20 |
-
{{- "boolean[]" }}
|
21 |
{%- else -%}
|
22 |
-
{
|
23 |
-
{%- if inner_type == "object | object" or inner_type|length > 50 -%}
|
24 |
-
{{- "any[]" }}
|
25 |
-
{%- else -%}
|
26 |
-
{{- inner_type + "[]" }}
|
27 |
-
{%- endif -%}
|
28 |
{%- endif -%}
|
29 |
{%- if param_spec.nullable -%}
|
30 |
{{- " | null" }}
|
|
|
10 |
{%- macro render_typescript_type(param_spec, required_params, is_nullable=false) -%}
|
11 |
{%- if param_spec.type == "array" -%}
|
12 |
{%- if param_spec['items'] -%}
|
13 |
+
{%- set inner_type = render_typescript_type(param_spec['items'], required_params) -%}
|
14 |
+
{%- if inner_type == "object | object" or inner_type|length > 200 -%}
|
15 |
+
{{- "any[]" }}
|
|
|
|
|
|
|
|
|
|
|
16 |
{%- else -%}
|
17 |
+
{{- inner_type + "[]" }}
|
|
|
|
|
|
|
|
|
|
|
18 |
{%- endif -%}
|
19 |
{%- if param_spec.nullable -%}
|
20 |
{{- " | null" }}
|