-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Grok/XAI support for LLM & agents (#2517)
* Add Grok/XAI support for LLM & agents * forgot files
- Loading branch information
1 parent
0074ede
commit 5bc96bc
Showing
21 changed files
with
512 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
"uuidv", | ||
"vectordbs", | ||
"Weaviate", | ||
"XAILLM", | ||
"Zilliz" | ||
], | ||
"eslint.experimental.useFlatConfig": true, | ||
|
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
114 changes: 114 additions & 0 deletions
114
frontend/src/components/LLMSelection/XAiLLMOptions/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,114 @@ | ||
import { useState, useEffect } from "react"; | ||
import System from "@/models/system"; | ||
|
||
export default function XAILLMOptions({ settings }) { | ||
const [inputValue, setInputValue] = useState(settings?.XAIApiKey); | ||
const [apiKey, setApiKey] = useState(settings?.XAIApiKey); | ||
|
||
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"> | ||
xAI API Key | ||
</label> | ||
<input | ||
type="password" | ||
name="XAIApiKey" | ||
className="border-none 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="xAI API Key" | ||
defaultValue={settings?.XAIApiKey ? "*".repeat(20) : ""} | ||
required={true} | ||
autoComplete="off" | ||
spellCheck={false} | ||
onChange={(e) => setInputValue(e.target.value)} | ||
onBlur={() => setApiKey(inputValue)} | ||
/> | ||
</div> | ||
|
||
{!settings?.credentialsOnly && ( | ||
<XAIModelSelection settings={settings} apiKey={apiKey} /> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
function XAIModelSelection({ apiKey, settings }) { | ||
const [customModels, setCustomModels] = useState([]); | ||
const [loading, setLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
async function findCustomModels() { | ||
if (!apiKey) { | ||
setCustomModels([]); | ||
setLoading(true); | ||
return; | ||
} | ||
|
||
try { | ||
setLoading(true); | ||
const { models } = await System.customModels("xai", apiKey); | ||
setCustomModels(models || []); | ||
} catch (error) { | ||
console.error("Failed to fetch custom models:", error); | ||
setCustomModels([]); | ||
} finally { | ||
setLoading(false); | ||
} | ||
} | ||
findCustomModels(); | ||
}, [apiKey]); | ||
|
||
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="XAIModelPref" | ||
disabled={true} | ||
className="border-none bg-zinc-900 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> | ||
<p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> | ||
Enter a valid API key to view all available models for your account. | ||
</p> | ||
</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="XAIModelPref" | ||
required={true} | ||
className="border-none bg-zinc-900 border-gray-500 text-white text-sm rounded-lg block w-full p-2.5" | ||
> | ||
{customModels.length > 0 && ( | ||
<optgroup label="Available models"> | ||
{customModels.map((model) => { | ||
return ( | ||
<option | ||
key={model.id} | ||
value={model.id} | ||
selected={settings?.XAIModelPref === model.id} | ||
> | ||
{model.id} | ||
</option> | ||
); | ||
})} | ||
</optgroup> | ||
)} | ||
</select> | ||
<p className="text-xs leading-[18px] font-base text-white text-opacity-60 mt-2"> | ||
Select the xAI model you want to use for your conversations. | ||
</p> | ||
</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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.