Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak type hints to match dependency's behavior. #11355

Merged
merged 7 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions libs/experimental/langchain_experimental/sql/vector_sql.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Vector SQL Database Chain Retriever"""
from __future__ import annotations

from typing import Any, Dict, List, Optional, Union
from typing import Any, Dict, List, Optional, Sequence, Union

from langchain.callbacks.manager import CallbackManagerForChainRun
from langchain.chains.llm import LLMChain
Expand Down Expand Up @@ -76,10 +76,8 @@ def parse(self, text: str) -> str:
return super().parse(text)


def get_result_from_sqldb(
db: SQLDatabase, cmd: str
) -> Union[str, List[Dict[str, Any]], Dict[str, Any]]:
result = db._execute(cmd, fetch="all") # type: ignore
def get_result_from_sqldb(db: SQLDatabase, cmd: str) -> Sequence[Dict[str, Any]]:
result = db._execute(cmd, fetch="all")
return result


Expand Down Expand Up @@ -179,8 +177,9 @@ def _call(
_run_manager.on_text("\nSQLResult: ", verbose=self.verbose)
_run_manager.on_text(str(result), color="yellow", verbose=self.verbose)
# If return direct, we just set the final result equal to
# the result of the sql query result, otherwise try to get a human readable
# final answer
# the result of the sql query result (`Sequence[Dict[str, Any]]`),
# otherwise try to get a human readable final answer (`str`).
final_result: Union[str, Sequence[Dict[str, Any]]]
if self.return_direct:
final_result = result
else:
Expand Down
112 changes: 35 additions & 77 deletions libs/experimental/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/experimental/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository = "https://github.com/langchain-ai/langchain"

[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
langchain = ">=0.0.239"
langchain = ">=0.0.308"
presidio-anonymizer = {version = "^2.2.33", optional = true}
presidio-analyzer = {version = "^2.2.33", optional = true}
faker = {version = "^19.3.1", optional = true}
Expand Down