Skip to content

Commit bda84ea

Browse files
committed
refactor(chat): support multiple assistants internally
1 parent ab51d6b commit bda84ea

File tree

3 files changed

+279
-71
lines changed

3 files changed

+279
-71
lines changed

library/AcfFields/json/chat.json

Lines changed: 125 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
"title": "Chat Settings",
44
"fields": [
55
{
6-
"key": "field_69b814ffe90d1",
7-
"label": "Chat URL",
8-
"name": "chat_url",
6+
"key": "field_69ddf0289aa80",
7+
"label": "Default Assistant",
8+
"name": "chat_default_assistant",
99
"aria-label": "",
10-
"type": "url",
11-
"instructions": "",
10+
"type": "text",
11+
"instructions": "Unique ID of the assistant to use when no assistant is given.",
1212
"required": 0,
1313
"conditional_logic": 0,
1414
"wrapper": {
@@ -17,34 +17,18 @@
1717
"id": ""
1818
},
1919
"default_value": "",
20-
"allow_in_bindings": 0,
21-
"placeholder": ""
22-
},
23-
{
24-
"key": "field_69b97761d5880",
25-
"label": "Chat API Key",
26-
"name": "chat_api_key",
27-
"aria-label": "",
28-
"type": "password",
29-
"instructions": "",
30-
"required": 0,
31-
"conditional_logic": 0,
32-
"wrapper": {
33-
"width": "",
34-
"class": "",
35-
"id": ""
36-
},
20+
"maxlength": "",
3721
"allow_in_bindings": 0,
3822
"placeholder": "",
3923
"prepend": "",
4024
"append": ""
4125
},
4226
{
43-
"key": "field_69b97783d5881",
44-
"label": "Chat Assistant ID",
45-
"name": "chat_assistant_id",
27+
"key": "field_69ddefc99aa7a",
28+
"label": "Assistants",
29+
"name": "chat_assistants",
4630
"aria-label": "",
47-
"type": "text",
31+
"type": "repeater",
4832
"instructions": "",
4933
"required": 0,
5034
"conditional_logic": 0,
@@ -53,12 +37,120 @@
5337
"class": "",
5438
"id": ""
5539
},
56-
"default_value": "",
57-
"maxlength": "",
58-
"allow_in_bindings": 0,
59-
"placeholder": "",
60-
"prepend": "",
61-
"append": ""
40+
"layout": "table",
41+
"pagination": 0,
42+
"min": 0,
43+
"max": 0,
44+
"collapsed": "",
45+
"button_label": "Add Row",
46+
"rows_per_page": 20,
47+
"sub_fields": [
48+
{
49+
"key": "field_69ddefdc9aa7b",
50+
"label": "Unique ID",
51+
"name": "id",
52+
"aria-label": "",
53+
"type": "text",
54+
"instructions": "",
55+
"required": 0,
56+
"conditional_logic": 0,
57+
"wrapper": {
58+
"width": "",
59+
"class": "",
60+
"id": ""
61+
},
62+
"default_value": "",
63+
"maxlength": "",
64+
"allow_in_bindings": 0,
65+
"placeholder": "",
66+
"prepend": "",
67+
"append": "",
68+
"parent_repeater": "field_69ddefc99aa7a"
69+
},
70+
{
71+
"key": "field_69ddefe99aa7c",
72+
"label": "Name",
73+
"name": "name",
74+
"aria-label": "",
75+
"type": "text",
76+
"instructions": "",
77+
"required": 0,
78+
"conditional_logic": 0,
79+
"wrapper": {
80+
"width": "",
81+
"class": "",
82+
"id": ""
83+
},
84+
"default_value": "",
85+
"maxlength": "",
86+
"allow_in_bindings": 0,
87+
"placeholder": "",
88+
"prepend": "",
89+
"append": "",
90+
"parent_repeater": "field_69ddefc99aa7a"
91+
},
92+
{
93+
"key": "field_69ddefed9aa7d",
94+
"label": "Server URL",
95+
"name": "server_url",
96+
"aria-label": "",
97+
"type": "url",
98+
"instructions": "",
99+
"required": 0,
100+
"conditional_logic": 0,
101+
"wrapper": {
102+
"width": "",
103+
"class": "",
104+
"id": ""
105+
},
106+
"default_value": "",
107+
"allow_in_bindings": 0,
108+
"placeholder": "",
109+
"parent_repeater": "field_69ddefc99aa7a"
110+
},
111+
{
112+
"key": "field_69ddeffa9aa7e",
113+
"label": "API Key",
114+
"name": "api_key",
115+
"aria-label": "",
116+
"type": "password",
117+
"instructions": "",
118+
"required": 0,
119+
"conditional_logic": 0,
120+
"wrapper": {
121+
"width": "",
122+
"class": "",
123+
"id": ""
124+
},
125+
"allow_in_bindings": 0,
126+
"placeholder": "",
127+
"prepend": "",
128+
"append": "",
129+
"parent_repeater": "field_69ddefc99aa7a"
130+
},
131+
{
132+
"key": "field_69ddf0029aa7f",
133+
"label": "Assistant ID",
134+
"name": "assistant_id",
135+
"aria-label": "",
136+
"type": "text",
137+
"instructions": "",
138+
"required": 0,
139+
"conditional_logic": 0,
140+
"wrapper": {
141+
"width": "",
142+
"class": "",
143+
"id": ""
144+
},
145+
"default_value": "",
146+
"maxlength": "",
147+
"allow_in_bindings": 0,
148+
"placeholder": "",
149+
"prepend": "",
150+
"append": "",
151+
"parent_repeater": "field_69ddefc99aa7a"
152+
}
153+
]
62154
}
63155
],
64156
"location": [
@@ -73,7 +165,7 @@
73165
{
74166
"param": "block",
75167
"operator": "==",
76-
"value": "acf\/chat"
168+
"value": "all"
77169
}
78170
]
79171
],

