aurelio-labs / semantic-router

Superfast AI decision making and intelligent processing of multi-modal data.
https://www.aurelio.ai/semantic-router
MIT License
2.14k stars 221 forks source link

Router Save and Load #336

Open fadi212 opened 4 months ago

fadi212 commented 4 months ago

I am trying to save the router using rl.to_yaml and then when I load it, it does not work ? Does the semantic router have no support for saving and loading both index and routers ? Because every time I have to initialize the index and router.

I am trying to convert it into an API but it is creating the above issue.

abnerjacobsen commented 4 months ago

Hi @fadi212 ,

I had a similar need, in my case I saved the routes in JSON and then needed to load the JSON to populate the vectors in Qdrant through a script. I solved it this way:

from semantic_router.index.qdrant import QdrantIndex
from semantic_router.layer import LayerConfig, RouteLayer

layer_config = LayerConfig.from_file("./semantic_routes_daschat.json")

qd_index = QdrantIndex(
    index_name="dasbothub",
    location="http://0.0.0.0",
    port=6333,
    prefer_grpc=False,
    https=False,
    api_key="1245436547",
)

layer = RouteLayer.from_config(config=layer_config, index=qd_index)
shankara-93 commented 3 months ago

how to save both index and routers in first places... and load it into QdrantIndex.. Ref: https://github.com/aurelio-labs/semantic-router/issues/53