feat(provider): support custom headers injection for HTTP providers (#2402)
* feat(provider): support custom headers injection for HTTP providers * fix(provider): resolve lint problem * fix(provider): align stream user-agent and header precedence docs
This commit is contained in:
16 files changed
+389
-15
No files matched your search
@@ -36,6 +36,7 @@ interface AddForm {
|
||||
requestTimeout: string
|
||||
thinkingLevel: string
|
||||
extraBody: string
|
||||
customHeaders: string
|
||||
}
|
||||
|
||||
const EMPTY_ADD_FORM: AddForm = {
|
||||
@@ -52,6 +53,7 @@ const EMPTY_ADD_FORM: AddForm = {
|
||||
requestTimeout: "",
|
||||
thinkingLevel: "",
|
||||
extraBody: "",
|
||||
customHeaders: "",
|
||||
}
|
||||
|
||||
interface AddModelSheetProps {
|
||||
@@ -136,6 +138,9 @@ export function AddModelSheet({
|
||||
extra_body: form.extraBody.trim()
|
||||
? JSON.parse(form.extraBody.trim())
|
||||
: undefined,
|
||||
custom_headers: form.customHeaders.trim()
|
||||
? JSON.parse(form.customHeaders.trim())
|
||||
: undefined,
|
||||
})
|
||||
if (setAsDefault) {
|
||||
await setDefaultModel(modelName)
|
||||
@@ -324,6 +329,18 @@ export function AddModelSheet({
|
||||
rows={3}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field
|
||||
label={t("models.field.customHeaders")}
|
||||
hint={t("models.field.customHeadersHint")}
|
||||
>
|
||||
<Textarea
|
||||
value={form.customHeaders}
|
||||
onChange={setField("customHeaders")}
|
||||
placeholder='{"X-Source": "coding-plan"}'
|
||||
rows={3}
|
||||
/>
|
||||
</Field>
|
||||
</AdvancedSection>
|
||||
|
||||
{serverError && (
|
||||
|
||||
@@ -34,6 +34,7 @@ interface EditForm {
|
||||
requestTimeout: string
|
||||
thinkingLevel: string
|
||||
extraBody: string
|
||||
customHeaders: string
|
||||
}
|
||||
|
||||
interface EditModelSheetProps {
|
||||
@@ -62,6 +63,7 @@ export function EditModelSheet({
|
||||
requestTimeout: "",
|
||||
thinkingLevel: "",
|
||||
extraBody: "",
|
||||
customHeaders: "",
|
||||
})
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [setAsDefault, setSetAsDefault] = useState(false)
|
||||
@@ -85,6 +87,9 @@ export function EditModelSheet({
|
||||
extraBody: model.extra_body
|
||||
? JSON.stringify(model.extra_body, null, 2)
|
||||
: "",
|
||||
customHeaders: model.custom_headers
|
||||
? JSON.stringify(model.custom_headers, null, 2)
|
||||
: "",
|
||||
})
|
||||
setSetAsDefault(model.is_default)
|
||||
setError("")
|
||||
@@ -119,6 +124,9 @@ export function EditModelSheet({
|
||||
extra_body: form.extraBody.trim()
|
||||
? JSON.parse(form.extraBody.trim())
|
||||
: {},
|
||||
custom_headers: form.customHeaders.trim()
|
||||
? JSON.parse(form.customHeaders.trim())
|
||||
: {},
|
||||
})
|
||||
if (setAsDefault && !model.is_default) {
|
||||
await setDefaultModel(model.model_name)
|
||||
@@ -294,6 +302,18 @@ export function EditModelSheet({
|
||||
rows={3}
|
||||
/>
|
||||
</Field>
|
||||
|
||||
<Field
|
||||
label={t("models.field.customHeaders")}
|
||||
hint={t("models.field.customHeadersHint")}
|
||||
>
|
||||
<Textarea
|
||||
value={form.customHeaders}
|
||||
onChange={setField("customHeaders")}
|
||||
placeholder='{"X-Source": "coding-plan"}'
|
||||
rows={3}
|
||||
/>
|
||||
</Field>
|
||||
</AdvancedSection>
|
||||
|
||||
{error && (
|
||||
|
||||
Reference in new issue
Block a user