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
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ function RouteEditor({
className='max-w-full gap-1.5 font-mono'
>
<span className='font-sans text-[10px] font-semibold tracking-normal uppercase'>
{t(ruleKind === 'regex' ? 'Regex' : 'Exact')}
{t(ruleKind === 'regex' ? 'Go Regex' : 'Exact')}
</span>
<span className='truncate'>{displayModel}</span>
</Badge>
Expand Down Expand Up @@ -1271,12 +1271,12 @@ function ModelRuleHelpPopover() {
<div className='text-muted-foreground space-y-2 text-xs leading-relaxed'>
<p>
{t(
'Use exact model names such as gpt-4o, or regex rules prefixed with re: such as re:^gemini-.'
'Use exact model names such as gpt-4o, or prefix Go regular expressions with re:, for example re:^gemini-.'
)}
</p>
<p>
{t(
'Separate multiple rules with English commas. For regex patterns that need commas, switch to JSON Text.'
'Separate multiple rules with ASCII commas. If a Go regular expression contains a comma, switch to JSON Text.'
)}
</p>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const OPERATION_MODE_OPTIONS = [
{ label: 'Copy Field', value: 'copy' },
{ label: 'Move Field', value: 'move' },
{ label: 'String Replace', value: 'replace' },
{ label: 'Regex Replace', value: 'regex_replace' },
{ label: 'Go Regex Replacement', value: 'regex_replace' },
{ label: 'Trim Prefix', value: 'trim_prefix' },
{ label: 'Trim Suffix', value: 'trim_suffix' },
{ label: 'Ensure Prefix', value: 'ensure_prefix' },
Expand Down Expand Up @@ -221,7 +221,8 @@ const MODE_DESCRIPTIONS: Record<string, string> = {
copy: 'Copy source field to target field',
move: 'Move source field to target field',
replace: 'Do string replacement in the target field',
regex_replace: 'Do regex replacement in the target field',
regex_replace:
'Replace text in the target field using a Go regular expression.',
trim_prefix: 'Remove string prefix',
trim_suffix: 'Remove string suffix',
ensure_prefix: 'Ensure the string has a specified prefix',
Expand Down Expand Up @@ -604,7 +605,7 @@ const getModePathPlaceholder = (mode: string): string => {

const getModeFromLabel = (mode: string): string => {
if (mode === 'replace') return 'Match Text'
if (mode === 'regex_replace') return 'Regex Pattern'
if (mode === 'regex_replace') return 'Go Regex Pattern'
if (mode === 'copy_header' || mode === 'move_header') return 'Source Header'
return 'Source Field'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4263,11 +4263,16 @@ export function ChannelMutateDrawer({
<FormItem className='flex items-center justify-between gap-3 px-4 py-3'>
<div className='space-y-0.5'>
<FormLabel className='text-sm'>
{t('Allow service_tier passthrough')}
{t('Allow {{field}} passthrough', {
field: 'service_tier',
})}
</FormLabel>
<FormDescription>
{t(
'Pass through the service_tier field'
'Pass through the {{field}} field',
{
field: 'service_tier',
}
)}
</FormDescription>
</div>
Expand All @@ -4290,11 +4295,17 @@ export function ChannelMutateDrawer({
<FormItem className='flex items-center justify-between gap-3 px-4 py-3'>
<div className='space-y-0.5'>
<FormLabel className='text-sm'>
{t('Disable store passthrough')}
{t(
'Block {{field}} passthrough',
{
field: 'store',
}
)}
</FormLabel>
<FormDescription>
{t(
'When enabled, the store field will be blocked'
'When enabled, the {{field}} field will be blocked',
{ field: 'store' }
)}
</FormDescription>
</div>
Expand All @@ -4316,12 +4327,14 @@ export function ChannelMutateDrawer({
<div className='space-y-0.5'>
<FormLabel className='text-sm'>
{t(
'Allow safety_identifier passthrough'
'Allow {{field}} passthrough',
{ field: 'safety_identifier' }
)}
</FormLabel>
<FormDescription>
{t(
'Pass through the safety_identifier field'
'Pass through the {{field}} field',
{ field: 'safety_identifier' }
)}
</FormDescription>
</div>
Expand All @@ -4343,12 +4356,20 @@ export function ChannelMutateDrawer({
<div className='space-y-0.5'>
<FormLabel className='text-sm'>
{t(
'Allow include usage obfuscation passthrough'
'Allow {{field}} passthrough',
{
field:
'stream_options.include_obfuscation',
}
)}
</FormLabel>
<FormDescription>
{t(
'Pass through the include field for usage obfuscation'
'Pass through {{field}} for usage obfuscation',
{
field:
'stream_options.include_obfuscation',
}
)}
</FormDescription>
</div>
Expand All @@ -4370,12 +4391,14 @@ export function ChannelMutateDrawer({
<div className='space-y-0.5'>
<FormLabel className='text-sm'>
{t(
'Allow inference geography passthrough'
'Allow {{field}} passthrough',
{ field: 'inference_geo' }
)}
</FormLabel>
<FormDescription>
{t(
'Pass through the inference_geo field for geographic routing'
'Pass through {{field}} for geographic routing',
{ field: 'inference_geo' }
)}
</FormDescription>
</div>
Expand All @@ -4401,12 +4424,14 @@ export function ChannelMutateDrawer({
<div className='space-y-0.5'>
<FormLabel className='text-sm'>
{t(
'Allow inference_geo passthrough'
'Allow {{field}} passthrough',
{ field: 'inference_geo' }
)}
</FormLabel>
<FormDescription>
{t(
'Pass through the inference_geo field for Claude data residency region control'
'Pass through {{field}} to control the Claude data residency region',
{ field: 'inference_geo' }
)}
</FormDescription>
</div>
Expand All @@ -4427,11 +4452,17 @@ export function ChannelMutateDrawer({
<FormItem className='flex items-center justify-between gap-3 px-4 py-3'>
<div className='space-y-0.5'>
<FormLabel className='text-sm'>
{t('Allow speed passthrough')}
{t(
'Allow {{field}} passthrough',
{
field: 'speed',
}
)}
</FormLabel>
<FormDescription>
{t(
'Pass through the speed field for Claude inference speed mode control'
'Pass through {{field}} to control the Claude inference speed mode',
{ field: 'speed' }
)}
</FormDescription>
</div>
Expand All @@ -4453,12 +4484,16 @@ export function ChannelMutateDrawer({
<div className='space-y-0.5'>
<FormLabel className='text-sm'>
{t(
'Allow Claude beta query passthrough'
'Append {{query}} to Claude requests',
{
query: '?beta=true',
}
)}
</FormLabel>
<FormDescription>
{t(
'Pass through the anthropic-beta header for beta features'
'Append {{query}} to upstream Claude request URLs for beta features',
{ query: '?beta=true' }
)}
</FormDescription>
</div>
Expand Down Expand Up @@ -4570,7 +4605,7 @@ export function ChannelMutateDrawer({
</FormControl>
<FormDescription>
{t(
'Comma-separated exact model names. Prefix with regex: to ignore by regular expression.'
'Separate exact model names with ASCII commas. Prefix a rule with regex: to use Go regular expression syntax (RE2; lookarounds such as (?!...) are not supported).'
)}
</FormDescription>
<FormMessage />
Expand Down
6 changes: 5 additions & 1 deletion web/default/src/features/channels/lib/advanced-custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,11 @@ function validateAdvancedCustomRouteModels(
getAdvancedCustomModelRuleKind(model) === 'regex' &&
getAdvancedCustomRegexModelPattern(model) === ''
) {
return { routeIndex, message: 'Model regex cannot be empty' }
return {
routeIndex,
message:
'The Go regular expression for model matching cannot be empty.',
}
}
if (seenInRoute.has(model)) {
return { routeIndex, message: 'Duplicate model in route models' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ export function ChannelAffinitySection(props: Props) {
},
{
id: 'model-regex',
header: t('Model Regex'),
header: t('Model Regex (Go syntax)'),
cell: (rule) => (
<RuleBadgeList items={rule.model_regex || []} />
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ export function RuleEditorDialog(props: Props) {
const handleSave = (values: RuleFormValues) => {
const modelRegex = normalizeStringList(values.model_regex_text)
if (modelRegex.length === 0) {
toast.error(t('At least one model regex pattern is required'))
toast.error(
t('At least one Go regular expression is required for model matching.')
)
return
}

Expand Down Expand Up @@ -278,15 +280,15 @@ export function RuleEditorDialog(props: Props) {

<div className='grid gap-3 sm:grid-cols-2'>
<div className='grid gap-1.5'>
<Label>{t('Model Regex (one per line)')} *</Label>
<Label>{t('Model Regex (Go syntax, one per line)')} *</Label>
<Textarea
rows={4}
placeholder={'^gpt-4o.*$\n^claude-3.*$'}
{...form.register('model_regex_text', { required: true })}
/>
</div>
<div className='grid gap-1.5'>
<Label>{t('Path Regex (one per line)')}</Label>
<Label>{t('Path Regex (Go syntax, one per line)')}</Label>
<Textarea
rows={4}
placeholder='/v1/chat/completions'
Expand Down Expand Up @@ -417,7 +419,7 @@ export function RuleEditorDialog(props: Props) {

<div className='grid gap-3 sm:grid-cols-2'>
<div className='grid gap-1.5'>
<Label>{t('Value Regex')}</Label>
<Label>{t('Value Regex (Go syntax)')}</Label>
<Input
placeholder='^[-0-9A-Za-z._:]{1,128}$'
{...form.register('value_regex')}
Expand Down
2 changes: 1 addition & 1 deletion web/default/src/features/usage-logs/lib/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const PARAM_OVERRIDE_ACTION_MAP: Record<string, string> = {
to_lower: 'To Lower',
to_upper: 'To Upper',
replace: 'Replace',
regex_replace: 'Regex Replace',
regex_replace: 'Go Regex Replacement',
set_header: 'Set Header',
delete_header: 'Delete Header',
copy_header: 'Copy Header',
Expand Down
Loading