Skip to content

Commit bc6216c

Browse files
danny-avilaMichielMAnalytics
authored andcommitted
✨ feat: Add OpenAI Verbosity Parameter (danny-avila#8929)
* WIP: Verbosity OpenAI Parameter * 🔧 chore: remove unused import of extractEnvVariable from parsers.ts * ✨ feat: add comprehensive tests for getOpenAIConfig and enhance verbosity handling * fix: Handling for maxTokens in GPT-5+ models and add corresponding tests * feat: Implement GPT-5+ model handling in processMemory function
1 parent 876e254 commit bc6216c

14 files changed

Lines changed: 2109 additions & 10 deletions

File tree

api/server/controllers/agents/client.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,26 @@ class AgentClient extends BaseClient {
979979
if (/\b(o\d)\b/i.test(clientOptions.model) && clientOptions.maxTokens != null) {
980980
delete clientOptions.maxTokens;
981981
}
982+
983+
if (/\bgpt-[5-9]\b/i.test(clientOptions.model) && clientOptions.maxTokens != null) {
984+
clientOptions.modelKwargs = clientOptions.modelKwargs ?? {};
985+
clientOptions.modelKwargs.max_completion_tokens = clientOptions.maxTokens;
986+
delete clientOptions.maxTokens;
987+
}
988+
989+
clientOptions = Object.assign(
990+
Object.fromEntries(
991+
Object.entries(clientOptions).filter(([key]) => !omitTitleOptions.has(key)),
992+
),
993+
);
994+
995+
if (
996+
provider === Providers.GOOGLE &&
997+
(endpointConfig?.titleMethod === TitleMethod.FUNCTIONS ||
998+
endpointConfig?.titleMethod === TitleMethod.STRUCTURED)
999+
) {
1000+
clientOptions.json = true;
1001+
}
9821002
try {
9831003
const titleResult = await this.run.generateTitle({
9841004
inputText: text,

0 commit comments

Comments
 (0)