θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ AnythingLLM divides your documents into objects called `workspaces`. A Workspace
- [xAI](https://x.ai/)
- [Novita AI (chat models)](https://novita.ai/model-api/product/llm-api?utm_source=github_anything-llm&utm_medium=github_readme&utm_campaign=link)
- [PPIO](https://ppinfra.com?utm_source=github_anything-llm)
- [Moonshot AI](https://www.moonshot.ai/)

**Embedder models:**

Expand Down
4 changes: 4 additions & 0 deletions docker/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ GID='1000'
# PPIO_API_KEY='your-ppio-api-key-here'
# PPIO_MODEL_PREF=deepseek/deepseek-v3/community

# LLM_PROVIDER='moonshotai'
# MOONSHOT_AI_API_KEY='your-moonshot-api-key-here'
# MOONSHOT_AI_MODEL_PREF='moonshot-v1-32k'

###########################################
######## Embedding API SElECTION ##########
###########################################
Expand Down
117 changes: 117 additions & 0 deletions frontend/src/components/LLMSelection/MoonshotAiOptions/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { useState, useEffect } from "react";
import System from "@/models/system";

export default function MoonshotAiOptions({ settings }) {
const [inputValue, setInputValue] = useState(settings?.MoonshotAiApiKey);
const [moonshotAiKey, setMoonshotAiKey] = useState(
settings?.MoonshotAiApiKey
);

return (
<div className="flex gap-[36px] mt-1.5">
<div className="flex flex-col w-60">
<label className="text-white text-sm font-semibold block mb-3">
API Key
</label>
<input
type="password"
name="MoonshotAiApiKey"
className="border-none bg-theme-settings-input-bg text-white placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"
placeholder="Moonshot AI API Key"
defaultValue={settings?.MoonshotAiApiKey ? "*".repeat(20) : ""}
required={true}
autoComplete="off"
spellCheck={false}
onChange={(e) => setInputValue(e.target.value)}
onBlur={() => setMoonshotAiKey(inputValue)}
/>
</div>
{!settings?.credentialsOnly && (
<MoonshotAiModelSelection settings={settings} apiKey={moonshotAiKey} />
)}
</div>
);
}

function MoonshotAiModelSelection({ apiKey, settings }) {
const [models, setModels] = useState([]);
const [loading, setLoading] = useState(true);

useEffect(() => {
async function findCustomModels() {
setLoading(true);
const { models: availableModels } = await System.customModels(
"moonshotai",
typeof apiKey === "boolean" ? null : apiKey
);

if (availableModels?.length > 0) {
setModels(availableModels);
}

setLoading(false);
}
findCustomModels();
}, [apiKey]);

if (!apiKey) {
return (
<div className="flex flex-col w-60">
<label className="text-white text-sm font-semibold block mb-3">
Chat Model Selection
</label>
<select
name="MoonshotAiModelPref"
disabled={true}
className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5"
>
<option disabled={true} selected={true}>
-- Enter API key --
</option>
</select>
</div>
);
}

if (loading) {
return (
<div className="flex flex-col w-60">
<label className="text-white text-sm font-semibold block mb-3">
Chat Model Selection
</label>
<select
name="MoonshotAiModelPref"
disabled={true}
className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5"
>
<option disabled={true} selected={true}>
-- loading available models --
</option>
</select>
</div>
);
}

return (
<div className="flex flex-col w-60">
<label className="text-white text-sm font-semibold block mb-3">
Chat Model Selection
</label>
<select
name="MoonshotAiModelPref"
required={true}
className="border-none bg-theme-settings-input-bg border-gray-500 text-white text-sm rounded-lg block w-full p-2.5"
>
{models.map((model) => (
<option
key={model.id}
value={model.id}
selected={settings?.MoonshotAiModelPref === model.id}
>
{model.id}
</option>
))}
</select>
</div>
);
}
Binary file added frontend/src/media/llmprovider/moonshotai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions frontend/src/pages/GeneralSettings/LLMPreference/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import XAILogo from "@/media/llmprovider/xai.png";
import NvidiaNimLogo from "@/media/llmprovider/nvidia-nim.png";
import PPIOLogo from "@/media/llmprovider/ppio.png";
import DellProAiStudioLogo from "@/media/llmprovider/dpais.png";
import MoonshotAiLogo from "@/media/llmprovider/moonshotai.png";

import PreLoader from "@/components/Preloader";
import OpenAiOptions from "@/components/LLMSelection/OpenAiOptions";
Expand Down Expand Up @@ -61,6 +62,7 @@ import XAILLMOptions from "@/components/LLMSelection/XAiLLMOptions";
import NvidiaNimOptions from "@/components/LLMSelection/NvidiaNimOptions";
import PPIOLLMOptions from "@/components/LLMSelection/PPIOLLMOptions";
import DellProAiStudioOptions from "@/components/LLMSelection/DPAISOptions";
import MoonshotAiOptions from "@/components/LLMSelection/MoonshotAiOptions";

import LLMItem from "@/components/LLMSelection/LLMItem";
import { CaretUpDown, MagnifyingGlass, X } from "@phosphor-icons/react";
Expand Down Expand Up @@ -293,6 +295,14 @@ export const AVAILABLE_LLM_PROVIDERS = [
description: "A unified API of AI services from leading providers",
requiredConfig: ["ApipieLLMApiKey", "ApipieLLMModelPref"],
},
{
name: "Moonshot AI",
value: "moonshotai",
logo: MoonshotAiLogo,
options: (settings) => <MoonshotAiOptions settings={settings} />,
description: "Run Moonshot AI's powerful LLMs.",
requiredConfig: ["MoonshotAiApiKey"],
},
{
name: "Generic OpenAI",
value: "generic-openai",
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/pages/OnboardingFlow/Steps/DataHandling/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import VoyageAiLogo from "@/media/embeddingprovider/voyageai.png";
import PPIOLogo from "@/media/llmprovider/ppio.png";
import PGVectorLogo from "@/media/vectordbs/pgvector.png";
import DPAISLogo from "@/media/llmprovider/dpais.png";
import MoonshotAiLogo from "@/media/llmprovider/moonshotai.png";

import React, { useState, useEffect } from "react";
import paths from "@/utils/paths";
import { useNavigate } from "react-router-dom";
Expand Down Expand Up @@ -242,6 +244,14 @@ export const LLM_SELECTION_PRIVACY = {
],
logo: DPAISLogo,
},
moonshotai: {
name: "Moonshot AI",
description: [
"Your chats may be used by Moonshot AI for training and model refinement",
"Your prompts and document text used in response creation are visible to Moonshot AI",
],
logo: MoonshotAiLogo,
},
};

export const VECTOR_DB_PRIVACY = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import NvidiaNimLogo from "@/media/llmprovider/nvidia-nim.png";
import CohereLogo from "@/media/llmprovider/cohere.png";
import PPIOLogo from "@/media/llmprovider/ppio.png";
import DellProAiStudioLogo from "@/media/llmprovider/dpais.png";
import MoonshotAiLogo from "@/media/llmprovider/moonshotai.png";

import OpenAiOptions from "@/components/LLMSelection/OpenAiOptions";
import GenericOpenAiOptions from "@/components/LLMSelection/GenericOpenAiOptions";
Expand Down Expand Up @@ -55,6 +56,7 @@ import XAILLMOptions from "@/components/LLMSelection/XAiLLMOptions";
import NvidiaNimOptions from "@/components/LLMSelection/NvidiaNimOptions";
import PPIOLLMOptions from "@/components/LLMSelection/PPIOLLMOptions";
import DellProAiStudioOptions from "@/components/LLMSelection/DPAISOptions";
import MoonshotAiOptions from "@/components/LLMSelection/MoonshotAiOptions";

import LLMItem from "@/components/LLMSelection/LLMItem";
import System from "@/models/system";
Expand Down Expand Up @@ -263,6 +265,13 @@ const LLMS = [
options: (settings) => <XAILLMOptions settings={settings} />,
description: "Run xAI's powerful LLMs like Grok-2 and more.",
},
{
name: "Moonshot AI",
value: "moonshotai",
logo: MoonshotAiLogo,
options: (settings) => <MoonshotAiOptions settings={settings} />,
description: "Run Moonshot AI's powerful LLMs.",
},
];

export default function LLMPreference({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const ENABLED_PROVIDERS = [
"xai",
"nvidia-nim",
"gemini",
"moonshotai",
// TODO: More agent support.
// "cohere", // Has tool calling and will need to build explicit support
// "huggingface" // Can be done but already has issues with no-chat templated. Needs to be tested.
Expand Down
4 changes: 4 additions & 0 deletions server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ SIG_SALT='salt' # Please generate random string at least 32 chars long.
# PPIO_API_KEY='your-ppio-api-key-here'
# PPIO_MODEL_PREF='deepseek/deepseek-v3/community'

# LLM_PROVIDER='moonshotai'
# MOONSHOT_AI_API_KEY='your-moonshot-api-key-here'
# MOONSHOT_AI_MODEL_PREF='moonshot-v1-32k'

###########################################
######## Embedding API SElECTION ##########
###########################################
Expand Down
3 changes: 3 additions & 0 deletions server/endpoints/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ function getModelTag() {
case "gemini":
model = process.env.GEMINI_LLM_MODEL_PREF;
break;
case "moonshotai":
model = process.env.MOONSHOT_AI_MODEL_PREF;
break;
default:
model = "--";
break;
Expand Down
5 changes: 5 additions & 0 deletions server/models/systemSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,11 @@ const SystemSettings = {
LiteLLMBasePath: process.env.LITE_LLM_BASE_PATH,
LiteLLMApiKey: !!process.env.LITE_LLM_API_KEY,

// Moonshot AI Keys
MoonshotAiApiKey: !!process.env.MOONSHOT_AI_API_KEY,
MoonshotAiModelPref:
process.env.MOONSHOT_AI_MODEL_PREF || "moonshot-v1-32k",

// Generic OpenAI Keys
GenericOpenAiBasePath: process.env.GENERIC_OPEN_AI_BASE_PATH,
GenericOpenAiModelPref: process.env.GENERIC_OPEN_AI_MODEL_PREF,
Expand Down
1 change: 1 addition & 0 deletions server/utils/AiProviders/modelMap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ContextWindowFinder {
groq: "groq",
xai: "xai",
deepseek: "deepseek",
moonshot: "moonshot",
};
static expiryMs = 1000 * 60 * 60 * 24 * 3; // 3 days
static remoteUrl =
Expand Down
Loading