1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-04-06 10:46:57 +00:00

feat: allow config default server and model

This commit is contained in:
lin onetwo 2025-03-01 18:45:10 +08:00
parent 309bd70dc3
commit 3030595df5
6 changed files with 30 additions and 18 deletions

View File

@ -2,7 +2,10 @@ title: $:/plugins/tiddlywiki/ai-tools/globals
tags: $:/tags/Global
\function ai-tools-default-llm-completion-server()
[all[shadows+tiddlers]tag[$:/tags/AI/CompletionServer]sort[caption]first[]]
[[$:/plugins/tiddlywiki/ai-tools/configs/default-server]get[completion-server]]
\end
\function ai-tools-default-llm-completion-model()
[[$:/plugins/tiddlywiki/ai-tools/configs/default-server]get[completion-model]]
\end
<!--
@ -119,21 +122,6 @@ Procedure to display a message from an AI conversation. Current tiddler is the c
Action procedure to get the next response from the LLM on a chat tiddler.
-->
\procedure ai-tools-action-get-response()
<!-- Assign a server and model on tiddler if user forget to pick one. -->
<% if [<currentTiddler>!has[completion-server]] %>
<$action-setfield
$tiddler=<<currentTiddler>>
$field="completion-server"
$value={{{[all[shadows+tiddlers]tag[$:/tags/AI/CompletionServer]sort[caption]first[]]}}}
/>
<% endif %>
<% if [<currentTiddler>!has[completion-model]] %>
<$action-setfield
$tiddler=<<currentTiddler>>
$field="completion-model"
$value={{{[{!!completion-server}get[models]enlist-input[]first[]]}}}
/>
<% endif %>
<!-- Get the response -->
<$let
resultTitlePrefix={{{ [<currentTiddler>addsuffix[ - Prompt]] }}}
@ -173,10 +161,15 @@ Action procedure to get the next response from the LLM on a chat tiddler.
</$list>
</$select>
Model: <$select tiddler=<<currentTiddler>> field="completion-model" default=<<ai-tools-default-llm-completion-model>>>
<$list filter="[{!!completion-server}get[models]enlist-input[]]">
<$list filter="[<ai-tools-default-llm-completion-server>get[models]enlist-input[]]">
<option value=<<currentTiddler>>><<currentTiddler>></option>
</$list>
</$select>
<$list filter="[<ai-tools-default-llm-completion-server>get[settings]]">
<$button to=<<currentTiddler>> class="tc-btn-invisible">
{{$:/core/images/options-button}}
</$button>
</$list>
<div class="ai-conversation">
<$transclude

View File

@ -5,3 +5,4 @@ caption: DeepSeek
auth-token-store-key: deepseek-secret-key
models: deepseek-chat deepseek-reasoner
extends: $:/plugins/tiddlywiki/ai-tools/servers/openai
settings: $:/plugins/tiddlywiki/ai-tools/settings/deepseek

View File

@ -2,6 +2,7 @@ title: $:/plugins/tiddlywiki/ai-tools/servers/llamafile-llava
tags: $:/tags/AI/CompletionServer
url: http://127.0.0.1:8080/completion
caption: Local Llamafile server running LLaVA models
settings: $:/plugins/tiddlywiki/ai-tools/settings/llamafile
<!--
Wikified JSON text to be sent to server

View File

@ -4,6 +4,7 @@ url: https://api.openai.com/v1/chat/completions
auth-token-store-key: openai-secret-key
caption: OpenAI Service
models: gpt-4o gpt-4.5-preview gpt-4o-mini o1 o1-mini o3-mini
settings: $:/plugins/tiddlywiki/ai-tools/settings/openai
<!--
Wikified JSON text to be sent to server

View File

@ -5,3 +5,4 @@ caption: SiliconFlow
auth-token-store-key: siliconflow-secret-key
models: deepseek-ai/DeepSeek-V3 deepseek-ai/DeepSeek-R1
extends: $:/plugins/tiddlywiki/ai-tools/servers/openai
settings: $:/plugins/tiddlywiki/ai-tools/settings/siliconflow

View File

@ -5,4 +5,19 @@ These settings let you customise the behaviour of the "AI Tools" plugin.
!! Completion Servers
<<tabs "[all[shadows+tiddlers]tag[$:/tags/AI/ServerSetting]]">>
Default Server: <$select tiddler="$:/plugins/tiddlywiki/ai-tools/configs/default-server" field="completion-server">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/AI/CompletionServer]sort[caption]]">
<option value=<<currentTiddler>>><$view field='caption'/></option>
</$list>
</$select>
Default Model: <$select tiddler="$:/plugins/tiddlywiki/ai-tools/configs/default-server" field="completion-model">
<$list filter="[{$:/plugins/tiddlywiki/ai-tools/configs/default-server!!completion-server}get[models]enlist-input[]]">
<option value=<<currentTiddler>>><<currentTiddler>></option>
</$list>
</$select>
<$transclude
$variable="tabs"
tabsList="[all[shadows+tiddlers]tag[$:/tags/AI/ServerSetting]]"
default={{{[{$:/plugins/tiddlywiki/ai-tools/configs/default-server!!completion-server}get[settings]]}}}
/>