Skip to content

Commit 5ce37d3

Browse files
authored
Add request type muxing (#96)
Add request type filtering to muxing docs and update file matching behavior
1 parent d87b9c7 commit 5ce37d3

File tree

4 files changed

+37
-16
lines changed

4 files changed

+37
-16
lines changed

docs/about/changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ Major features and changes are noted here. To review all updates, see the
1313

1414
Related: [Upgrade CodeGate](../how-to/install.md#upgrade-codegate)
1515

16+
- **Request type muxing** - 26 Feb, 2025\
17+
Workspace model muxing now supports filtering based on chat and FIM request
18+
types. Check the [model muxing docs](../features/muxing.mdx) to learn more.
19+
1620
- **New integration: Open Interpreter** - 20 Feb, 2025\
1721
CodeGate v0.1.24 adds support for the
1822
[avante.nvim](https://github.com/yetone/avante.nvim) plugin for Neovim with

docs/features/muxing.mdx

+33-16
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ especially useful when you're working on multiple projects or tasks that require
1515
different AI models.
1616

1717
In each of your CodeGate workspaces, you can select the AI provider and model
18-
combinations to use, even dynamically switching the active model based on file
19-
types found in your prompt. Then, configure your AI coding tool to use the
20-
CodeGate muxing endpoint `http://localhost:8989/v1/mux` as an OpenAI-compatible
21-
API provider.
18+
combinations to use, even dynamically switching the active model based on the
19+
request type and file types found in your prompt. Then, configure your AI coding
20+
tool to use the CodeGate muxing endpoint `http://localhost:8989/v1/mux` as an
21+
OpenAI-compatible API provider.
2222

2323
To change the model(s) currently in use, simply switch your active CodeGate
2424
workspace.
@@ -38,9 +38,11 @@ flowchart LR
3838
CodeGate --> WS1
3939
CodeGate --> WS2
4040
CodeGate --> WS3
41-
WS1 --> |api| LLM1
42-
WS2 --> |api| LLM2
43-
WS3 --> |api| LLM3
41+
WS1 --> |FIM requests| LLM1
42+
WS1 --> |Chat| LLM2
43+
WS2 --> |.md files| LLM2
44+
WS2 --> |.js files| LLM3
45+
WS3 --> |All prompts| LLM3
4446
```
4547

4648
## Use cases
@@ -109,21 +111,33 @@ workspace selection menu or the
109111
In the **Model Muxing** section, select the default ("catch-all") model to use
110112
with the workspace.
111113

112-
To assign a different model based on filename, click **Add Filter**. In the
113-
**Filter by** column, enter a file name or extension string to match. This is a
114-
simple substring match, wildcards are not supported. For example, to match
115-
Python files, enter `.py`. Then select the model to use with that file type.
114+
To assign a different model based on request type or filename, click **Add
115+
Filter**.
116+
117+
In the **Request Type** column, select the type of prompt to match:
118+
119+
- `FIM & Chat` matches all prompt types
120+
- `FIM` matches fill-in-the-middle (completion) requests
121+
- `Chat` matches chat prompts
122+
123+
In the **Filter by** column, enter a file name or extension string to match.
124+
This is an exact or `endswith` match, wildcards are not supported. For example,
125+
to match Python files, enter `.py`.
126+
127+
Finally, select the model to use for prompts that match the rule.
116128

117129
Filter rules are evaluated top-down. CodeGate selects the active model for a
118130
request using the first matching rule. If the prompt contains multiple files in
119131
context, the first rule that matches _any_ of the files is used. If no filter is
120132
matched, the catch-all rule applies.
121133

134+
#### Example configuration
135+
122136
<ThemedImage
123137
alt='An example showing several muxing rules for different file types'
124138
sources={{
125139
light: useBaseUrl('/img/features/muxing-rules-light.webp'),
126-
dark: useBaseUrl('/img/quickstart/muxing-rules-dark.webp'),
140+
dark: useBaseUrl('/img/features/muxing-rules-dark.webp'),
127141
}}
128142
title='Example muxing rules'
129143
width={'800px'}
@@ -132,10 +146,13 @@ _An example showing several muxing rules for different file types_
132146

133147
Breaking down the above example:
134148

135-
- Markdown files (`.md`) use the gpt-4o-mini model from the OpenAI provider.
136-
- JavaScript and TypeScript files (`.js` and `.ts`, which also matches `.jsx`
137-
and `.tsx`) use anthropic/claude-3.5-sonnet via OpenRouter.
138-
- All other requests use Ollama.
149+
- Markdown files (`.md`) use the gpt-4o-mini model from the OpenAI provider for
150+
all request types.
151+
- Chat prompts for JavaScript files (`.js`, but NOT `.jsx`) use
152+
anthropic/claude-3.7-sonnet via OpenRouter.
153+
- FIM requests for all files (except `.md` since it's higher in the list) use
154+
Ollama with the qwen2.5-coder:1.5b model.
155+
- All other requests use anthropic/claude-3.5-sonnet via OpenRouter.
139156
- A request containing both a JavaScript and Markdown file will match the `.md`
140157
rule first and use OpenAI.
141158

-5.7 KB
Binary file not shown.
-8.38 KB
Binary file not shown.

0 commit comments

Comments
 (0)