Sfoglia il codice sorgente

gpt-5 lower verbosity

Dax Raad 6 mesi fa
parent
commit
53630ebdce

File diff suppressed because it is too large
+ 5 - 12
bun.lock


+ 2 - 2
package.json

@@ -20,10 +20,10 @@
       "@hono/zod-validator": "0.4.2",
       "@types/node": "22.13.9",
       "@tsconfig/node22": "22.0.2",
-      "ai": "5.0.0-beta.34",
+      "ai": "5.0.8",
       "hono": "4.7.10",
       "typescript": "5.8.2",
-      "zod": "3.25.49",
+      "zod": "3.25.76",
       "remeda": "2.26.0"
     }
   },

+ 1 - 1
packages/opencode/src/global/index.ts

@@ -27,7 +27,7 @@ await Promise.all([
   fs.mkdir(Global.Path.log, { recursive: true }),
 ])
 
-const CACHE_VERSION = "4"
+const CACHE_VERSION = "5"
 
 const version = await Bun.file(path.join(Global.Path.cache, "version"))
   .text()

+ 15 - 15
packages/opencode/src/provider/provider.ts

@@ -97,7 +97,7 @@ export namespace Provider {
                     Array.isArray(msg.content) && msg.content.some((part: any) => part.type === "image_url"),
                 )
               }
-            } catch { }
+            } catch {}
             const headers: Record<string, string> = {
               ...init.headers,
               ...copilot.HEADERS,
@@ -283,26 +283,26 @@ export namespace Provider {
           cost:
             !model.cost && !existing?.cost
               ? {
-                input: 0,
-                output: 0,
-                cache_read: 0,
-                cache_write: 0,
-              }
+                  input: 0,
+                  output: 0,
+                  cache_read: 0,
+                  cache_write: 0,
+                }
               : {
-                cache_read: 0,
-                cache_write: 0,
-                ...existing?.cost,
-                ...model.cost,
-              },
+                  cache_read: 0,
+                  cache_write: 0,
+                  ...existing?.cost,
+                  ...model.cost,
+                },
           options: {
             ...existing?.options,
             ...model.options,
           },
           limit: model.limit ??
             existing?.limit ?? {
-            context: 0,
-            output: 0,
-          },
+              context: 0,
+              output: 0,
+            },
         }
         parsed.models[modelID] = parsedModel
       }
@@ -373,7 +373,7 @@ export namespace Provider {
       const existing = s.sdk.get(provider.id)
       if (existing) return existing
       const pkg = provider.npm ?? provider.id
-      const mod = await import(await BunProc.install(pkg, "beta"))
+      const mod = await import(await BunProc.install(pkg, "latest"))
       const fn = mod[Object.keys(mod).find((key) => key.startsWith("create"))!]
       const loaded = fn({
         name: provider.id,

+ 9 - 0
packages/opencode/src/provider/transform.ts

@@ -81,4 +81,13 @@ export namespace ProviderTransform {
     if (modelID.toLowerCase().includes("qwen")) return 1
     return undefined
   }
+
+  export function options(_providerID: string, modelID: string) {
+    if (modelID.includes("gpt-5")) {
+      return {
+        reasoningEffort: "low",
+        textVerbosity: "low",
+      }
+    }
+  }
 }

+ 14 - 9
packages/opencode/src/session/index.ts

@@ -322,9 +322,9 @@ export namespace Session {
       for (const child of await children(sessionID)) {
         await remove(child.id, false)
       }
-      await unshare(sessionID).catch(() => { })
-      await Storage.remove(`session/info/${sessionID}`).catch(() => { })
-      await Storage.removeDir(`session/message/${sessionID}/`).catch(() => { })
+      await unshare(sessionID).catch(() => {})
+      await Storage.remove(`session/info/${sessionID}`).catch(() => {})
+      await Storage.removeDir(`session/message/${sessionID}/`).catch(() => {})
       state().sessions.delete(sessionID)
       state().messages.delete(sessionID)
       if (emitEvent) {
@@ -523,7 +523,7 @@ export namespace Session {
                     sessionID: input.sessionID,
                     abort: new AbortController().signal,
                     messageID: userMsg.id,
-                    metadata: async () => { },
+                    metadata: async () => {},
                   }),
                 )
                 return [
@@ -632,7 +632,7 @@ export namespace Session {
 
     // mark session as updated
     // used for session list sorting (indicates when session was most recently interacted with)
-    await update(input.sessionID, (_draft) => { })
+    await update(input.sessionID, (_draft) => {})
 
     if (isLocked(input.sessionID)) {
       return new Promise((resolve) => {
@@ -679,7 +679,9 @@ export namespace Session {
       generateText({
         maxOutputTokens: small.info.reasoning ? 1024 : 20,
         providerOptions: {
-          [input.providerID]: small.info.options,
+          [input.providerID]: {
+            ...small.info.options,
+          },
         },
         messages: [
           ...SystemPrompt.title(input.providerID).map(
@@ -712,7 +714,7 @@ export namespace Session {
               draft.title = title.trim()
             })
         })
-        .catch(() => { })
+        .catch(() => {})
     }
 
     const agent = await Agent.get(inputAgent)
@@ -927,11 +929,14 @@ export namespace Session {
       },
       maxRetries: 3,
       activeTools: Object.keys(tools).filter((x) => x !== "invalid"),
-      maxOutputTokens: model.info.id.startsWith("gpt-5") ? undefined : outputLimit,
+      maxOutputTokens: outputLimit,
       abortSignal: abort.signal,
       stopWhen: stepCountIs(1000),
       providerOptions: {
-        [input.providerID]: model.info.options,
+        [input.providerID]: {
+          ...ProviderTransform.options(input.providerID, input.modelID),
+          ...model.info.options,
+        },
       },
       temperature: params.temperature,
       topP: params.topP,

Some files were not shown because too many files changed in this diff