给ollama增加system message

This commit is contained in:
mcz
2024-09-30 16:41:58 +08:00
parent 37facdc3c1
commit 71f90b36ca
3 changed files with 34 additions and 4 deletions

View File

@@ -320,7 +320,7 @@ const genClaude = ({
return [url, init]; return [url, init];
}; };
const genOllama = ({ text, from, to, url, key, prompt, model }) => { const genOllama = ({ text, from, to, url, key, system,prompt, model }) => {
prompt = prompt prompt = prompt
.replaceAll(INPUT_PLACE_FROM, from) .replaceAll(INPUT_PLACE_FROM, from)
.replaceAll(INPUT_PLACE_TO, to) .replaceAll(INPUT_PLACE_TO, to)
@@ -328,6 +328,7 @@ const genOllama = ({ text, from, to, url, key, prompt, model }) => {
const data = { const data = {
model, model,
system,
prompt, prompt,
stream: false, stream: false,
}; };

View File

@@ -537,8 +537,9 @@ const defaultOpenaiApi = {
const defaultOllamaApi = { const defaultOllamaApi = {
url: "http://localhost:11434/api/generate", url: "http://localhost:11434/api/generate",
key: "", key: "",
model: "llama3", model: "llama3.1",
prompt: `Translate the following text from ${INPUT_PLACE_FROM} to ${INPUT_PLACE_TO}:\n\n${INPUT_PLACE_TEXT}`, system:"You are a professional, authentic machine translation engine.",
prompt: `Translate the following text from ${INPUT_PLACE_FROM} to ${INPUT_PLACE_TO},output translation directly without any additional text:\n\n${INPUT_PLACE_TEXT}`,
fetchLimit: 1, fetchLimit: 1,
fetchInterval: 500, fetchInterval: 500,
}; };

View File

@@ -115,6 +115,7 @@ function ApiFields({ translator }) {
url = "", url = "",
key = "", key = "",
model = "", model = "",
system = "",
prompt = "", prompt = "",
systemPrompt = "", systemPrompt = "",
fetchLimit = DEFAULT_FETCH_LIMIT, fetchLimit = DEFAULT_FETCH_LIMIT,
@@ -214,7 +215,6 @@ function ApiFields({ translator }) {
)} )}
{(translator.startsWith(OPT_TRANS_OPENAI) || {(translator.startsWith(OPT_TRANS_OPENAI) ||
translator.startsWith(OPT_TRANS_OLLAMA) ||
translator === OPT_TRANS_CLAUDE || translator === OPT_TRANS_CLAUDE ||
translator === OPT_TRANS_GEMINI) && ( translator === OPT_TRANS_GEMINI) && (
<> <>
@@ -236,6 +236,34 @@ function ApiFields({ translator }) {
/> />
</> </>
)} )}
{(translator.startsWith(OPT_TRANS_OLLAMA)) && (
<>
<TextField
size="small"
label={"MODEL"}
name="model"
value={model}
onChange={handleChange}
/>
<TextField
size="small"
label={"SYSTEM MESSAGE"}
name="system"
value={system}
onChange={handleChange}
/>
<TextField
size="small"
label={"PROMPT"}
name="prompt"
value={prompt}
onChange={handleChange}
multiline
maxRows={10}
/>
</>
)}
{(translator.startsWith(OPT_TRANS_OPENAI) || {(translator.startsWith(OPT_TRANS_OPENAI) ||
translator === OPT_TRANS_CLAUDE) && ( translator === OPT_TRANS_CLAUDE) && (