mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 18:24:21 +01:00
make top_p configurable
This commit is contained in:
@@ -144,6 +144,7 @@ export namespace Config {
|
|||||||
.object({
|
.object({
|
||||||
model: z.string().optional(),
|
model: z.string().optional(),
|
||||||
temperature: z.number().optional(),
|
temperature: z.number().optional(),
|
||||||
|
top_p: z.number().optional(),
|
||||||
prompt: z.string().optional(),
|
prompt: z.string().optional(),
|
||||||
tools: z.record(z.string(), z.boolean()).optional(),
|
tools: z.record(z.string(), z.boolean()).optional(),
|
||||||
disable: z.boolean().optional(),
|
disable: z.boolean().optional(),
|
||||||
|
|||||||
@@ -50,4 +50,9 @@ export namespace ProviderTransform {
|
|||||||
if (modelID.toLowerCase().includes("qwen")) return 0.55
|
if (modelID.toLowerCase().includes("qwen")) return 0.55
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function topP(_providerID: string, modelID: string) {
|
||||||
|
if (modelID.toLowerCase().includes("qwen")) return 1
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -847,6 +847,7 @@ export namespace Session {
|
|||||||
temperature: model.info.temperature
|
temperature: model.info.temperature
|
||||||
? (mode.temperature ?? ProviderTransform.temperature(input.providerID, input.modelID))
|
? (mode.temperature ?? ProviderTransform.temperature(input.providerID, input.modelID))
|
||||||
: undefined,
|
: undefined,
|
||||||
|
topP: mode.topP ?? ProviderTransform.topP(input.providerID, input.modelID),
|
||||||
tools: model.info.tool_call === false ? undefined : tools,
|
tools: model.info.tool_call === false ? undefined : tools,
|
||||||
model: wrapLanguageModel({
|
model: wrapLanguageModel({
|
||||||
model: model.language,
|
model: model.language,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export namespace Mode {
|
|||||||
.object({
|
.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
temperature: z.number().optional(),
|
temperature: z.number().optional(),
|
||||||
|
topP: z.number().optional(),
|
||||||
model: z
|
model: z
|
||||||
.object({
|
.object({
|
||||||
modelID: z.string(),
|
modelID: z.string(),
|
||||||
@@ -51,7 +52,8 @@ export namespace Mode {
|
|||||||
item.name = key
|
item.name = key
|
||||||
if (value.model) item.model = Provider.parseModel(value.model)
|
if (value.model) item.model = Provider.parseModel(value.model)
|
||||||
if (value.prompt) item.prompt = value.prompt
|
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)
|
if (value.tools)
|
||||||
item.tools = {
|
item.tools = {
|
||||||
...value.tools,
|
...value.tools,
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ export default defineConfig({
|
|||||||
"docs/permissions",
|
"docs/permissions",
|
||||||
"docs/mcp-servers",
|
"docs/mcp-servers",
|
||||||
"docs/formatters",
|
"docs/formatters",
|
||||||
|
"docs/lsp",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -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"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
Reference in New Issue
Block a user