Skip to content

Commit 90031d9

Browse files
wanlin31copybara-github
authored andcommitted
feat: generate function_response's converter
PiperOrigin-RevId: 808250364
1 parent 8b67b9d commit 90031d9

File tree

6 files changed

+608
-191
lines changed

6 files changed

+608
-191
lines changed

src/converters/_batches_converters.ts

Lines changed: 88 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,39 @@ export function functionCallToMldev(
9999
return toObject;
100100
}
101101

102+
export function functionResponseToMldev(
103+
fromObject: types.FunctionResponse,
104+
): Record<string, unknown> {
105+
const toObject: Record<string, unknown> = {};
106+
107+
const fromWillContinue = common.getValueByPath(fromObject, ['willContinue']);
108+
if (fromWillContinue != null) {
109+
common.setValueByPath(toObject, ['willContinue'], fromWillContinue);
110+
}
111+
112+
const fromScheduling = common.getValueByPath(fromObject, ['scheduling']);
113+
if (fromScheduling != null) {
114+
common.setValueByPath(toObject, ['scheduling'], fromScheduling);
115+
}
116+
117+
const fromId = common.getValueByPath(fromObject, ['id']);
118+
if (fromId != null) {
119+
common.setValueByPath(toObject, ['id'], fromId);
120+
}
121+
122+
const fromName = common.getValueByPath(fromObject, ['name']);
123+
if (fromName != null) {
124+
common.setValueByPath(toObject, ['name'], fromName);
125+
}
126+
127+
const fromResponse = common.getValueByPath(fromObject, ['response']);
128+
if (fromResponse != null) {
129+
common.setValueByPath(toObject, ['response'], fromResponse);
130+
}
131+
132+
return toObject;
133+
}
134+
102135
export function partToMldev(fromObject: types.Part): Record<string, unknown> {
103136
const toObject: Record<string, unknown> = {};
104137

@@ -152,6 +185,17 @@ export function partToMldev(fromObject: types.Part): Record<string, unknown> {
152185
);
153186
}
154187

188+
const fromFunctionResponse = common.getValueByPath(fromObject, [
189+
'functionResponse',
190+
]);
191+
if (fromFunctionResponse != null) {
192+
common.setValueByPath(
193+
toObject,
194+
['functionResponse'],
195+
functionResponseToMldev(fromFunctionResponse),
196+
);
197+
}
198+
155199
const fromCodeExecutionResult = common.getValueByPath(fromObject, [
156200
'codeExecutionResult',
157201
]);
@@ -170,13 +214,6 @@ export function partToMldev(fromObject: types.Part): Record<string, unknown> {
170214
common.setValueByPath(toObject, ['executableCode'], fromExecutableCode);
171215
}
172216

