Skip to content
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "noggin-server"]
path = noggin-server
url = git@github.com:timothyaveni/noggin-server.git
url = git@github.com:GodricLee/noggin-server.git
2 changes: 1 addition & 1 deletion noggin-server
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ import './ModelProviderCredentialsForm.css';

type SingleCredentialType = string;

// Added: allow passing extra optional fields not present in credentialsSchema
type ExtraField = {
key: string;
label: string;
helperText?: string;
};

export function ModelProviderCredentialsForm({
credentialsSchema,
currentCredentials,
onSubmit,
// Added: new optional prop for extra fields
extraFields,
}: {
credentialsSchema: Record<
string,
Expand All @@ -22,6 +31,8 @@ export function ModelProviderCredentialsForm({
>;
currentCredentials: Record<string, SingleCredentialType>;
onSubmit: (credentials: Record<string, SingleCredentialType>) => any;
// Added
extraFields?: ExtraField[];
}) {
const [credentials, setCredentials] = useState(currentCredentials);

Expand Down Expand Up @@ -51,6 +62,30 @@ export function ModelProviderCredentialsForm({
);
})}

{/* Added: render extra optional fields that are not in credentialsSchema */}
{extraFields
?.filter((f) => !(f.key in credentialsSchema))
.map((f) => (
<div
key={f.key}
// 新增: 给 base_url 文本框往下挪一点(上方留白)
style={f.key === 'base_url' ? { marginTop: 12 } : undefined}
>
<TextField
id={f.key}
label={f.label}
value={credentials[f.key] ?? ''}
helperText={f.helperText}
onChange={(e) => {
setCredentials({
...credentials,
[f.key]: e.target.value,
});
}}
/>
</div>
))}

<Button type="submit">
<T>Save credentials</T>
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,19 @@ export default function Provider() {
const actionResponse = useActionData<typeof action>();
const submit = useSubmit();

// Added: optional extra field for OpenAI provider only
const extraFields =
provider.name === 'openai'
? [
{
key: 'base_url',
label: 'Base URL (optional)',
helperText:
'Optional. If left blank, the default OpenAI API endpoint will be used.',
},
]
: undefined;

return (
<Box mt={4}>
<Breadcrumbs>
Expand Down Expand Up @@ -128,6 +141,7 @@ export default function Provider() {
provider.credentialsSchema as any // TODO get this type outta there
}
currentCredentials={currentCredentials as Record<string, string>}
extraFields={extraFields}
onSubmit={(credentials: any) => {
// alert(JSON.stringify(credentials));
submit(
Expand Down
15 changes: 15 additions & 0 deletions reagent-remix-vite/app/routes/providers.$name/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ export default function Provider() {
const actionResponse = useActionData<typeof action>();
const submit = useSubmit();

// Added: optional extra field for OpenAI provider only
const extraFields =
provider.name === 'openai'
? [
{
key: 'base_url',
label: 'Base URL (optional)',
helperText:
'Optional. If left blank, the default OpenAI API endpoint will be used.',
},
]
: undefined;

return (
<Box mt={4}>
<Breadcrumbs>
Expand Down Expand Up @@ -131,6 +144,8 @@ export default function Provider() {
provider.credentialsSchema as any // TODO get this type outta there
}
currentCredentials={currentCredentials as Record<string, string>}
// Added: pass optional extra fields for OpenAI
extraFields={extraFields}
onSubmit={(credentials: any) => {
// alert(JSON.stringify(credentials));
submit(
Expand Down
11 changes: 11 additions & 0 deletions reagent-remix-vite/db/seeds/aiModels/aiModels.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ async function main() {
en_US: 'API Key',
},
},
// 新增可选 Azure 端点,保持后向兼容
base_url: {
type: 'string',
name: {
en_US: 'Base URL (Azure endpoint, optional)',
},
description: {
en_US:
'If set to an Azure domain (https://{resource}.openai.azure.com/ or https://{resource}.cognitiveservices.azure.com/), Azure OpenAI will be used automatically. Model-to-deployment mapping is derived from the selected model; you do not need to enter a deployment name.',
},
},
},
needsCredentials: true,
},
Expand Down