فهرست منبع

make top_p configurable

Dax Raad 6 ماه پیش
والد
کامیت
e1b7e25f4d

+ 1 - 0
packages/opencode/src/config/config.ts

@@ -144,6 +144,7 @@ export namespace Config {
     .object({
       model: z.string().optional(),
       temperature: z.number().optional(),
+      top_p: z.number().optional(),
       prompt: z.string().optional(),
       tools: z.record(z.string(), z.boolean()).optional(),
       disable: z.boolean().optional(),

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

@@ -50,4 +50,9 @@ export namespace ProviderTransform {
     if (modelID.toLowerCase().includes("qwen")) return 0.55
     return 0
   }
+
+  export function topP(_providerID: string, modelID: string) {
+    if (modelID.toLowerCase().includes("qwen")) return 1
+    return undefined
+  }
 }

+ 1 - 0
packages/opencode/src/session/index.ts

@@ -847,6 +847,7 @@ export namespace Session {
       temperature: model.info.temperature
         ? (mode.temperature ?? ProviderTransform.temperature(input.providerID, input.modelID))
         : undefined,
+      topP: mode.topP ?? ProviderTransform.topP(input.providerID, input.modelID),
       tools: model.info.tool_call === false ? undefined : tools,
       model: wrapLanguageModel({
         model: model.language,

+ 3 - 1
packages/opencode/src/session/mode.ts

@@ -8,6 +8,7 @@ export namespace Mode {
     .object({
       name: z.string(),
       temperature: z.number().optional(),
+      topP: z.number().optional(),
       model: z
         .object({
           modelID: z.string(),
@@ -51,7 +52,8 @@ export namespace Mode {
       item.name = key
       if (value.model) item.model = Provider.parseModel(value.model)
       if (value.prompt) item.prompt = value.prompt
-      if (value.temperature) item.temperature = value.temperature
+      if (value.temperature != undefined) item.temperature = value.temperature
+      if (value.top_p != undefined) item.topP = value.top_p
       if (value.tools)
         item.tools = {
           ...value.tools,

+ 1 - 0
packages/web/astro.config.mjs

@@ -84,6 +84,7 @@ export default defineConfig({
             "docs/permissions",
             "docs/mcp-servers",
             "docs/formatters",
+            "docs/lsp",
           ],
         },
       ],

+ 0 - 34
packages/web/src/content/docs/docs/lsp-servers.mdx

@@ -1,34 +0,0 @@
----
-title: LSP servers
----
-
-opencode integrates with _Language Server Protocol_, or LSP to improve how the LLM interacts with your codebase.
-
-LSP servers for different languages give the LLM:
-
-- **Diagnostics**: These include things like errors and lint warnings. So the LLM can generate code that has fewer mistakes without having to run the code.
-- **Quick actions**: The LSP can allow the LLM to better navigate the codebase through features like _go-to-definition_ and _find references_.
-
-## Auto-detection
-
-By default, opencode will **automatically detect** the languages used in your project and add the right LSP servers.
-
-## Manual configuration
-
-You can also manually configure LSP servers by adding them under the `lsp` section in your opencode config.
-
-```json title="opencode.json"
-{
-  "lsp": {
-    "go": {
-      "disabled": false,
-      "command": "gopls"
-    },
-    "typescript": {
-      "disabled": false,
-      "command": "typescript-language-server",
-      "args": ["--stdio"]
-    }
-  }
-}
-```