Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added vertex #2578

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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 @@ -96,6 +96,7 @@ AnythingLLM divides your documents into objects called `workspaces`. A Workspace
- [Text Generation Web UI](https://github.com/oobabooga/text-generation-webui)
- [Apipie](https://apipie.ai/)
- [xAI](https://x.ai/)
- [Google Vertex](https://cloud.google.com/vertex-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)

**Embedder models:**
Expand Down
95 changes: 95 additions & 0 deletions frontend/src/components/LLMSelection/VertexLLMOptions/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
export default function VertexLLMOptions({ settings }) {
return (
<div className="w-full flex flex-col">
<div className="w-full flex items-center gap-[36px] mt-1.5">
<div className="flex flex-col w-60">
<label className="text-white text-sm font-semibold block mb-3">
GCP Project Name
</label>
<input
type="text"
name="VertexProjectName"
className="bg-zinc-900 text-white placeholder:text-white/20 text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"
placeholder="eg: your-project-name"
defaultValue={settings?.VertexProjectName ?? ""}
required={true}
autoComplete="off"
spellCheck={false}
/>
</div>
<div className="flex flex-col w-60">
<label className="text-white text-sm font-semibold block mb-3">
GCP Region
</label>
<input
type="text"
name="VertexRegion"
className="bg-zinc-900 text-white placeholder:text-white/20 text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5"
placeholder="eg: europe-west4"
defaultValue={settings?.VertexRegion ?? ""}
required={true}
autoComplete="off"
spellCheck={false}
/>
</div>
{!settings?.credentialsOnly && (
<VertexLLMModelSelection settings={settings} />
)}
</div>
</div>
);

function VertexLLMModelSelection({ settings }) {
console.log(settings);
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="VertexLLMModelPref"
defaultValue={settings?.VertexLLMModelPref || "gemini-1.5-flash"}
required={true}
className="bg-zinc-900 border-gray-500 text-white text-sm rounded-lg block w-full p-2.5"
>
<optgroup label="Stable Models">
{[
"gemini-1.5-flash",
"gemini-1.5-pro",
"gemini-1.5-flash-001",
"gemini-1.5-pro-001",
"gemini-1.5-flash-002",
"gemini-1.5-pro-002",
].map((model) => {
return (
<option key={model} value={model}>
{model}
</option>
);
})}
</optgroup>
</select>
</div>
<div className="flex flex-col w-60">
<label className="text-white text-sm font-semibold block mb-3">
Safety Setting
</label>
<select
name="VertexSafetySetting"
defaultValue={
settings?.VertexSafetySetting || "BLOCK_MEDIUM_AND_ABOVE"
}
required={true}
className="bg-zinc-900 border-gray-500 text-white text-sm rounded-lg block w-full p-2.5"
>
<option value="BLOCK_NONE">None</option>
<option value="BLOCK_ONLY_HIGH">Block few</option>
<option value="BLOCK_MEDIUM_AND_ABOVE">Block some (default)</option>
<option value="BLOCK_LOW_AND_ABOVE">Block most</option>
</select>
</div>
</>
);
}
}
8 changes: 8 additions & 0 deletions frontend/src/hooks/useGetProvidersModels.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ export const DISABLED_PROVIDERS = [
];
const PROVIDER_DEFAULT_MODELS = {
openai: [],
vertex: [
"gemini-1.5-flash",
"gemini-1.5-pro",
"gemini-1.5-flash-001",
"gemini-1.5-pro-001",
"gemini-1.5-flash-002",
"gemini-1.5-pro-002",
],
gemini: [
"gemini-pro",
"gemini-1.0-pro",
Expand Down
Binary file added frontend/src/media/llmprovider/vertex.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 @@ -10,6 +10,7 @@ import GenericOpenAiLogo from "@/media/llmprovider/generic-openai.png";
import AzureOpenAiLogo from "@/media/llmprovider/azure.png";
import AnthropicLogo from "@/media/llmprovider/anthropic.png";
import GeminiLogo from "@/media/llmprovider/gemini.png";
import VertexLogo from "@/media/llmprovider/vertex.png";
import OllamaLogo from "@/media/llmprovider/ollama.png";
import NovitaLogo from "@/media/llmprovider/novita.png";
import LMStudioLogo from "@/media/llmprovider/lmstudio.png";
Expand Down Expand Up @@ -39,6 +40,7 @@ import LMStudioOptions from "@/components/LLMSelection/LMStudioOptions";
import LocalAiOptions from "@/components/LLMSelection/LocalAiOptions";
import NativeLLMOptions from "@/components/LLMSelection/NativeLLMOptions";
import GeminiLLMOptions from "@/components/LLMSelection/GeminiLLMOptions";
import VertexLLMOptions from "@/components/LLMSelection/VertexLLMOptions";
import OllamaLLMOptions from "@/components/LLMSelection/OllamaLLMOptions";
import NovitaLLMOptions from "@/components/LLMSelection/NovitaLLMOptions";
import TogetherAiOptions from "@/components/LLMSelection/TogetherAiOptions";
Expand Down Expand Up @@ -94,6 +96,14 @@ export const AVAILABLE_LLM_PROVIDERS = [
description: "Google's largest and most capable AI model",
requiredConfig: ["GeminiLLMApiKey"],
},
{
name: "Vertex",
value: "vertex",
logo: VertexLogo,
options: (settings) => <VertexLLMOptions settings={settings} />,
description: "Google's Genereative AI model platform",
requiredConfig: ["VertexProjectName", "VertexRegion"],
},
{
name: "HuggingFace",
value: "huggingface",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import GenericOpenAiLogo from "@/media/llmprovider/generic-openai.png";
import AzureOpenAiLogo from "@/media/llmprovider/azure.png";
import AnthropicLogo from "@/media/llmprovider/anthropic.png";
import GeminiLogo from "@/media/llmprovider/gemini.png";
import VertexLogo from "@/media/llmprovider/vertex.png";
import OllamaLogo from "@/media/llmprovider/ollama.png";
import TogetherAILogo from "@/media/llmprovider/togetherai.png";
import FireworksAILogo from "@/media/llmprovider/fireworksai.jpeg";
Expand Down Expand Up @@ -76,6 +77,14 @@ export const LLM_SELECTION_PRIVACY = {
],
logo: GeminiLogo,
},
vertex: {
name: "Vertex",
description: [
"Your chats will not be used for training",
"Your prompts and document text used in response creation are visible to Google",
],
logo: VertexLogo,
},
lmstudio: {
name: "LMStudio",
description: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import GenericOpenAiLogo from "@/media/llmprovider/generic-openai.png";
import AzureOpenAiLogo from "@/media/llmprovider/azure.png";
import AnthropicLogo from "@/media/llmprovider/anthropic.png";
import GeminiLogo from "@/media/llmprovider/gemini.png";
import VertexLogo from "@/media/llmprovider/vertex.png";
import OllamaLogo from "@/media/llmprovider/ollama.png";
import LMStudioLogo from "@/media/llmprovider/lmstudio.png";
import LocalAiLogo from "@/media/llmprovider/localai.png";
Expand Down Expand Up @@ -34,6 +35,7 @@ import LMStudioOptions from "@/components/LLMSelection/LMStudioOptions";
import LocalAiOptions from "@/components/LLMSelection/LocalAiOptions";
import NativeLLMOptions from "@/components/LLMSelection/NativeLLMOptions";
import GeminiLLMOptions from "@/components/LLMSelection/GeminiLLMOptions";
import VertexLLMOptions from "@/components/LLMSelection/VertexLLMOptions";
import OllamaLLMOptions from "@/components/LLMSelection/OllamaLLMOptions";
import MistralOptions from "@/components/LLMSelection/MistralOptions";
import HuggingFaceOptions from "@/components/LLMSelection/HuggingFaceOptions";
Expand Down Expand Up @@ -91,6 +93,13 @@ const LLMS = [
options: (settings) => <GeminiLLMOptions settings={settings} />,
description: "Google's largest and most capable AI model",
},
{
name: "Vertex",
value: "vertex",
logo: VertexLogo,
options: (settings) => <VertexLLMOptions settings={settings} />,
description: "Google's Genereative AI model platform",
},
{
name: "HuggingFace",
value: "huggingface",
Expand Down
8 changes: 8 additions & 0 deletions server/models/systemSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,14 @@ const SystemSettings = {
GeminiSafetySetting:
process.env.GEMINI_SAFETY_SETTING || "BLOCK_MEDIUM_AND_ABOVE",

// Vertex
VertexLLMModelPref:
process.env.VERTEX_LLM_MODEL_PREF || "gemini-1.5-flash",
VertexSafetySetting:
process.env.VERTEX_SAFETY_SETTING || "BLOCK_MEDIUM_AND_ABOVE",
VertexProjectName: process.env.VERTEX_PROJECT_NAME,
VertexRegion: process.env.VERTEX_REGION,

// LMStudio Keys
LMStudioBasePath: process.env.LMSTUDIO_BASE_PATH,
LMStudioTokenLimit: process.env.LMSTUDIO_MODEL_TOKEN_LIMIT,
Expand Down
5 changes: 3 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@anthropic-ai/sdk": "^0.16.1",
"@azure/openai": "1.0.0-beta.10",
"@datastax/astra-db-ts": "^0.1.3",
"@google-cloud/vertexai": "^1.9.0",
"@google/generative-ai": "^0.7.1",
"@ladjs/graceful": "^3.2.2",
"@lancedb/lancedb": "0.5.2",
Expand Down Expand Up @@ -92,8 +93,8 @@
"flow-remove-types": "^2.217.1",
"globals": "^13.21.0",
"hermes-eslint": "^0.15.0",
"nodemon": "^2.0.22",
"node-html-markdown": "^1.3.0",
"nodemon": "^2.0.22",
"prettier": "^3.0.3"
}
}
}
8 changes: 8 additions & 0 deletions server/utils/AiProviders/modelMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ const MODEL_MAP = {
"gemini-1.5-flash-exp-0827": 1_048_576,
"gemini-1.5-flash-8b-exp-0827": 1_048_576,
},
vertex: {
"gemini-1.5-flash": 1_048_576,
"gemini-1.5-pro": 2_097_152,
"gemini-1.5-flash-001": 1_048_576,
"gemini-1.5-pro-001": 2_097_152,
"gemini-1.5-flash-002": 1_048_576,
"gemini-1.5-pro-002": 2_097_152,
},
groq: {
"gemma2-9b-it": 8192,
"gemma-7b-it": 8192,
Expand Down
Loading