mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-26 02:06:10 +01:00
🎨 Allow GPT Model selection in UI https://github.com/siyuan-note/siyuan/issues/8142
This commit is contained in:
parent
f6f3ebbcb2
commit
7daafcb3af
13 changed files with 63 additions and 19 deletions
|
|
@ -11,6 +11,19 @@ export const ai = {
|
|||
<input class="b3-text-field fn__flex-center fn__block" type="number" step="1" min="5" max="600" id="apiTimeout" value="${window.siyuan.config.ai.openAI.apiTimeout}"/>
|
||||
<div class="b3-label__text">${window.siyuan.languages.apiTimeoutTip}</div>
|
||||
</div>
|
||||
<div class="b3-label">
|
||||
${window.siyuan.languages.apiModel}
|
||||
<div class="b3-label__text">
|
||||
${window.siyuan.languages.apiModelTip}
|
||||
</div>
|
||||
<div class="b3-label__text fn__flex config__item" style="padding: 4px 0 4px 4px;">
|
||||
<select id="apiModel" class="b3-select">
|
||||
<option value="gpt-4" ${window.siyuan.config.ai.openAI.apiModel === "gpt-4" ? "selected" : ""}>gpt-4</option>
|
||||
<option value="gpt-4-32k" ${window.siyuan.config.ai.openAI.apiModel === "gpt-4-32k" ? "selected" : ""}>gpt-4-32k</option>
|
||||
<option value="gpt-3.5-turbo" ${window.siyuan.config.ai.openAI.apiModel === "gpt-3.5-turbo" ? "selected" : ""}>gpt-3.5-turbo</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="b3-label">
|
||||
${window.siyuan.languages.apiMaxTokens}
|
||||
<div class="fn__hr"></div>
|
||||
|
|
@ -44,6 +57,18 @@ export const ai = {
|
|||
<span class="fn__space"></span>
|
||||
<input class="b3-text-field fn__flex-center fn__size200" type="number" step="1" min="5" max="600" id="apiTimeout" value="${window.siyuan.config.ai.openAI.apiTimeout}"/>
|
||||
</label>
|
||||
<label class="fn__flex b3-label config__item">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.apiModel}
|
||||
<div class="b3-label__text">${window.siyuan.languages.apiModelTip}</div>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<select id="apiModel" class="b3-select fn__flex-center fn__size200">
|
||||
<option value="gpt-4" ${window.siyuan.config.ai.openAI.apiModel === "gpt-4" ? "selected" : ""}>gpt-4</option>
|
||||
<option value="gpt-4-32k" ${window.siyuan.config.ai.openAI.apiModel === "gpt-4-32k" ? "selected" : ""}>gpt-4-32k</option>
|
||||
<option value="gpt-3.5-turbo" ${window.siyuan.config.ai.openAI.apiModel === "gpt-3.5-turbo" ? "selected" : ""}>gpt-3.5-turbo</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="fn__flex b3-label">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.apiMaxTokens}
|
||||
|
|
@ -89,12 +114,13 @@ export const ai = {
|
|||
</div>`;
|
||||
},
|
||||
bindEvent: () => {
|
||||
ai.element.querySelectorAll("input").forEach((item) => {
|
||||
ai.element.querySelectorAll("input,select").forEach((item) => {
|
||||
item.addEventListener("change", () => {
|
||||
fetchPost("/api/setting/setAI", {
|
||||
openAI: {
|
||||
apiBaseURL: (ai.element.querySelector("#apiBaseURL") as HTMLInputElement).value,
|
||||
apiKey: (ai.element.querySelector("#apiKey") as HTMLInputElement).value,
|
||||
apiModel: (ai.element.querySelector("#apiModel") as HTMLSelectElement).value,
|
||||
apiMaxTokens: parseInt((ai.element.querySelector("#apiMaxTokens") as HTMLInputElement).value),
|
||||
apiProxy: (ai.element.querySelector("#apiProxy") as HTMLInputElement).value,
|
||||
apiTimeout: parseInt((ai.element.querySelector("#apiTimeout") as HTMLInputElement).value),
|
||||
|
|
|
|||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -424,6 +424,7 @@ declare interface IConfig {
|
|||
openAI: {
|
||||
apiBaseURL: string
|
||||
apiKey: string
|
||||
apiModel: string
|
||||
apiMaxTokens: number
|
||||
apiProxy: string
|
||||
apiTimeout: number
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue