Skip to content

Commit caf5fa0

Browse files
Chin Jia XiongChin Jia Xiong
authored andcommitted
Implement overrides
1 parent 4d8b8fe commit caf5fa0

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

lib/services/VirtualService.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,20 @@ export class VirtualService {
196196
formData.append("skipTTS", configs?.skipTTS ? "true" : "false");
197197
formData.append("userName", this.configs.userName ?? "");
198198
formData.append("botName", this.configs.virtualName ?? "");
199-
200-
if (configs?.overrides) {
201-
Object.keys(configs.overrides).forEach((key) => {
202-
formData.append(key, configs.overrides[key]);
203-
});
204-
}
205199
}
200+
const jsonBody: { [id: string]: any } = {
201+
text: content,
202+
skipTTS: configs?.skipTTS,
203+
userName: this.configs.userName,
204+
botName: this.configs.virtualName,
205+
};
206+
if (!!configs?.overrides) {
207+
Object.keys(configs.overrides).forEach((key) => {
208+
formData.append(key, configs.overrides?.[key] ?? "");
209+
jsonBody[key] = configs.overrides?.[key] ?? "";
210+
});
211+
}
212+
206213
const resp = await fetch(`${this.runnerUrl}/prompts`, {
207214
method: "POST",
208215
headers:
@@ -214,15 +221,7 @@ export class VirtualService {
214221
: {
215222
Authorization: `Bearer ${cachedRunnerToken}`,
216223
},
217-
body:
218-
typeof content === "string"
219-
? JSON.stringify({
220-
text: content,
221-
skipTTS: configs?.skipTTS,
222-
userName: this.configs.userName,
223-
botName: this.configs.virtualName,
224-
})
225-
: formData,
224+
body: typeof content === "string" ? JSON.stringify(jsonBody) : formData,
226225
});
227226
// if encountered error, retry after init access token
228227
if (resp.status !== 200 && (retry ?? 0) < 3) {

lib/types/ConfigType.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ export type ConfigType = {
22
skipTTS: boolean;
33
ttsMode?: boolean;
44
speakOnResponse: boolean;
5-
overrides?: any;
5+
overrides?: { [id: string]: any };
66
};

src/App.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@ function App() {
9797
userName: "User",
9898
env: "development",
9999
}}
100-
configs={{ skipTTS: true, speakOnResponse: false }}
100+
configs={{
101+
skipTTS: true,
102+
speakOnResponse: false,
103+
overrides: {
104+
abc: true,
105+
},
106+
}}
101107
zoom={2}
102108
></CharacterRoom>
103109
<div

0 commit comments

Comments
 (0)