Skip to content

Commit

Permalink
fix: prompt插入位置错误BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Jul 31, 2024
1 parent de66f3b commit 9d65a4a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dist/buildinfo.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"sha": "9f0740b", "timestamp": 1722404014}
{"sha": "de66f3b", "timestamp": 1722427564}
14 changes: 7 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ var Environment = class {
// -- 版本数据 --
//
// 当前版本
BUILD_TIMESTAMP = 1722404014;
BUILD_TIMESTAMP = 1722427564;
// 当前版本 commit id
BUILD_VERSION = "9f0740b";
BUILD_VERSION = "de66f3b";
// -- 基础配置 --
/**
* @type {I18n | null}
Expand Down Expand Up @@ -1034,7 +1034,7 @@ async function requestCompletionsFromOpenAI(message, prompt, history, context, o
const url = `${context.USER_CONFIG.OPENAI_API_BASE}/chat/completions`;
const messages = [...history || [], { role: "user", content: message }];
if (prompt) {
messages.push({ role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt });
messages.unshift({ role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt });
}
const body = {
model: context.USER_CONFIG.OPENAI_CHAT_MODEL,
Expand Down Expand Up @@ -1099,7 +1099,7 @@ async function requestCompletionsFromWorkersAI(message, prompt, history, context
};
const messages = [...history || [], { role: "user", content: message }];
if (prompt) {
messages.push({ role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt });
messages.unshift({ role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt });
}
const body = {
messages,
Expand Down Expand Up @@ -1133,7 +1133,7 @@ async function requestCompletionsFromGeminiAI(message, prompt, history, context,
const url = `${context.USER_CONFIG.GOOGLE_COMPLETIONS_API}${context.USER_CONFIG.GOOGLE_COMPLETIONS_MODEL}:${onStream ? "streamGenerateContent" : "generateContent"}?key=${context.USER_CONFIG.GOOGLE_API_KEY}`;
const contentsTemp = [...history || [], { role: "user", content: message }];
if (prompt) {
contentsTemp.push({ role: "assistant", content: prompt });
contentsTemp.unshift({ role: "assistant", content: prompt });
}
const contents = [];
const rolMap = {
Expand Down Expand Up @@ -1183,7 +1183,7 @@ async function requestCompletionsFromMistralAI(message, prompt, history, context
const url = `${context.USER_CONFIG.MISTRAL_API_BASE}/chat/completions`;
const messages = [...history || [], { role: "user", content: message }];
if (prompt) {
messages.push({ role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt });
messages.unshift({ role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt });
}
const body = {
model: context.USER_CONFIG.MISTRAL_CHAT_MODEL,
Expand Down Expand Up @@ -1294,7 +1294,7 @@ async function requestCompletionsFromAzureOpenAI(message, prompt, history, conte
const url = context.USER_CONFIG.AZURE_COMPLETIONS_API;
const messages = [...history || [], { role: "user", content: message }];
if (prompt) {
messages.push({ role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt });
messages.unshift({ role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt });
}
const body = {
...context.USER_CONFIG.OPENAI_API_EXTRA_PARAMS,
Expand Down
2 changes: 1 addition & 1 deletion dist/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1722404014
1722427564
2 changes: 1 addition & 1 deletion src/agent/azure.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function requestCompletionsFromAzureOpenAI(message, prompt, history

const messages = [...(history || []), {role: 'user', content: message}];
if (prompt) {
messages.push({role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt});
messages.unshift({role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt});
}
const body = {
...context.USER_CONFIG.OPENAI_API_EXTRA_PARAMS,
Expand Down
2 changes: 1 addition & 1 deletion src/agent/gemini.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function requestCompletionsFromGeminiAI(message, prompt, history, c

const contentsTemp = [...history || [], {role: 'user', content: message}];
if (prompt) {
contentsTemp.push({role: 'assistant', content: prompt});
contentsTemp.unshift({role: 'assistant', content: prompt});
}
const contents = [];
const rolMap = {
Expand Down
2 changes: 1 addition & 1 deletion src/agent/mistralai.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function requestCompletionsFromMistralAI(message, prompt, history,
const url = `${context.USER_CONFIG.MISTRAL_API_BASE}/chat/completions`;
const messages = [...(history || []), {role: 'user', content: message}];
if (prompt) {
messages.push({role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt});
messages.unshift({role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt});
}
const body = {
model: context.USER_CONFIG.MISTRAL_CHAT_MODEL,
Expand Down
2 changes: 1 addition & 1 deletion src/agent/openai.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function requestCompletionsFromOpenAI(message, prompt, history, con
const url = `${context.USER_CONFIG.OPENAI_API_BASE}/chat/completions`;
const messages = [...(history || []), {role: 'user', content: message}];
if (prompt) {
messages.push({role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt});
messages.unshift({role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt});
}
const body = {
model: context.USER_CONFIG.OPENAI_CHAT_MODEL,
Expand Down
2 changes: 1 addition & 1 deletion src/agent/workersai.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function requestCompletionsFromWorkersAI(message, prompt, history,
};
const messages = [...(history || []), {role: 'user', content: message}];
if (prompt) {
messages.push({role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt});
messages.unshift({role: context.USER_CONFIG.SYSTEM_INIT_MESSAGE_ROLE, content: prompt});
}
const body = {
messages: messages,
Expand Down

0 comments on commit 9d65a4a

Please sign in to comment.