library/AcfFields/php/chat.php

Lines changed: 126 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
'title' => __('Chat Settings', 'municipio'),
77
'fields' => array(
88
0 => array(
9-
'key' => 'field_69b814ffe90d1',
10-
'label' => __('Chat URL', 'municipio'),
11-
'name' => 'chat_url',
9+
'key' => 'field_69ddf0289aa80',
10+
'label' => __('Default Assistant', 'municipio'),
11+
'name' => 'chat_default_assistant',
1212
'aria-label' => '',
13-
'type' => 'url',
14-
'instructions' => '',
13+
'type' => 'text',
14+
'instructions' => __('Unique ID of the assistant to use when no assistant is given.', 'municipio'),
1515
'required' => 0,
1616
'conditional_logic' => 0,
1717
'wrapper' => array(
@@ -20,34 +20,18 @@
2020
'id' => '',
2121
),
2222
'default_value' => '',
23-
'allow_in_bindings' => 0,
24-
'placeholder' => '',
25-
),
26-
1 => array(
27-
'key' => 'field_69b97761d5880',
28-
'label' => __('Chat API Key', 'municipio'),
29-
'name' => 'chat_api_key',
30-
'aria-label' => '',
31-
'type' => 'password',
32-
'instructions' => '',
33-
'required' => 0,
34-
'conditional_logic' => 0,
35-
'wrapper' => array(
36-
'width' => '',
37-
'class' => '',
38-
'id' => '',
39-
),
23+
'maxlength' => '',
4024
'allow_in_bindings' => 0,
4125
'placeholder' => '',
4226
'prepend' => '',
4327
'append' => '',
4428
),
45-
2 => array(
46-
'key' => 'field_69b97783d5881',
47-
'label' => __('Chat Assistant ID', 'municipio'),
48-
'name' => 'chat_assistant_id',
29+
1 => array(
30+
'key' => 'field_69ddefc99aa7a',
31+
'label' => __('Assistants', 'municipio'),
32+
'name' => 'chat_assistants',
4933
'aria-label' => '',
50-
'type' => 'text',
34+
'type' => 'repeater',
5135
'instructions' => '',
5236
'required' => 0,
5337
'conditional_logic' => 0,
@@ -56,12 +40,120 @@
5640
'class' => '',
5741
'id' => '',
5842
),
59-
'default_value' => '',
60-
'maxlength' => '',
61-
'allow_in_bindings' => 0,
62-
'placeholder' => '',
63-
'prepend' => '',
64-
'append' => '',
43+
'layout' => 'table',
44+
'pagination' => 0,
45+
'min' => 0,
46+
'max' => 0,
47+
'collapsed' => '',
48+
'button_label' => __('Add Row', 'municipio'),
49+
'rows_per_page' => 20,
50+
'sub_fields' => array(
51+
0 => array(
52+
'key' => 'field_69ddefdc9aa7b',
53+
'label' => __('Unique ID', 'municipio'),
54+
'name' => 'id',
55+
'aria-label' => '',
56+
'type' => 'text',
57+
'instructions' => '',
58+
'required' => 0,
59+
'conditional_logic' => 0,
60+
'wrapper' => array(
61+
'width' => '',
62+
'class' => '',
63+
'id' => '',
64+
),
65+
'default_value' => '',
66+
'maxlength' => '',
67+
'allow_in_bindings' => 0,
68+
'placeholder' => '',
69+
'prepend' => '',
70+
'append' => '',
71+
'parent_repeater' => 'field_69ddefc99aa7a',
72+
),
73+
1 => array(
74+
'key' => 'field_69ddefe99aa7c',
75+
'label' => __('Name', 'municipio'),
76+
'name' => 'name',
77+
'aria-label' => '',
78+
'type' => 'text',
79+
'instructions' => '',
80+
'required' => 0,
81+
'conditional_logic' => 0,
82+
'wrapper' => array(
83+
'width' => '',
84+
'class' => '',
85+
'id' => '',
86+
),
87+
'default_value' => '',
88+
'maxlength' => '',
89+
'allow_in_bindings' => 0,
90+
'placeholder' => '',
91+
'prepend' => '',
92+
'append' => '',
93+
'parent_repeater' => 'field_69ddefc99aa7a',
94+
),
95+
2 => array(
96+
'key' => 'field_69ddefed9aa7d',
97+
'label' => __('Server URL', 'municipio'),
98+
'name' => 'server_url',
99+
'aria-label' => '',
100+
'type' => 'url',
101+
'instructions' => '',
102+
'required' => 0,
103+
'conditional_logic' => 0,
104+
'wrapper' => array(
105+
'width' => '',
106+
'class' => '',
107+
'id' => '',
108+
),
109+
'default_value' => '',
110+
'allow_in_bindings' => 0,
111+
'placeholder' => '',
112+
'parent_repeater' => 'field_69ddefc99aa7a',
113+
),
114+
3 => array(
115+
'key' => 'field_69ddeffa9aa7e',
116+
'label' => __('API Key', 'municipio'),
117+
'name' => 'api_key',
118+
'aria-label' => '',
119+
'type' => 'password',
120+
'instructions' => '',
121+
'required' => 0,
122+
'conditional_logic' => 0,
123+
'wrapper' => array(
124+
'width' => '',
125+
'class' => '',
126+
'id' => '',
127+
),
128+
'allow_in_bindings' => 0,
129+
'placeholder' => '',
130+
'prepend' => '',
131+
'append' => '',
132+
'parent_repeater' => 'field_69ddefc99aa7a',
133+
),
134+
4 => array(
135+
'key' => 'field_69ddf0029aa7f',
136+
'label' => __('Assistant ID', 'municipio'),
137+
'name' => 'assistant_id',
138+
'aria-label' => '',
139+
'type' => 'text',
140+
'instructions' => '',
141+
'required' => 0,
142+
'conditional_logic' => 0,
143+
'wrapper' => array(
144+
'width' => '',
145+
'class' => '',
146+
'id' => '',
147+
),
148+
'default_value' => '',
149+
'maxlength' => '',
150+
'allow_in_bindings' => 0,
151+
'placeholder' => '',
152+
'prepend' => '',
153+
'append' => '',
154+
'parent_repeater' => 'field_69ddefc99aa7a',
155+
),
156+
),
65157
),
66158
),
67159
'location' => array(
@@ -76,7 +168,7 @@
76168
0 => array(
77169
'param' => 'block',
78170
'operator' => '==',
79-
'value' => 'acf/chat',
171+
'value' => 'all',
80172
),
81173
),
82174
),

0 commit comments

Comments
 (0)