mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
chore: remove structure output limit (#11444)
This commit is contained in:
@@ -150,12 +150,10 @@ export class GeminiProvider
|
|||||||
messages,
|
messages,
|
||||||
embeddings,
|
embeddings,
|
||||||
model,
|
model,
|
||||||
options = {},
|
|
||||||
}: {
|
}: {
|
||||||
messages?: PromptMessage[];
|
messages?: PromptMessage[];
|
||||||
embeddings?: string[];
|
embeddings?: string[];
|
||||||
model: string;
|
model: string;
|
||||||
options: CopilotChatOptions;
|
|
||||||
}) {
|
}) {
|
||||||
if (!(await this.isModelAvailable(model))) {
|
if (!(await this.isModelAvailable(model))) {
|
||||||
throw new CopilotPromptInvalid(`Invalid model: ${model}`);
|
throw new CopilotPromptInvalid(`Invalid model: ${model}`);
|
||||||
@@ -186,14 +184,6 @@ export class GeminiProvider
|
|||||||
) {
|
) {
|
||||||
throw new CopilotPromptInvalid('Invalid message role');
|
throw new CopilotPromptInvalid('Invalid message role');
|
||||||
}
|
}
|
||||||
// json mode need 'json' keyword in content
|
|
||||||
// ref: https://platform.openai.com/docs/api-reference/chat/create#chat-create-response_format
|
|
||||||
if (
|
|
||||||
options.jsonMode &&
|
|
||||||
!messages.some(m => m.content.toLowerCase().includes('json'))
|
|
||||||
) {
|
|
||||||
throw new CopilotPromptInvalid('Prompt not support json mode');
|
|
||||||
}
|
|
||||||
} else if (
|
} else if (
|
||||||
Array.isArray(embeddings) &&
|
Array.isArray(embeddings) &&
|
||||||
embeddings.some(e => typeof e !== 'string' || !e || !e.trim())
|
embeddings.some(e => typeof e !== 'string' || !e || !e.trim())
|
||||||
@@ -227,7 +217,7 @@ export class GeminiProvider
|
|||||||
model: string = 'gemini-2.0-flash-001',
|
model: string = 'gemini-2.0-flash-001',
|
||||||
options: CopilotChatOptions = {}
|
options: CopilotChatOptions = {}
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
await this.checkParams({ messages, model, options });
|
await this.checkParams({ messages, model });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
metrics.ai.counter('chat_text_calls').add(1, { model });
|
metrics.ai.counter('chat_text_calls').add(1, { model });
|
||||||
@@ -265,7 +255,7 @@ export class GeminiProvider
|
|||||||
model: string = 'gemini-2.0-flash-001',
|
model: string = 'gemini-2.0-flash-001',
|
||||||
options: CopilotChatOptions = {}
|
options: CopilotChatOptions = {}
|
||||||
): AsyncIterable<string> {
|
): AsyncIterable<string> {
|
||||||
await this.checkParams({ messages, model, options });
|
await this.checkParams({ messages, model });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
metrics.ai.counter('chat_text_stream_calls').add(1, { model });
|
metrics.ai.counter('chat_text_stream_calls').add(1, { model });
|
||||||
|
|||||||
Reference in New Issue
Block a user