Patch model selection for openai (#1128)

prevent rerenders of web-browsing for agents
update openai latest pkg name
This commit is contained in:
Timothy Carambat 2024-04-18 13:32:50 -07:00 committed by GitHub
parent 9655880cf0
commit 91ea37d17a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 124 additions and 104 deletions

View File

@ -2,6 +2,20 @@ import useGetProviderModels, {
DISABLED_PROVIDERS,
} from "@/hooks/useGetProvidersModels";
// These models do NOT support function calling
function supportedModel(provider, model = "") {
if (provider !== "openai") return true;
if (model.startsWith("gpt-3.5-turbo")) return true;
switch (model) {
case "gpt-4":
case "gpt-4-turbo-preview":
case "gpt-4-32k":
return true;
default:
return false;
}
}
export default function AgentModelSelection({
provider,
workspace,
@ -60,6 +74,7 @@ export default function AgentModelSelection({
{defaultModels.length > 0 && (
<optgroup label="General models">
{defaultModels.map((model) => {
if (!supportedModel(provider, model)) return null;
return (
<option
key={model}
@ -75,6 +90,8 @@ export default function AgentModelSelection({
{Array.isArray(customModels) && customModels.length > 0 && (
<optgroup label="Custom models">
{customModels.map((model) => {
if (!supportedModel(provider, model.id)) return null;
return (
<option
key={model.id}
@ -93,7 +110,9 @@ export default function AgentModelSelection({
<>
{Object.entries(customModels).map(([organization, models]) => (
<optgroup key={organization} label={organization}>
{models.map((model) => (
{models.map((model) => {
if (!supportedModel(provider, model.id)) return null;
return (
<option
key={model.id}
value={model.id}
@ -101,7 +120,8 @@ export default function AgentModelSelection({
>
{model.name}
</option>
))}
);
})}
</optgroup>
))}
</>

View File

@ -112,8 +112,9 @@ export default function WorkspaceAgentConfiguration({ workspace }) {
</form>
</div>
);
}
function LoadingSkeleton() {
function LoadingSkeleton() {
return (
<div id="workspace-agent-settings-container">
<div className="w-1/2 flex flex-col gap-y-6">
@ -139,9 +140,9 @@ export default function WorkspaceAgentConfiguration({ workspace }) {
</div>
</div>
);
}
}
function AvailableAgentSkills({ skills, settings, toggleAgentSkill }) {
function AvailableAgentSkills({ skills, settings, toggleAgentSkill }) {
return (
<div>
<div className="flex flex-col mb-8">
@ -199,5 +200,4 @@ export default function WorkspaceAgentConfiguration({ workspace }) {
</div>
</div>
);
}
}

View File

@ -53,7 +53,7 @@
"node-html-markdown": "^1.3.0",
"node-llama-cpp": "^2.8.0",
"openai": "^3.2.1",
"openai:latest": "npm:openai@latest",
"openai-latest": "npm:openai@latest",
"pinecone-client": "^1.1.0",
"pluralize": "^8.0.0",
"posthog-node": "^3.1.1",

View File

@ -1,4 +1,4 @@
const OpenAI = require("openai:latest");
const OpenAI = require("openai-latest");
const Provider = require("./ai-provider.js");
const { RetryError } = require("../error.js");

View File

@ -4495,10 +4495,10 @@ onnxruntime-web@1.14.0:
onnxruntime-common "~1.14.0"
platform "^1.3.6"
"openai:latest@npm:openai@latest":
version "4.32.1"
resolved "https://registry.yarnpkg.com/openai/-/openai-4.32.1.tgz#9e375fdbc727330c5ea5d287beb325db3e6f9ad7"
integrity sha512-3e9QyCY47tgOkxBe2CSVKlXOE2lLkMa24Y0s3LYZR40yYjiBU9dtVze+C3mu1TwWDGiRX52STpQAEJZvRNuIrA==
"openai-latest@npm:openai@latest":
version "4.38.0"
resolved "https://registry.yarnpkg.com/openai/-/openai-4.38.0.tgz#d97accc7c368670a40c2f668650b624cb941dc8b"
integrity sha512-q1w04cRm+7CgUAGDXqt+OMa89zXBffHrEK0FcVDRhD+zL1S1aAatu4iYO5sIxR2QFEP//i8CM3QaxGVTNajxuw==
dependencies:
"@types/node" "^18.11.18"
"@types/node-fetch" "^2.6.4"