mirror of
https://github.com/hwchase17/langchain
synced 2024-11-16 06:13:16 +00:00
Patch: improve type hint (#15451)
This commit is contained in:
parent
8ebf55ebbf
commit
b65e57971e
@ -2,7 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
from typing import Any, Dict, Iterable, List, Literal, Optional, Sequence, Union
|
from typing import Any, Dict, Iterable, List, Literal, Optional, Sequence
|
||||||
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from langchain_core.utils import get_from_env
|
from langchain_core.utils import get_from_env
|
||||||
@ -376,14 +376,14 @@ class SQLDatabase:
|
|||||||
def _execute(
|
def _execute(
|
||||||
self,
|
self,
|
||||||
command: str,
|
command: str,
|
||||||
fetch: Union[Literal["all"], Literal["one"]] = "all",
|
fetch: Literal["all", "one"] = "all",
|
||||||
) -> Sequence[Dict[str, Any]]:
|
) -> Sequence[Dict[str, Any]]:
|
||||||
"""
|
"""
|
||||||
Executes SQL command through underlying engine.
|
Executes SQL command through underlying engine.
|
||||||
|
|
||||||
If the statement returns no rows, an empty list is returned.
|
If the statement returns no rows, an empty list is returned.
|
||||||
"""
|
"""
|
||||||
with self._engine.begin() as connection:
|
with self._engine.begin() as connection: # type: Connection
|
||||||
if self._schema is not None:
|
if self._schema is not None:
|
||||||
if self.dialect == "snowflake":
|
if self.dialect == "snowflake":
|
||||||
connection.exec_driver_sql(
|
connection.exec_driver_sql(
|
||||||
@ -426,7 +426,7 @@ class SQLDatabase:
|
|||||||
def run(
|
def run(
|
||||||
self,
|
self,
|
||||||
command: str,
|
command: str,
|
||||||
fetch: Union[Literal["all"], Literal["one"]] = "all",
|
fetch: Literal["all", "one"] = "all",
|
||||||
include_columns: bool = False,
|
include_columns: bool = False,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Execute a SQL command and return a string representing the results.
|
"""Execute a SQL command and return a string representing the results.
|
||||||
@ -471,7 +471,7 @@ class SQLDatabase:
|
|||||||
def run_no_throw(
|
def run_no_throw(
|
||||||
self,
|
self,
|
||||||
command: str,
|
command: str,
|
||||||
fetch: Union[Literal["all"], Literal["one"]] = "all",
|
fetch: Literal["all", "one"] = "all",
|
||||||
include_columns: bool = False,
|
include_columns: bool = False,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Execute a SQL command and return a string representing the results.
|
"""Execute a SQL command and return a string representing the results.
|
||||||
|
@ -98,7 +98,7 @@ class FewShotPromptTemplate(_FewShotPromptTemplateMixin, StringPromptTemplate):
|
|||||||
prefix: str = ""
|
prefix: str = ""
|
||||||
"""A prompt template string to put before the examples."""
|
"""A prompt template string to put before the examples."""
|
||||||
|
|
||||||
template_format: Union[Literal["f-string"], Literal["jinja2"]] = "f-string"
|
template_format: Literal["f-string", "jinja2"] = "f-string"
|
||||||
"""The format of the prompt template. Options are: 'f-string', 'jinja2'."""
|
"""The format of the prompt template. Options are: 'f-string', 'jinja2'."""
|
||||||
|
|
||||||
@root_validator()
|
@root_validator()
|
||||||
|
@ -65,7 +65,7 @@ class PromptTemplate(StringPromptTemplate):
|
|||||||
template: str
|
template: str
|
||||||
"""The prompt template."""
|
"""The prompt template."""
|
||||||
|
|
||||||
template_format: Union[Literal["f-string"], Literal["jinja2"]] = "f-string"
|
template_format: Literal["f-string", "jinja2"] = "f-string"
|
||||||
"""The format of the prompt template. Options are: 'f-string', 'jinja2'."""
|
"""The format of the prompt template. Options are: 'f-string', 'jinja2'."""
|
||||||
|
|
||||||
validate_template: bool = False
|
validate_template: bool = False
|
||||||
|
Loading…
Reference in New Issue
Block a user