setup max retries for AI request

This commit is contained in:
an-lee
2024-03-25 11:09:10 +08:00
parent cab66e6cd0
commit 7233e0d4a8
6 changed files with 9 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ export const analyzeCommand = async (
},
cache: false,
verbose: true,
maxRetries: 2,
});
const prompt = ChatPromptTemplate.fromMessages([

View File

@@ -39,6 +39,7 @@ export const extractStoryCommand = async (
},
cache: true,
verbose: true,
maxRetries: 2,
}).bind({
tools: [
{

View File

@@ -59,6 +59,7 @@ export const ipaCommand = async (
},
cache: true,
verbose: true,
maxRetries: 2,
});
const prompt = ChatPromptTemplate.fromMessages([

View File

@@ -71,6 +71,7 @@ export const lookupCommand = async (
},
cache: true,
verbose: true,
maxRetries: 2,
});
const prompt = ChatPromptTemplate.fromMessages([

View File

@@ -22,6 +22,7 @@ export const translateCommand = async (
},
cache: false,
verbose: true,
maxRetries: 2,
});
const prompt = ChatPromptTemplate.fromMessages([

View File

@@ -39,7 +39,7 @@ export const useConversation = () => {
configuration: {
baseURL: `${apiUrl}/api/ai`,
},
maxRetries: 3,
maxRetries: 2,
modelName: model,
temperature,
maxTokens,
@@ -55,6 +55,7 @@ export const useConversation = () => {
configuration: {
baseURL: baseUrl || openai.baseUrl,
},
maxRetries: 2,
modelName: model,
temperature,
maxTokens,
@@ -69,6 +70,7 @@ export const useConversation = () => {
temperature,
frequencyPenalty,
presencePenalty,
maxRetries: 2,
});
} else if (conversation.engine === "googleGenerativeAi") {
if (!googleGenerativeAi) throw new Error("Google Generative AI API key is required");
@@ -78,6 +80,7 @@ export const useConversation = () => {
modelName: model,
temperature: temperature,
maxOutputTokens: maxTokens,
maxRetries: 2,
});
}
};