|
7 | 7 |
|
8 | 8 | from dbally.audit.event_handlers.base import EventHandler
|
9 | 9 | from dbally.audit.event_tracker import EventTracker
|
| 10 | +from dbally.collection.exceptions import IndexUpdateError, NoViewFoundError |
| 11 | +from dbally.collection.results import ExecutionResult |
10 | 12 | from dbally.data_models.audit import RequestEnd, RequestStart
|
11 |
| -from dbally.data_models.execution_result import ExecutionResult |
12 |
| -from dbally.exceptions import DbAllyError |
13 | 13 | from dbally.llms.base import LLM
|
14 | 14 | from dbally.llms.clients.base import LLMOptions
|
15 | 15 | from dbally.nl_responder.nl_responder import NLResponder
|
|
18 | 18 | from dbally.views.base import BaseView, IndexLocation
|
19 | 19 |
|
20 | 20 |
|
21 |
| -class NoViewFoundError(DbAllyError): |
22 |
| - """ |
23 |
| - Error raised when there is no view with the given name. |
24 |
| - """ |
25 |
| - |
26 |
| - |
27 |
| -class IndexUpdateError(DbAllyError): |
28 |
| - """ |
29 |
| - Exception for when updating any of the Collection's similarity indexes fails. |
30 |
| -
|
31 |
| - Provides a dictionary mapping failed indexes to their |
32 |
| - respective exceptions as the `failed_indexes` attribute. |
33 |
| - """ |
34 |
| - |
35 |
| - def __init__(self, message: str, failed_indexes: Dict[AbstractSimilarityIndex, Exception]) -> None: |
36 |
| - """ |
37 |
| - Args: |
38 |
| - failed_indexes: Dictionary mapping failed indexes to their respective exceptions. |
39 |
| - """ |
40 |
| - self.failed_indexes = failed_indexes |
41 |
| - super().__init__(message) |
42 |
| - |
43 |
| - |
44 | 21 | class Collection:
|
45 | 22 | """
|
46 | 23 | Collection is a container for a set of views that can be used by db-ally to answer user questions.
|
@@ -158,7 +135,7 @@ def get(self, name: str) -> BaseView:
|
158 | 135 | """
|
159 | 136 |
|
160 | 137 | if name not in self._views:
|
161 |
| - raise NoViewFoundError |
| 138 | + raise NoViewFoundError(name) |
162 | 139 |
|
163 | 140 | return self._builders[name]()
|
164 | 141 |
|
@@ -298,5 +275,4 @@ async def update_similarity_indexes(self) -> None:
|
298 | 275 | }
|
299 | 276 | if failed_indexes:
|
300 | 277 | failed_locations = [loc for index in failed_indexes for loc in indexes[index]]
|
301 |
| - descriptions = ", ".join(".".join(name for name in location) for location in failed_locations) |
302 |
| - raise IndexUpdateError(f"Failed to update similarity indexes for {descriptions}", failed_indexes) |
| 278 | + raise IndexUpdateError(failed_indexes, failed_locations) |
0 commit comments