Skip to content

Commit

Permalink
fix circular selector dependencies (#10222)
Browse files Browse the repository at this point in the history
  • Loading branch information
logan-markewich committed Jan 23, 2024
1 parent 1bd90d8 commit 97140d2
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 25 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion llama_index/query_engine/router_query_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from llama_index.callbacks.schema import CBEventType, EventPayload
from llama_index.core.base_query_engine import BaseQueryEngine
from llama_index.core.base_retriever import BaseRetriever
from llama_index.core.base_selector import BaseSelector
from llama_index.core.response.schema import (
RESPONSE_TYPE,
PydanticResponse,
Expand All @@ -20,7 +21,6 @@
from llama_index.prompts.mixin import PromptMixinType
from llama_index.response_synthesizers import TreeSummarize
from llama_index.schema import BaseNode, QueryBundle
from llama_index.selectors.types import BaseSelector
from llama_index.selectors.utils import get_selector_from_context
from llama_index.service_context import ServiceContext
from llama_index.tools.query_engine import QueryEngineTool
Expand Down
2 changes: 1 addition & 1 deletion llama_index/query_pipeline/components/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from llama_index.bridge.pydantic import Field, PrivateAttr
from llama_index.callbacks.base import CallbackManager
from llama_index.core.base_selector import BaseSelector
from llama_index.core.query_pipeline.query_component import (
QUERY_COMPONENT_TYPE,
ChainableMixin,
Expand All @@ -13,7 +14,6 @@
QueryComponent,
validate_and_convert_stringable,
)
from llama_index.selectors.types import BaseSelector
from llama_index.utils import print_text


Expand Down
2 changes: 1 addition & 1 deletion llama_index/retrievers/router_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from llama_index.callbacks.schema import CBEventType, EventPayload
from llama_index.core.base_retriever import BaseRetriever
from llama_index.core.base_selector import BaseSelector
from llama_index.prompts.mixin import PromptMixinType
from llama_index.schema import IndexNode, NodeWithScore, QueryBundle
from llama_index.selectors.types import BaseSelector
from llama_index.selectors.utils import get_selector_from_context
from llama_index.service_context import ServiceContext
from llama_index.tools.retriever_tool import RetrieverTool
Expand Down
3 changes: 0 additions & 3 deletions llama_index/selectors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
PydanticMultiSelector,
PydanticSingleSelector,
)
from llama_index.selectors.types import BaseSelector, SelectorResult

__all__ = [
"BaseSelector",
"SelectorResult",
"LLMSingleSelector",
"LLMMultiSelector",
"EmbeddingSingleSelector",
Expand Down
10 changes: 5 additions & 5 deletions llama_index/selectors/embedding_selectors.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from typing import Any, Dict, Optional, Sequence

from llama_index.core.base_selector import (
BaseSelector,
SelectorResult,
SingleSelection,
)
from llama_index.embeddings.base import BaseEmbedding
from llama_index.embeddings.utils import resolve_embed_model
from llama_index.indices.query.embedding_utils import get_top_k_embeddings
from llama_index.prompts.mixin import PromptDictType
from llama_index.schema import QueryBundle
from llama_index.selectors.types import (
BaseSelector,
SelectorResult,
SingleSelection,
)
from llama_index.tools.types import ToolMetadata


Expand Down
6 changes: 5 additions & 1 deletion llama_index/selectors/llm_selectors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from typing import Any, Dict, List, Optional, Sequence, cast

from llama_index.core.base_selector import (
BaseSelector,
SelectorResult,
SingleSelection,
)
from llama_index.llm_predictor.base import LLMPredictorType
from llama_index.output_parsers.base import StructuredOutput
from llama_index.output_parsers.selection import Answer, SelectionOutputParser
Expand All @@ -12,7 +17,6 @@
MultiSelectPrompt,
SingleSelectPrompt,
)
from llama_index.selectors.types import BaseSelector, SelectorResult, SingleSelection
from llama_index.service_context import ServiceContext
from llama_index.tools.types import ToolMetadata
from llama_index.types import BaseOutputParser
Expand Down
12 changes: 6 additions & 6 deletions llama_index/selectors/pydantic_selectors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from typing import Any, Dict, Optional, Sequence

from llama_index.core.base_selector import (
BaseSelector,
MultiSelection,
SelectorResult,
SingleSelection,
)
from llama_index.llms.openai import OpenAI
from llama_index.program.openai_program import OpenAIPydanticProgram
from llama_index.prompts.mixin import PromptDictType
Expand All @@ -9,12 +15,6 @@
DEFAULT_MULTI_PYD_SELECT_PROMPT_TMPL,
DEFAULT_SINGLE_PYD_SELECT_PROMPT_TMPL,
)
from llama_index.selectors.types import (
BaseSelector,
MultiSelection,
SelectorResult,
SingleSelection,
)
from llama_index.tools.types import ToolMetadata
from llama_index.types import BasePydanticProgram

Expand Down
2 changes: 1 addition & 1 deletion llama_index/selectors/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from typing import Optional

from llama_index.core.base_selector import BaseSelector
from llama_index.selectors.llm_selectors import LLMMultiSelector, LLMSingleSelector
from llama_index.selectors.pydantic_selectors import (
PydanticMultiSelector,
PydanticSingleSelector,
)
from llama_index.selectors.types import BaseSelector
from llama_index.service_context import ServiceContext


Expand Down
12 changes: 6 additions & 6 deletions tests/query_pipeline/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
from typing import Any, List, Sequence

import pytest
from llama_index.core.base_selector import (
BaseSelector,
MultiSelection,
SelectorResult,
SingleSelection,
)
from llama_index.core.query_pipeline.components import (
ArgPackComponent,
FnComponent,
Expand All @@ -15,12 +21,6 @@
)
from llama_index.query_pipeline.query import QueryPipeline
from llama_index.schema import QueryBundle
from llama_index.selectors.types import (
BaseSelector,
MultiSelection,
SelectorResult,
SingleSelection,
)
from llama_index.tools.types import ToolMetadata


Expand Down

0 comments on commit 97140d2

Please sign in to comment.