thepopebot 1.2.74-beta.52 → 1.2.74-beta.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/ai/model.js
CHANGED
|
@@ -33,11 +33,13 @@ export async function createModel(options = {}) {
|
|
|
33
33
|
return new ChatOpenAI(config);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
const LLM_NOT_CONFIGURED = 'No chat LLM configured — set one up in Admin > Event Handler > LLMs';
|
|
37
|
+
|
|
36
38
|
switch (provider) {
|
|
37
39
|
case 'anthropic': {
|
|
38
40
|
const apiKey = getConfig('ANTHROPIC_API_KEY');
|
|
39
41
|
if (!apiKey) {
|
|
40
|
-
throw new Error(
|
|
42
|
+
throw new Error(LLM_NOT_CONFIGURED);
|
|
41
43
|
}
|
|
42
44
|
return new ChatAnthropic({
|
|
43
45
|
modelName,
|
|
@@ -50,7 +52,7 @@ export async function createModel(options = {}) {
|
|
|
50
52
|
const apiKey = getConfig('OPENAI_API_KEY');
|
|
51
53
|
const baseURL = getConfig('CUSTOM_OPENAI_BASE_URL');
|
|
52
54
|
if (!apiKey && !baseURL) {
|
|
53
|
-
throw new Error(
|
|
55
|
+
throw new Error(LLM_NOT_CONFIGURED);
|
|
54
56
|
}
|
|
55
57
|
const config = { modelName, maxTokens };
|
|
56
58
|
config.apiKey = apiKey || 'not-needed';
|
|
@@ -63,7 +65,7 @@ export async function createModel(options = {}) {
|
|
|
63
65
|
const { ChatGoogleGenerativeAI } = await import('@langchain/google-genai');
|
|
64
66
|
const apiKey = getConfig('GOOGLE_API_KEY');
|
|
65
67
|
if (!apiKey) {
|
|
66
|
-
throw new Error(
|
|
68
|
+
throw new Error(LLM_NOT_CONFIGURED);
|
|
67
69
|
}
|
|
68
70
|
let resolvedModel = modelName;
|
|
69
71
|
const isUnsupported = GEMINI_UNSUPPORTED_MODELS.some(m => resolvedModel.startsWith(m));
|
|
@@ -83,37 +85,37 @@ export async function createModel(options = {}) {
|
|
|
83
85
|
case 'deepseek': {
|
|
84
86
|
const { ChatOpenAI } = await import('@langchain/openai');
|
|
85
87
|
const apiKey = getConfig('DEEPSEEK_API_KEY');
|
|
86
|
-
if (!apiKey) throw new Error(
|
|
88
|
+
if (!apiKey) throw new Error(LLM_NOT_CONFIGURED);
|
|
87
89
|
return new ChatOpenAI({ modelName, maxTokens, apiKey, configuration: { baseURL: 'https://api.deepseek.com' } });
|
|
88
90
|
}
|
|
89
91
|
case 'minimax': {
|
|
90
92
|
const { ChatOpenAI } = await import('@langchain/openai');
|
|
91
93
|
const apiKey = getConfig('MINIMAX_API_KEY');
|
|
92
|
-
if (!apiKey) throw new Error(
|
|
94
|
+
if (!apiKey) throw new Error(LLM_NOT_CONFIGURED);
|
|
93
95
|
return new ChatOpenAI({ modelName, maxTokens, apiKey, configuration: { baseURL: 'https://api.minimax.io/v1' } });
|
|
94
96
|
}
|
|
95
97
|
case 'mistral': {
|
|
96
98
|
const { ChatOpenAI } = await import('@langchain/openai');
|
|
97
99
|
const apiKey = getConfig('MISTRAL_API_KEY');
|
|
98
|
-
if (!apiKey) throw new Error(
|
|
100
|
+
if (!apiKey) throw new Error(LLM_NOT_CONFIGURED);
|
|
99
101
|
return new ChatOpenAI({ modelName, maxTokens, apiKey, configuration: { baseURL: 'https://api.mistral.ai/v1' } });
|
|
100
102
|
}
|
|
101
103
|
case 'xai': {
|
|
102
104
|
const { ChatOpenAI } = await import('@langchain/openai');
|
|
103
105
|
const apiKey = getConfig('XAI_API_KEY');
|
|
104
|
-
if (!apiKey) throw new Error(
|
|
106
|
+
if (!apiKey) throw new Error(LLM_NOT_CONFIGURED);
|
|
105
107
|
return new ChatOpenAI({ modelName, maxTokens, apiKey, configuration: { baseURL: 'https://api.x.ai/v1' } });
|
|
106
108
|
}
|
|
107
109
|
case 'kimi': {
|
|
108
110
|
const { ChatOpenAI } = await import('@langchain/openai');
|
|
109
111
|
const apiKey = getConfig('MOONSHOT_API_KEY');
|
|
110
|
-
if (!apiKey) throw new Error(
|
|
112
|
+
if (!apiKey) throw new Error(LLM_NOT_CONFIGURED);
|
|
111
113
|
return new ChatOpenAI({ modelName, maxTokens, apiKey, configuration: { baseURL: 'https://api.moonshot.cn/v1' } });
|
|
112
114
|
}
|
|
113
115
|
case 'openrouter': {
|
|
114
116
|
const { ChatOpenAI } = await import('@langchain/openai');
|
|
115
117
|
const apiKey = getConfig('OPENROUTER_API_KEY');
|
|
116
|
-
if (!apiKey) throw new Error(
|
|
118
|
+
if (!apiKey) throw new Error(LLM_NOT_CONFIGURED);
|
|
117
119
|
return new ChatOpenAI({ modelName, maxTokens, apiKey, configuration: { baseURL: 'https://openrouter.ai/api/v1' } });
|
|
118
120
|
}
|
|
119
121
|
default:
|
|
@@ -209,7 +209,7 @@ function Chat({ chatId, initialMessages = [], workspace = null, chatMode = null
|
|
|
209
209
|
/* @__PURE__ */ jsx(ChatHeader, { chatId }),
|
|
210
210
|
messages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center justify-center px-2.5 md:px-6", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-4xl", children: [
|
|
211
211
|
/* @__PURE__ */ jsx(Greeting, { codeMode }),
|
|
212
|
-
error && /* @__PURE__ */ jsx("div", { className: "mt-4 rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-2 text-sm text-destructive", children: error.message || "Something went wrong. Please try again." }),
|
|
212
|
+
error && /* @__PURE__ */ jsx("div", { className: "mt-4 mb-4 rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-2 text-sm text-destructive", children: error.message || "Something went wrong. Please try again." }),
|
|
213
213
|
/* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
|
|
214
214
|
ChatInput,
|
|
215
215
|
{
|
|
@@ -257,7 +257,7 @@ export function Chat({ chatId, initialMessages = [], workspace = null, chatMode
|
|
|
257
257
|
<div className="w-full max-w-4xl">
|
|
258
258
|
<Greeting codeMode={codeMode} />
|
|
259
259
|
{error && (
|
|
260
|
-
<div className="mt-4 rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-2 text-sm text-destructive">
|
|
260
|
+
<div className="mt-4 mb-4 rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-2 text-sm text-destructive">
|
|
261
261
|
{error.message || 'Something went wrong. Please try again.'}
|
|
262
262
|
</div>
|
|
263
263
|
)}
|