Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Add mux rules for match according to file and request type#968

Merged
aponcedeleonch merged 1 commit intomainfrom
file-mux-routing
Feb 7, 2025
Merged

Add mux rules for match according to file and request type#968
aponcedeleonch merged 1 commit intomainfrom
file-mux-routing

Conversation

@aponcedeleonch
Copy link
Copy Markdown
Member

@aponcedeleonch aponcedeleonch commented Feb 6, 2025

Closes: #885 and #944

This PR introduces the necessary changes for:

  1. Muxing to match on a specific filename (main.py) or file type (.py)
  2. Muxing on a specific request type, i.e. chat or FIM

The matching is tightly coupled with the priority of the muxing rules. A match will occur on the first possible rule.

Example:

  1. Muxing rule 1 -> match all .py files -> go to chat-gpt
  2. Muxing rule 2 -> match all .md files -> go to ollama

If in a request we recieve a README.md and a main.py file the request will be routed to chat-gpt since it's the match with the highest priority in the list.

To introduce above changes there were some minor changes:

  1. Separate FIM detection into its own class. Before it used to be part of BaseProvider
  2. Detect if a request is FIM or not before calling process_request method.

Both of them were necessary in order to re-use the logic to create the matcher for request type

peppescg
peppescg previously approved these changes Feb 6, 2025
Copy link
Copy Markdown
Contributor

@peppescg peppescg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing 🚀

Correct me if I am wrong, this should backward compatible with the current production API right? so if we merge it, without adding the new related UI part, it should works as well.

@aponcedeleonch
Copy link
Copy Markdown
Member Author

@peppescg yes, that's correct :)

@aponcedeleonch aponcedeleonch marked this pull request as draft February 7, 2025 12:19
Closes: #885 and #944

This PR introduces the necessary changes for:
1. Muxing to match on a specific filename (`main.py`) or file type (`.py`)
2. Muxing on a specific request type, i.e. chat or FIM

The matching is tightly coupled with the priority of the muxing rules.
A match will occur on the first possible rule.

Example:
Muxing rule 1 -> match all `.py` files -> go to `chat-gpt`
Muxing rule 2 -> match all `.md` files -> go to `ollama`

If in a request we recieve a `README.md` and a `main.py` file the
request will be routed to `chat-gpt` since it's the match with
the highest priority in the list.

To introduce above changes there were some minor changes:
1. Separate FIM detection into its own class. Before it used to be part of `BaseProvider`
2. Detect if a request is FIM or not before calling `process_request` method.

Both of them were necessary in order to re-use the logic to create the
matcher for request type
@aponcedeleonch aponcedeleonch merged commit 114f843 into main Feb 7, 2025
9 checks passed
@aponcedeleonch aponcedeleonch deleted the file-mux-routing branch February 7, 2025 13:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: Add rules to filter by file extension or name

3 participants