173-
const fromFunctionResponse = common.getValueByPath(fromObject, [
174-
'functionResponse',
175-
]);
176-
if (fromFunctionResponse != null) {
177-
common.setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
178-
}
179-
180217
const fromText = common.getValueByPath(fromObject, ['text']);
181218
if (fromText != null) {
182219
common.setValueByPath(toObject, ['text'], fromText);
@@ -1746,6 +1783,39 @@ export function functionCallFromMldev(
17461783
return toObject;
17471784
}
17481785

1786+
export function functionResponseFromMldev(
1787+
fromObject: types.FunctionResponse,
1788+
): Record<string, unknown> {
1789+
const toObject: Record<string, unknown> = {};
1790+
1791+
const fromWillContinue = common.getValueByPath(fromObject, ['willContinue']);
1792+
if (fromWillContinue != null) {
1793+
common.setValueByPath(toObject, ['willContinue'], fromWillContinue);
1794+
}
1795+
1796+
const fromScheduling = common.getValueByPath(fromObject, ['scheduling']);
1797+
if (fromScheduling != null) {
1798+
common.setValueByPath(toObject, ['scheduling'], fromScheduling);
1799+
}
1800+
1801+
const fromId = common.getValueByPath(fromObject, ['id']);
1802+
if (fromId != null) {
1803+
common.setValueByPath(toObject, ['id'], fromId);
1804+
}
1805+
1806+
const fromName = common.getValueByPath(fromObject, ['name']);
1807+
if (fromName != null) {
1808+
common.setValueByPath(toObject, ['name'], fromName);
1809+
}
1810+
1811+
const fromResponse = common.getValueByPath(fromObject, ['response']);
1812+
if (fromResponse != null) {
1813+
common.setValueByPath(toObject, ['response'], fromResponse);
1814+
}
1815+
1816+
return toObject;
1817+
}
1818+
17491819
export function partFromMldev(fromObject: types.Part): Record<string, unknown> {
17501820
const toObject: Record<string, unknown> = {};
17511821

@@ -1799,6 +1869,17 @@ export function partFromMldev(fromObject: types.Part): Record<string, unknown> {
17991869
);
18001870
}
18011871

1872+
const fromFunctionResponse = common.getValueByPath(fromObject, [
1873+
'functionResponse',
1874+
]);
1875+
if (fromFunctionResponse != null) {
1876+
common.setValueByPath(
1877+
toObject,
1878+
['functionResponse'],
1879+
functionResponseFromMldev(fromFunctionResponse),
1880+
);
1881+
}
1882+
18021883
const fromCodeExecutionResult = common.getValueByPath(fromObject, [
18031884
'codeExecutionResult',
18041885
]);
@@ -1817,13 +1898,6 @@ export function partFromMldev(fromObject: types.Part): Record<string, unknown> {
18171898
common.setValueByPath(toObject, ['executableCode'], fromExecutableCode);
18181899
}
18191900

1820-
const fromFunctionResponse = common.getValueByPath(fromObject, [
1821-
'functionResponse',
1822-
]);
1823-
if (fromFunctionResponse != null) {
1824-
common.setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
1825-
}
1826-
18271901
const fromText = common.getValueByPath(fromObject, ['text']);
18281902
if (fromText != null) {
18291903
common.setValueByPath(toObject, ['text'], fromText);

src/converters/_caches_converters.ts

Lines changed: 88 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,39 @@ export function functionCallToMldev(
9999
return toObject;
100100
}
101101

102+
export function functionResponseToMldev(
103+
fromObject: types.FunctionResponse,
104+
): Record<string, unknown> {
105+
const toObject: Record<string, unknown> = {};
106+
107+
const fromWillContinue = common.getValueByPath(fromObject, ['willContinue']);
108+
if (fromWillContinue != null) {
109+
common.setValueByPath(toObject, ['willContinue'], fromWillContinue);
110+
}
111+
112+
const fromScheduling = common.getValueByPath(fromObject, ['scheduling']);
113+
if (fromScheduling != null) {
114+
common.setValueByPath(toObject, ['scheduling'], fromScheduling);
115+
}
116+
117+
const fromId = common.getValueByPath(fromObject, ['id']);
118+
if (fromId != null) {
119+
common.setValueByPath(toObject, ['id'], fromId);
120+
}
121+
122+
const fromName = common.getValueByPath(fromObject, ['name']);
123+
if (fromName != null) {
124+
common.setValueByPath(toObject, ['name'], fromName);
125+
}
126+
127+
const fromResponse = common.getValueByPath(fromObject, ['response']);
128+
if (fromResponse != null) {
129+
common.setValueByPath(toObject, ['response'], fromResponse);
130+
}
131+
132+
return toObject;
133+
}
134+
102135
export function partToMldev(fromObject: types.Part): Record<string, unknown> {
103136
const toObject: Record<string, unknown> = {};
104137

@@ -152,6 +185,17 @@ export function partToMldev(fromObject: types.Part): Record<string, unknown> {
152185
);
153186
}
154187

188+
const fromFunctionResponse = common.getValueByPath(fromObject, [
189+
'functionResponse',
190+
]);
191+
if (fromFunctionResponse != null) {
192+
common.setValueByPath(
193+
toObject,
194+
['functionResponse'],
195+
functionResponseToMldev(fromFunctionResponse),
196+
);
197+
}
198+
155199
const fromCodeExecutionResult = common.getValueByPath(fromObject, [
156200
'codeExecutionResult',
157201
]);
@@ -170,13 +214,6 @@ export function partToMldev(fromObject: types.Part): Record<string, unknown> {
170214
common.setValueByPath(toObject, ['executableCode'], fromExecutableCode);
171215
}
172216

173-
const fromFunctionResponse = common.getValueByPath(fromObject, [
174-
'functionResponse',
175-
]);
176-
if (fromFunctionResponse != null) {
177-
common.setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
178-
}
179-
180217
const fromText = common.getValueByPath(fromObject, ['text']);
181218
if (fromText != null) {
182219
common.setValueByPath(toObject, ['text'], fromText);
@@ -844,6 +881,39 @@ export function functionCallToVertex(
844881
return toObject;
845882
}
846883

884+
export function functionResponseToVertex(
885+
fromObject: types.FunctionResponse,
886+
): Record<string, unknown> {
887+
const toObject: Record<string, unknown> = {};
888+
889+
const fromWillContinue = common.getValueByPath(fromObject, ['willContinue']);
890+
if (fromWillContinue != null) {
891+
common.setValueByPath(toObject, ['willContinue'], fromWillContinue);
892+
}
893+
894+
const fromScheduling = common.getValueByPath(fromObject, ['scheduling']);
895+
if (fromScheduling != null) {
896+
common.setValueByPath(toObject, ['scheduling'], fromScheduling);
897+
}
898+
899+
const fromId = common.getValueByPath(fromObject, ['id']);
900+
if (fromId != null) {
901+
common.setValueByPath(toObject, ['id'], fromId);
902+
}
903+
904+
const fromName = common.getValueByPath(fromObject, ['name']);
905+
if (fromName != null) {
906+
common.setValueByPath(toObject, ['name'], fromName);
907+
}
908+
909+
const fromResponse = common.getValueByPath(fromObject, ['response']);
910+
if (fromResponse != null) {
911+
common.setValueByPath(toObject, ['response'], fromResponse);
912+
}
913+
914+
return toObject;
915+
}
916+
847917
export function partToVertex(fromObject: types.Part): Record<string, unknown> {
848918
const toObject: Record<string, unknown> = {};
849919

@@ -897,6 +967,17 @@ export function partToVertex(fromObject: types.Part): Record<string, unknown> {
897967
);
898968
}
899969

970+
const fromFunctionResponse = common.getValueByPath(fromObject, [
971+
'functionResponse',
972+
]);
973+
if (fromFunctionResponse != null) {
974+
common.setValueByPath(
975+
toObject,
976+
['functionResponse'],
977+
functionResponseToVertex(fromFunctionResponse),
978+
);
979+
}
980+
900981
const fromCodeExecutionResult = common.getValueByPath(fromObject, [
901982
'codeExecutionResult',
902983
]);
@@ -915,13 +996,6 @@ export function partToVertex(fromObject: types.Part): Record<string, unknown> {
915996
common.setValueByPath(toObject, ['executableCode'], fromExecutableCode);
916997
}
917998

918-
const fromFunctionResponse = common.getValueByPath(fromObject, [
919-
'functionResponse',
920-
]);
921-
if (fromFunctionResponse != null) {
922-
common.setValueByPath(toObject, ['functionResponse'], fromFunctionResponse);
923-
}
924-
925999
const fromText = common.getValueByPath(fromObject, ['text']);
9261000
if (fromText != null) {
9271001
common.setValueByPath(toObject, ['text'], fromText);

0 commit comments

Comments
 (0)