Skip to content
Snippets Groups Projects
Unverified Commit 172a486c authored by Siraj R Aizlewood's avatar Siraj R Aizlewood
Browse files

LocalIndex Now Using Placeholder BaseIndex Class

Also fixed bug in layer.py where we weren't:
a) Setting the index_name to a default value.
b) Weren't using index_name.
parent 37fe08cb
No related branches found
No related tags found
No related merge requests found
from pydantic.v1 import BaseModel from pydantic.v1 import BaseModel
class BaseIndex(BaseModel): class BaseIndex(BaseModel):
pass pass
\ No newline at end of file
import numpy as np import numpy as np
from typing import List, Any from typing import List, Any
from semantic_router.linear import similarity_matrix, top_scores from semantic_router.linear import similarity_matrix, top_scores
from pydantic import BaseModel from semantic_router.indices.base import BaseIndex
import numpy as np import numpy as np
from typing import List, Any, Tuple, Optional from typing import List, Any, Tuple, Optional
class LocalIndex(BaseModel): class LocalIndex(BaseIndex):
index: Optional[np.ndarray] = None index: Optional[np.ndarray] = None
class Config: # Stop pydantic from complaining about Optional[np.ndarray] type hints. class Config: # Stop pydantic from complaining about Optional[np.ndarray] type hints.
......
...@@ -164,10 +164,10 @@ class RouteLayer: ...@@ -164,10 +164,10 @@ class RouteLayer:
encoder: Optional[BaseEncoder] = None, encoder: Optional[BaseEncoder] = None,
llm: Optional[BaseLLM] = None, llm: Optional[BaseLLM] = None,
routes: Optional[List[Route]] = None, routes: Optional[List[Route]] = None,
index_name: Optional[str] = None, index_name: Optional[str] = "local",
): ):
logger.info("local") logger.info("local")
self.index = Index.get_by_name(index_name="local") self.index = Index.get_by_name(index_name=index_name)
self.categories = None self.categories = None
if encoder is None: if encoder is None:
logger.warning( logger.warning(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment