Commit d17a2c8
committed
refactor(provider): tighten a handful of helpers
Five small simplifications, no behaviour change. All touched functions remain at 100% line coverage and overall package coverage nudges from 96.9% to 98.2%.
* mergeCloneOptions: apply every Opt to a single ModelOptions accumulator and read the final effective MaxTokens / NoThinking once, instead of allocating a fresh tempOpts per option and re-checking inside the loop. Later-opt-wins semantics are now an obvious property of the accumulator rather than a property of "the last loop iteration that set the field".
* resolveEffectiveProvider: replace the if/else fallback to "openai" with cmp.Or(cfg.Provider, "openai").
* isOpenAICompatibleProvider: drop the default: arm so that the alias fallthrough sits at function scope, removing one indentation level and a redundant return false.
* resolveProviderType: drop the cfg.ProviderOpts != nil guard. Reading from a nil map is well-defined and yields the zero value, which the existing type-assertion already handles.
* mergeFromProviderConfig: reuse setProviderOptIfAbsent for the ProviderOpts merge loop instead of inlining the lazy-init + has-key dance, which already exists in that helper.
Assisted-By: docker-agent1 parent 304f4e8 commit d17a2c8
2 files changed
Lines changed: 20 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
49 | 48 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 49 | + | |
58 | 50 | | |
59 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
60 | 59 | | |
61 | 60 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
17 | 19 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 32 | + | |
36 | 33 | | |
37 | 34 | | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
50 | 44 | | |
51 | 45 | | |
52 | 46 | | |
| |||
114 | 108 | | |
115 | 109 | | |
116 | 110 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
| 111 | + | |
123 | 112 | | |
124 | 113 | | |
125 | 114 | | |
| |||
0 commit comments