-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
95 changed files
with
2,558 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
frontend/src/components/EmbeddingSelection/OllamaOptions/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import System from "@/models/system"; | ||
|
||
export default function OllamaEmbeddingOptions({ settings }) { | ||
const [basePathValue, setBasePathValue] = useState( | ||
settings?.EmbeddingBasePath | ||
); | ||
const [basePath, setBasePath] = useState(settings?.EmbeddingBasePath); | ||
|
||
return ( | ||
<div className="w-full flex flex-col gap-y-4"> | ||
<div className="w-full flex items-center gap-4"> | ||
<div className="flex flex-col w-60"> | ||
<label className="text-white text-sm font-semibold block mb-4"> | ||
LocalAI Base URL | ||
</label> | ||
<input | ||
type="url" | ||
name="EmbeddingBasePath" | ||
className="bg-zinc-900 text-white placeholder-white/20 text-sm rounded-lg focus:border-white block w-full p-2.5" | ||
placeholder="http://127.0.0.1:11434" | ||
defaultValue={settings?.EmbeddingBasePath} | ||
onChange={(e) => setBasePathValue(e.target.value)} | ||
onBlur={() => setBasePath(basePathValue)} | ||
required={true} | ||
autoComplete="off" | ||
spellCheck={false} | ||
/> | ||
</div> | ||
<OllamaLLMModelSelection settings={settings} basePath={basePath} /> | ||
<div className="flex flex-col w-60"> | ||
<label className="text-white text-sm font-semibold block mb-4"> | ||
Max embedding chunk length | ||
</label> | ||
<input | ||
type="number" | ||
name="EmbeddingModelMaxChunkLength" | ||
className="bg-zinc-900 text-white placeholder-white/20 text-sm rounded-lg focus:border-white block w-full p-2.5" | ||
placeholder="8192" | ||
min={1} | ||
onScroll={(e) => e.target.blur()} | ||
defaultValue={settings?.EmbeddingModelMaxChunkLength} | ||
required={false} | ||
autoComplete="off" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
function OllamaLLMModelSelection({ settings, basePath = null }) { | ||
const [customModels, setCustomModels] = useState([]); | ||
const [loading, setLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
async function findCustomModels() { | ||
if (!basePath) { | ||
setCustomModels([]); | ||
setLoading(false); | ||
return; | ||
} | ||
setLoading(true); | ||
const { models } = await System.customModels("ollama", null, basePath); | ||
setCustomModels(models || []); | ||
setLoading(false); | ||
} | ||
findCustomModels(); | ||
}, [basePath]); | ||
|
||
if (loading || customModels.length == 0) { | ||
return ( | ||
<div className="flex flex-col w-60"> | ||
<label className="text-white text-sm font-semibold block mb-4"> | ||
Embedding Model Selection | ||
</label> | ||
<select | ||
name="EmbeddingModelPref" | ||
disabled={true} | ||
className="bg-zinc-900 border border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" | ||
> | ||
<option disabled={true} selected={true}> | ||
{!!basePath | ||
? "-- loading available models --" | ||
: "-- waiting for URL --"} | ||
</option> | ||
</select> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col w-60"> | ||
<label className="text-white text-sm font-semibold block mb-4"> | ||
Embedding Model Selection | ||
</label> | ||
<select | ||
name="EmbeddingModelPref" | ||
required={true} | ||
className="bg-zinc-900 border border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" | ||
> | ||
{customModels.length > 0 && ( | ||
<optgroup label="Your loaded models"> | ||
{customModels.map((model) => { | ||
return ( | ||
<option | ||
key={model.id} | ||
value={model.id} | ||
selected={settings.EmbeddingModelPref === model.id} | ||
> | ||
{model.id} | ||
</option> | ||
); | ||
})} | ||
</optgroup> | ||
)} | ||
</select> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.