Skip to content

Commit c6c17c5

Browse files
committed
Merge branch 'main' into cs-6704-error-message-if-fails-to-send
2 parents e0932ee + dd75e87 commit c6c17c5

File tree

105 files changed

+1605
-1247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1605
-1247
lines changed

packages/ai-bot/main.ts

+22-10
Original file line numberDiff line numberDiff line change
@@ -129,39 +129,46 @@ function getResponse(history: DiscreteMatrixEvent[], aiBotUsername: string) {
129129
let messages = getModifyPrompt(history, aiBotUsername, functions);
130130
if (functions.length === 0) {
131131
return openai.beta.chat.completions.stream({
132-
model: 'gpt-4-1106-preview',
132+
model: 'gpt-4-turbo',
133133
messages: messages,
134134
});
135135
} else {
136136
return openai.beta.chat.completions.stream({
137-
model: 'gpt-4-1106-preview',
137+
model: 'gpt-4-turbo',
138138
messages: messages,
139139
functions: functions,
140140
function_call: 'auto',
141141
});
142142
}
143143
}
144144

145+
function getErrorMessage(error: any): string {
146+
if (error instanceof OpenAIError) {
147+
return `OpenAI error: ${error.name} - ${error.message}`;
148+
}
149+
if (typeof error === 'string') {
150+
return `Unknown error: ${error}`;
151+
}
152+
return `Unknown error`;
153+
}
154+
145155
async function sendError(
146156
client: MatrixClient,
147157
room: Room,
148158
error: any,
149159
eventToUpdate: string | undefined,
150160
) {
151-
if (error instanceof OpenAIError) {
152-
log.error(`OpenAI error: ${error.name} - ${error.message}`);
153-
} else {
154-
log.error(`Unknown error: ${error}`);
155-
}
156161
try {
162+
let errorMessage = getErrorMessage(error);
163+
log.error(errorMessage);
157164
await sendMessage(
158165
client,
159166
room,
160167
'There was an error processing your request, please try again later',
161168
eventToUpdate,
162169
{
163170
isStreamingFinished: true,
164-
errorMessage: error.message,
171+
errorMessage,
165172
},
166173
);
167174
} catch (e) {
@@ -227,8 +234,13 @@ async function handleDebugCommands(
227234
eventBody.split('debug:title:set:')[1],
228235
);
229236
} else if (eventBody.startsWith('debug:boom')) {
230-
await sendMessage(client, room, `Throwing an unhandled error`, undefined);
231-
throw new Error('Boom');
237+
await sendError(
238+
client,
239+
room,
240+
`Boom! Throwing an unhandled error`,
241+
undefined,
242+
);
243+
throw new Error('Boom!');
232244
}
233245
// Use GPT to set the room title
234246
else if (eventBody.startsWith('debug:title:create')) {

packages/base/contains-many-component.gts

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class ContainsManyEditor extends GlimmerComponent<Signature> {
4646
<div class='remove-button-container'>
4747
<IconButton
4848
@icon={{IconTrash}}
49-
@width='20px'
50-
@height='20px'
49+
@width='18px'
50+
@height='18px'
5151
class='remove'
5252
{{on 'click' (fn this.remove i)}}
5353
data-test-remove={{i}}

packages/base/links-to-many-component.gts

+4-4
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class LinksToManyEditor extends GlimmerComponent<Signature> {
105105
<IconButton
106106
@variant='primary'
107107
@icon={{IconX}}
108-
@width='14px'
109-
@height='14px'
108+
@width='10px'
109+
@height='10px'
110110
class='remove-item-button'
111111
{{on 'click' (fn this.remove i)}}
112112
aria-label='Remove'
@@ -119,8 +119,8 @@ class LinksToManyEditor extends GlimmerComponent<Signature> {
119119
<AddButton
120120
class='add-new'
121121
@variant='pill'
122-
@iconWidth='16px'
123-
@iconHeight='16px'
122+
@iconWidth='12px'
123+
@iconHeight='12px'
124124
{{on 'click' this.add}}
125125
data-test-add-new
126126
>
Loading
Loading
Loading
Loading
+3-7
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)