This commit is contained in:
DarkSky
2026-03-17 23:32:57 +08:00
parent bbcb7e69fe
commit 1112a06623
3 changed files with 23 additions and 13 deletions

View File

@@ -258,7 +258,7 @@ export class FalProvider extends CopilotProvider<FalConfig> {
const model = this.selectModel(cond); const model = this.selectModel(cond);
try { try {
metrics.ai.counter('chat_text_calls').add(1, { model: model.id }); metrics.ai.counter('chat_text_calls').add(1, this.metricLabels(model.id));
// by default, image prompt assumes there is only one message // by default, image prompt assumes there is only one message
const prompt = this.extractPrompt(messages[messages.length - 1]); const prompt = this.extractPrompt(messages[messages.length - 1]);
@@ -283,7 +283,9 @@ export class FalProvider extends CopilotProvider<FalConfig> {
} }
return data.output; return data.output;
} catch (e: any) { } catch (e: any) {
metrics.ai.counter('chat_text_errors').add(1, { model: model.id }); metrics.ai
.counter('chat_text_errors')
.add(1, this.metricLabels(model.id));
throw this.handleError(e); throw this.handleError(e);
} }
} }
@@ -296,12 +298,16 @@ export class FalProvider extends CopilotProvider<FalConfig> {
const model = this.selectModel(cond); const model = this.selectModel(cond);
try { try {
metrics.ai.counter('chat_text_stream_calls').add(1, { model: model.id }); metrics.ai
.counter('chat_text_stream_calls')
.add(1, this.metricLabels(model.id));
const result = await this.text(cond, messages, options); const result = await this.text(cond, messages, options);
yield result; yield result;
} catch (e) { } catch (e) {
metrics.ai.counter('chat_text_stream_errors').add(1, { model: model.id }); metrics.ai
.counter('chat_text_stream_errors')
.add(1, this.metricLabels(model.id));
throw e; throw e;
} }
} }
@@ -319,7 +325,7 @@ export class FalProvider extends CopilotProvider<FalConfig> {
try { try {
metrics.ai metrics.ai
.counter('generate_images_stream_calls') .counter('generate_images_stream_calls')
.add(1, { model: model.id }); .add(1, this.metricLabels(model.id));
// by default, image prompt assumes there is only one message // by default, image prompt assumes there is only one message
const prompt = this.extractPrompt( const prompt = this.extractPrompt(
@@ -376,7 +382,7 @@ export class FalProvider extends CopilotProvider<FalConfig> {
} catch (e) { } catch (e) {
metrics.ai metrics.ai
.counter('generate_images_stream_errors') .counter('generate_images_stream_errors')
.add(1, { model: model.id }); .add(1, this.metricLabels(model.id));
throw this.handleError(e); throw this.handleError(e);
} }
} }

View File

@@ -664,7 +664,7 @@ export class OpenAIProvider extends CopilotProvider<OpenAIConfig> {
const model = this.selectModel(normalizedCond); const model = this.selectModel(normalizedCond);
try { try {
metrics.ai.counter('chat_text_calls').add(1, { model: model.id }); metrics.ai.counter('chat_text_calls').add(1, this.metricLabels(model.id));
const backendConfig = this.createNativeConfig(); const backendConfig = this.createNativeConfig();
const middleware = this.getActiveProviderMiddleware(); const middleware = this.getActiveProviderMiddleware();
const cap = this.getAttachCapability(model, ModelOutputType.Structured); const cap = this.getAttachCapability(model, ModelOutputType.Structured);
@@ -687,7 +687,9 @@ export class OpenAIProvider extends CopilotProvider<OpenAIConfig> {
const validated = schema.parse(parsed); const validated = schema.parse(parsed);
return JSON.stringify(validated); return JSON.stringify(validated);
} catch (e: any) { } catch (e: any) {
metrics.ai.counter('chat_text_errors').add(1, { model: model.id }); metrics.ai
.counter('chat_text_errors')
.add(1, this.metricLabels(model.id));
throw this.handleError(e); throw this.handleError(e);
} }
} }
@@ -983,7 +985,7 @@ export class OpenAIProvider extends CopilotProvider<OpenAIConfig> {
metrics.ai metrics.ai
.counter('generate_images_stream_calls') .counter('generate_images_stream_calls')
.add(1, { model: model.id }); .add(1, this.metricLabels(model.id));
const { content: prompt, attachments } = [...messages].pop() || {}; const { content: prompt, attachments } = [...messages].pop() || {};
if (!prompt) throw new CopilotPromptInvalid('Prompt is required'); if (!prompt) throw new CopilotPromptInvalid('Prompt is required');
@@ -1021,7 +1023,9 @@ export class OpenAIProvider extends CopilotProvider<OpenAIConfig> {
} }
return; return;
} catch (e: any) { } catch (e: any) {
metrics.ai.counter('generate_images_errors').add(1, { model: model.id }); metrics.ai
.counter('generate_images_errors')
.add(1, this.metricLabels(model.id));
throw this.handleError(e); throw this.handleError(e);
} }
} }

View File

@@ -1095,7 +1095,7 @@ export function useAFFiNEI18N(): {
*/ */
["com.affine.appearanceSettings.showLinkedDocInSidebar.description"](): string; ["com.affine.appearanceSettings.showLinkedDocInSidebar.description"](): string;
/** /**
* `Your current email is {{email}}. We'll send a temporary verification link to this email.` * `Your current email is {{email}}. We'll send a confirmation link there first so you can securely switch to a new email address.`
*/ */
["com.affine.auth.change.email.message"](options: { ["com.affine.auth.change.email.message"](options: {
readonly email: string; readonly email: string;
@@ -1427,7 +1427,7 @@ export function useAFFiNEI18N(): {
*/ */
["com.affine.auth.toast.title.signed-in"](): string; ["com.affine.auth.toast.title.signed-in"](): string;
/** /**
* `Your current email is {{email}}. We'll send a temporary verification link to this email.` * `Your current email is {{email}}. We'll send a verification link to this email so you can confirm it belongs to you.`
*/ */
["com.affine.auth.verify.email.message"](options: { ["com.affine.auth.verify.email.message"](options: {
readonly email: string; readonly email: string;
@@ -9897,7 +9897,7 @@ export const TypedTrans: {
["2"]: JSX.Element; ["2"]: JSX.Element;
}>>; }>>;
/** /**
* `<1>{{username}}</1> has accept your invitation` * `<1>{{username}}</1> has accepted your invitation`
*/ */
["com.affine.notification.invitation-accepted"]: ComponentType<TypedTransProps<{ ["com.affine.notification.invitation-accepted"]: ComponentType<TypedTransProps<{
readonly username: string; readonly username: string;