{"id":24760692,"url":"https://github.com/racoolstudio/semantic-router-c-sharp","last_synced_at":"2026-04-25T11:34:07.922Z","repository":{"id":273876365,"uuid":"921141820","full_name":"racoolstudio/Semantic-Router-C-Sharp","owner":"racoolstudio","description":"Semantic-Router-C-Sharp is a superfast decision-making layer for your LLMs (Large Language Models) and agents in C#. Instead of relying on slow LLM generations to make tool-use decisions, this router uses the power of semantic vector space to make fast decisions by routing requests based on semantic meaning. ","archived":false,"fork":false,"pushed_at":"2025-01-23T14:18:09.000Z","size":89718,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T11:45:44.225Z","etag":null,"topics":["ai","csharp","llm","machine-learning","ml","semantic","semantic-router"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/racoolstudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-23T12:19:07.000Z","updated_at":"2025-01-23T14:18:13.000Z","dependencies_parsed_at":"2025-01-23T14:31:22.761Z","dependency_job_id":null,"html_url":"https://github.com/racoolstudio/Semantic-Router-C-Sharp","commit_stats":null,"previous_names":["racoolstudio/semantic-router-c-sharp-"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racoolstudio%2FSemantic-Router-C-Sharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racoolstudio%2FSemantic-Router-C-Sharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racoolstudio%2FSemantic-Router-C-Sharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/racoolstudio%2FSemantic-Router-C-Sharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/racoolstudio","download_url":"https://codeload.github.com/racoolstudio/Semantic-Router-C-Sharp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245097840,"owners_count":20560317,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","csharp","llm","machine-learning","ml","semantic","semantic-router"],"created_at":"2025-01-28T18:18:52.200Z","updated_at":"2026-04-25T11:34:02.892Z","avatar_url":"https://github.com/racoolstudio.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Semantic-Router-C-Sharp\n\n**Semantic-Router-C-Sharp** is a superfast decision-making layer for your LLMs (Large Language Models) and agents in C#. Instead of relying on slow LLM generations to make tool-use decisions, this router uses the power of **semantic vector space** to make fast decisions by routing requests based on semantic meaning.\n\nThis C# version replicates the core features of the original Python Semantic Router, offering the same functionality with C#-specific optimizations.\n\n## Overview\n\nThe Semantic Router makes routing decisions based on the **semantic content** of a query, improving efficiency in applications that rely on NLP. It can be used to route requests to different actions or tools depending on the meaning of the user's input, without the need for slow or manual decision-making.\n\n## Features\n\n- Routes decisions based on the **semantic meaning** of user input.\n- Superfast decision-making for applications involving LLMs and agents.\n- C#-optimized implementation for routing natural language queries.\n- Easily integrates with existing C# systems.\n## Repo\nHere is the [repo](https://github.com/racoolstudio/Semantic-Router-C-Sharp)\n## Installation\n\n### Manual Installation\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/yourusername/Semantic-Router-C-Sharp.git\n```\n2. Build the project:\n\n```bash\ndotnet build\n```\n3. Add the project to your solution or reference the compiled DLL.\n\n## Quickstart\n\n### To get started with the Semantic Router in C#, follow these simple steps.\n\n1. Define Your Routes:\nDefine a set of **Route objects**. These represent the decision paths the router will use. In this example, we define two routes: one for political discussions and one for casual chitchat.\n\n```csharp\nusing SemanticRouter.Models;\nusing SmartComponents.Inference;\n\nRoute chitchat = new Route(\n    name: \"chitchat\",\n    utterances: new string[] {\n        \"how's the weather today?\",\n        \"how are things going?\",\n        \"lovely weather today\",\n        \"the weather is horrendous\",\n        \"let's go to the chippy\"\n    }\n);\n\nRoute politics = new Route(\n    name: \"politics\",\n    utterances: new string[] {\n        \"isn't politics the best thing ever?\",\n        \"why don't you tell me about your political opinions?\",\n        \"don't you just love the president?\",\n        \"they're going to destroy this country!\",\n        \"they will save the country!\"\n    }\n);\n\nRoute[] routes = new Route[] { chitchat, politics };\n\n```\n2. Initialize the Route Layer:\nThe **RouteLayer** handles the decision-making process, routing the input based on its semantic content. You’ll need to instantiate a RouteLayer object and pass in your predefined routes.\n\n```csharp\nRouteLayer routeLayer = new RouteLayer();\n```\n\n3. Make Semantic Decisions:\nNow, you can pass user input to the RouteLayer, which will return the appropriate route based on the semantic meaning of the query.\n\n```csharp\n// Example 1: Chitchat query\nstring c_target = \"how are you doing?\";\nvar c_result = routeLayer.GetRoute(c_target, routes);\nConsole.WriteLine(c_result); // Output: chitchat\n\n// Example 2: Politics query\nstring p_target = \"I think the president is doing a great job\";\nvar p_result = routeLayer.GetRoute(p_target, routes);\nConsole.WriteLine(p_result); // Output: politics\n```\n4. Running the Application:\nRun the application using the following command:\n\n```bash\ndotnet run\n```\n\n**Expected Output:**\n```bash\nchitchat\npolitics\n```\n\n## Contributing\n\nI welcome contributions! If you'd like to help improve this project or add new features, follow these steps:\n\n1. Fork the repo.\n2. Create a new branch (`git checkout -b feature/your-feature`).\n3. Commit your changes (`git commit -am 'Add new feature'`).\n4. Push to the branch (`git push origin feature/your-feature`).\n5. Open a pull request.\n\n## Acknowledgements\n- The original concept was inspired by [Aurelio Labs' Semantic Router (Python)](https://github.com/aurelio-labs/semantic-router).\n- Thanks to the open-source community for supporting the development of intelligent routing solutions.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fracoolstudio%2Fsemantic-router-c-sharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fracoolstudio%2Fsemantic-router-c-sharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fracoolstudio%2Fsemantic-router-c-sharp/lists"}