Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
87 lines (79 loc) · 2.52 KB
/
Copy pathindex.js
File metadata and controls
87 lines (79 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const PROVIDER_ID = "bharatcode"
const MODEL_ID = "bharatcode:qwen36-35b-q6-256k-vision"
const LEGACY_MODEL_ID = "bharatcode:qwen36-35b-q8-256k"
const MODEL = `${PROVIDER_ID}/${MODEL_ID}`
function explicitApiKey(options) {
return (
options?.apiKey ||
process.env.BHARATCODE_API_KEY ||
process.env.OPENCODE_BHARATCODE_API_KEY ||
undefined
)
}
export const BharatCodePlugin = async (_ctx, options = {}) => {
return {
config: async (config) => {
const key = explicitApiKey(options)
const providerOptions = {
baseURL: options.baseURL || "https://bharatcode.kaabil.me/v1",
timeout: options.timeout ?? 1800000,
chunkTimeout: options.chunkTimeout ?? 180000,
}
if (key) providerOptions.apiKey = key
config.model = options.model || MODEL
config.small_model = options.small_model || MODEL
config.compaction = {
...(config.compaction || {}),
auto: options.autoCompaction ?? false,
}
config.agent = config.agent || {}
for (const name of ["build", "plan"]) {
config.agent[name] = {
...(config.agent[name] || {}),
model: MODEL,
temperature: options.temperature ?? 0.6,
top_p: options.topP ?? 0.95,
steps: options.steps ?? 16,
}
}
for (const name of ["title", "compaction"]) {
config.agent[name] = {
...(config.agent[name] || {}),
model: MODEL,
temperature: options.temperature ?? 0.6,
top_p: options.topP ?? 0.95,
steps: options.smallSteps ?? 3,
}
}
config.provider = config.provider || {}
config.provider[PROVIDER_ID] = {
npm: "@ai-sdk/openai-compatible",
name: "BharatCode A100 llama.cpp",
options: providerOptions,
models: {
[MODEL_ID]: {
name: "BharatCode Qwen3.6 35B-A3B Q6_K 256K Vision Thinking",
reasoning: true,
temperature: true,
tool_call: true,
limit: {
context: options.context ?? 262144,
output: options.output ?? 32768,
},
},
[LEGACY_MODEL_ID]: {
name: "BharatCode legacy Q8 model id compatibility alias",
reasoning: true,
temperature: true,
tool_call: true,
limit: {
context: options.context ?? 262144,
output: options.output ?? 32768,
},
},
},
}
},
}
}
export default BharatCodePlugin