Tony20100/langchain_full huggingface dataset:
Parameters
_fields_set (Optional[SetStr]) – 
values (Any) – 
Return type
Model
copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶
Duplicate a model, optionally choose which fields to include, exclude and change.
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating
the new model: you should trust this data
deep (bool) – set to True to make a deep copy of the model
self (Model) – 
Returns
new model instance
Return type
Model
create_file(file_query: str) → str[source]¶
Creates a new file on the gitlab repo
Parameters:
file_query(str): a string which contains the file path
and the file contents. The file path is the first line
in the string, and the contents are the rest of the string.
For example, “hello_world.md
# Hello World!”
Returns:str: A success or failure message
Parameters
file_query (str) – 
Return type
str
create_pull_request(pr_query: str) → str[source]¶
Makes a pull request from the bot’s branch to the base branch
Parameters:
pr_query(str): a string which contains the PR title
and the PR body. The title is the first line
and the PR body. The title is the first line
in the string, and the body are the rest of the string.
For example, “Updated README
made changes to add info”
Returns:str: A success or failure message
Parameters
pr_query (str) – 
Return type
str
delete_file(file_path: str) → str[source]¶
Deletes a file from the repo
:param file_path: Where the file is
:type file_path: str
Returns
Success or failure message
Return type
str
Parameters
file_path (str) – 
dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) → DictStrAny¶
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
by_alias (bool) – 
skip_defaults (Optional[bool]) – 
exclude_unset (bool) – 
exclude_defaults (bool) – 
exclude_none (bool) – 
Return type
DictStrAny
classmethod from_orm(obj: Any) → Model¶
Parameters
obj (Any) – 
Return type
Model
get_issue(issue_number: int) → Dict[str, Any][source]¶
Fetches a specific issue and its first 10 comments
:param issue_number: The number for the gitlab issue
:type issue_number: int
Returns
A dictionary containing the issue’s title,
:type issue_number: int
Returns
A dictionary containing the issue’s title,
body, and comments as a string
Return type
dict
Parameters
issue_number (int) – 
get_issues() → str[source]¶
Fetches all open issues from the repo
Returns
A plaintext report containing the number of issues
and each issue’s title and number.
Return type
str
json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) → unicode¶
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – 
by_alias (bool) – 
skip_defaults (Optional[bool]) – 
exclude_unset (bool) – 
exclude_defaults (bool) – 
exclude_none (bool) – 
encoder (Optional[Callable[[Any], Any]]) – 
models_as_dict (bool) – 
dumps_kwargs (Any) – 
Return type
unicode
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
Parameters
path (Union[str, Path]) – 
content_type (unicode) – 
encoding (unicode) – 
proto (Protocol) – 
allow_pickle (bool) – 
Return type
Model
parse_issues(issues: List[Issue]) → List[dict][source]¶
Extracts title and number from each Issue and puts them in a dictionary
:param issues: A list of gitlab Issue objects
:type issues: List[Issue]
Returns
A dictionary of issue titles and numbers
Return type
List[dict]
Parameters
issues (List[Issue]) – 
classmethod parse_obj(obj: Any) → Model¶
Parameters
obj (Any) – 
Return type
Model
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
b (Union[str, bytes]) – 
content_type (unicode) – 
encoding (unicode) – 
proto (Protocol) – 
allow_pickle (bool) – 
Return type
Model
read_file(file_path: str) → str[source]¶
Reads a file from the gitlab repo
:param file_path: the file path
:type file_path: str
Returns
The file decoded as a string
Return type
str
Parameters
file_path (str) – 
run(mode: str, query: str) → str[source]¶
Parameters
mode (str) – 
query (str) – 
Return type
str
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
Parameters
by_alias (bool) – 
ref_template (unicode) – 
Return type
DictStrAny
ref_template (unicode) – 
Return type
DictStrAny
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶
Parameters
by_alias (bool) – 
ref_template (unicode) – 
dumps_kwargs (Any) – 
Return type
unicode
update_file(file_query: str) → str[source]¶
Updates a file with new content.
:param file_query: Contains the file path and the file contents.
The old file contents is wrapped in OLD <<<< and >>>> OLD
The new file contents is wrapped in NEW <<<< and >>>> NEW
For example:
test/hello.txt
OLD <<<<
Hello Earth!
>>>> OLD
NEW <<<<
Hello Mars!
>>>> NEW
Returns
A success or failure message
Parameters
file_query (str) – 
Return type
str
classmethod update_forward_refs(**localns: Any) → None¶
Try to update ForwardRefs on fields based on this Model, globalns and localns.
Parameters
localns (Any) – 
Return type
None
classmethod validate(value: Any) → Model¶
Parameters
value (Any) – 
Return type
Model
Examples using GitLabAPIWrapper¶
Gitlab
langchain_community.utilities.sql_database.SQLDatabase¶
class langchain_community.utilities.sql_database.SQLDatabase(engine: Engine, schema: Optional[str] = None, metadata: Optional[MetaData] = None, ignore_tables: Optional[List[str]] = None, include_tables: Optional[List[str]] = None, sample_rows_in_table_info: int = 3, indexes_in_table_info: bool = False, custom_table_info: Optional[dict] = None, view_support: bool = False, max_string_length: int = 300, lazy_table_reflection: bool = False)[source]¶
SQLAlchemy wrapper around a database.
Create engine from database URI.
Attributes
dialect
Return string representation of dialect to use.
table_info
Information about all tables in the database.
Methods
__init__(engine[, schema, metadata, ...])
Create engine from database URI.
from_cnosdb([url, user, password, tenant, ...])
Class method to create an SQLDatabase instance from a CnosDB connection.
from_databricks(catalog, schema[, host, ...])
Class method to create an SQLDatabase instance from a Databricks connection.
from_uri(database_uri[, engine_args])
Construct a SQLAlchemy engine from URI.
get_context()
Return db context that you may want in agent prompt.
get_table_info([table_names])
Get information about specified tables.
get_table_info_no_throw([table_names])
Get information about specified tables.
get_table_names()
[Deprecated] Get names of tables available.
get_usable_table_names()
Get names of tables available.
run(command[, fetch, include_columns, ...])
Execute a SQL command and return a string representing the results.
run_no_throw(command[, fetch, ...])
Execute a SQL command and return a string representing the results.
Execute a SQL command and return a string representing the results.
Parameters
engine (Engine) – 
schema (Optional[str]) – 
metadata (Optional[MetaData]) – 
ignore_tables (Optional[List[str]]) – 
include_tables (Optional[List[str]]) – 
sample_rows_in_table_info (int) – 
indexes_in_table_info (bool) – 
custom_table_info (Optional[dict]) – 
view_support (bool) – 
max_string_length (int) – 
lazy_table_reflection (bool) – 
__init__(engine: Engine, schema: Optional[str] = None, metadata: Optional[MetaData] = None, ignore_tables: Optional[List[str]] = None, include_tables: Optional[List[str]] = None, sample_rows_in_table_info: int = 3, indexes_in_table_info: bool = False, custom_table_info: Optional[dict] = None, view_support: bool = False, max_string_length: int = 300, lazy_table_reflection: bool = False)[source]¶
Create engine from database URI.
Parameters
engine (Engine) – 
schema (Optional[str]) – 
metadata (Optional[MetaData]) – 
ignore_tables (Optional[List[str]]) – 
include_tables (Optional[List[str]]) – 
sample_rows_in_table_info (int) – 
indexes_in_table_info (bool) – 
custom_table_info (Optional[dict]) – 
view_support (bool) – 
max_string_length (int) – 
lazy_table_reflection (bool) – 
classmethod from_cnosdb(url: str = '127.0.0.1:8902', user: str = 'root', password: str = '', tenant: str = 'cnosdb', database: str = 'public') → SQLDatabase[source]¶
Class method to create an SQLDatabase instance from a CnosDB connection.
This method requires the ‘cnos-connector’ package. If not installed, it
can be added using pip install cnos-connector.
Parameters
url (str) – The HTTP connection host name and port number of the CnosDB
service, excluding “http://” or “https://”, with a default value
of “127.0.0.1:8902”.
user (str) – The username used to connect to the CnosDB service, with a
default value of “root”.
password (str) – The password of the user connecting to the CnosDB service,
with a default value of “”.
tenant (str) – The name of the tenant used to connect to the CnosDB service,
with a default value of “cnosdb”.
database (str) – The name of the database in the CnosDB tenant.
Returns
An instance of SQLDatabase configured with the provided
CnosDB connection details.
Return type
SQLDatabase
classmethod from_databricks(catalog: str, schema: str, host: Optional[str] = None, api_token: Optional[str] = None, warehouse_id: Optional[str] = None, cluster_id: Optional[str] = None, engine_args: Optional[dict] = None, **kwargs: Any) → SQLDatabase[source]¶
Class method to create an SQLDatabase instance from a Databricks connection.
This method requires the ‘databricks-sql-connector’ package. If not installed,
it can be added using pip install databricks-sql-connector.
Parameters
catalog (str) – The catalog name in the Databricks database.
schema (str) – The schema name in the catalog.
host (Optional[str]) – The Databricks workspace hostname, excluding
host (Optional[str]) – The Databricks workspace hostname, excluding
‘https://’ part. If not provided, it attempts to fetch from the
environment variable ‘DATABRICKS_HOST’. If still unavailable and if
running in a Databricks notebook, it defaults to the current workspace
hostname. Defaults to None.
api_token (Optional[str]) – The Databricks personal access token for
accessing the Databricks SQL warehouse or the cluster. If not provided,
it attempts to fetch from ‘DATABRICKS_TOKEN’. If still unavailable
and running in a Databricks notebook, a temporary token for the current
user is generated. Defaults to None.
warehouse_id (Optional[str]) – The warehouse ID in the Databricks SQL. If
provided, the method configures the connection to use this warehouse.
Cannot be used with ‘cluster_id’. Defaults to None.
cluster_id (Optional[str]) – The cluster ID in the Databricks Runtime. If
provided, the method configures the connection to use this cluster.
Cannot be used with ‘warehouse_id’. If running in a Databricks notebook
and both ‘warehouse_id’ and ‘cluster_id’ are None, it uses the ID of the
cluster the notebook is attached to. Defaults to None.
engine_args (Optional[dict]) – The arguments to be used when connecting
Databricks. Defaults to None.
**kwargs (Any) – Additional keyword arguments for the from_uri method.
Returns
An instance of SQLDatabase configured with the providedDatabricks connection details.
Return type
SQLDatabase
Raises
ValueError – If ‘databricks-sql-connector’ is not found, or if both
    ‘warehouse_id’ and ‘cluster_id’ are provided, or if neither
    ‘warehouse_id’ nor ‘cluster_id’ are provided and it’s not executing
‘warehouse_id’ nor ‘cluster_id’ are provided and it’s not executing
    inside a Databricks notebook.
classmethod from_uri(database_uri: str, engine_args: Optional[dict] = None, **kwargs: Any) → SQLDatabase[source]¶
Construct a SQLAlchemy engine from URI.
Parameters
database_uri (str) – 
engine_args (Optional[dict]) – 
kwargs (Any) – 
Return type
SQLDatabase
get_context() → Dict[str, Any][source]¶
Return db context that you may want in agent prompt.
Return type
Dict[str, Any]
get_table_info(table_names: Optional[List[str]] = None) → str[source]¶
Get information about specified tables.
Follows best practices as specified in: Rajkumar et al, 2022
(https://arxiv.org/abs/2204.00498)
If sample_rows_in_table_info, the specified number of sample rows will be
appended to each table description. This can increase performance as
demonstrated in the paper.
Parameters
table_names (Optional[List[str]]) – 
Return type
str
get_table_info_no_throw(table_names: Optional[List[str]] = None) → str[source]¶
Get information about specified tables.
Follows best practices as specified in: Rajkumar et al, 2022
(https://arxiv.org/abs/2204.00498)
If sample_rows_in_table_info, the specified number of sample rows will be
appended to each table description. This can increase performance as
demonstrated in the paper.
Parameters
table_names (Optional[List[str]]) – 
Return type
str
get_table_names() → Iterable[str][source]¶
[Deprecated] Get names of tables available.
Notes
[Deprecated] Get names of tables available.
Notes
Deprecated since version langchain-community==0.0.1: Use get_usable_table_names instead.
Return type
Iterable[str]
get_usable_table_names() → Iterable[str][source]¶
Get names of tables available.
Return type
Iterable[str]
run(command: Union[str, Executable], fetch: Literal['all', 'one', 'cursor'] = 'all', include_columns: bool = False, *, parameters: Optional[Dict[str, Any]] = None, execution_options: Optional[Dict[str, Any]] = None) → Union[str, Sequence[Dict[str, Any]], Result[Any]][source]¶
Execute a SQL command and return a string representing the results.
If the statement returns rows, a string of the results is returned.
If the statement returns no rows, an empty string is returned.
Parameters
command (Union[str, Executable]) – 
fetch (Literal['all', 'one', 'cursor']) – 
include_columns (bool) – 
parameters (Optional[Dict[str, Any]]) – 
execution_options (Optional[Dict[str, Any]]) – 
Return type
Union[str, Sequence[Dict[str, Any]], Result[Any]]
run_no_throw(command: str, fetch: Literal['all', 'one'] = 'all', include_columns: bool = False, *, parameters: Optional[Dict[str, Any]] = None, execution_options: Optional[Dict[str, Any]] = None) → Union[str, Sequence[Dict[str, Any]], Result[Any]][source]¶
Execute a SQL command and return a string representing the results.
If the statement returns rows, a string of the results is returned.
If the statement returns no rows, an empty string is returned.
If the statement throws an error, the error message is returned.
Parameters
If the statement throws an error, the error message is returned.
Parameters
command (str) – 
fetch (Literal['all', 'one']) – 
include_columns (bool) – 
parameters (Optional[Dict[str, Any]]) – 
execution_options (Optional[Dict[str, Any]]) – 
Return type
Union[str, Sequence[Dict[str, Any]], Result[Any]]
Examples using SQLDatabase¶
Build a Question/Answering system over SQL data
CnosDB
How to better prompt when doing SQL question-answering
How to deal with large databases when doing SQL question-answering
How to do query validation as part of SQL question-answering
How to do question answering over CSVs
Rebuff
SQL Database
langchain_community.utilities.google_serper.GoogleSerperAPIWrapper¶
class langchain_community.utilities.google_serper.GoogleSerperAPIWrapper[source]¶
Bases: BaseModel
Wrapper around the Serper.dev Google Search API.
You can create a free API key at https://serper.dev.
To use, you should have the environment variable SERPER_API_KEY
set with your API key, or pass serper_api_key as a named parameter
to the constructor.
Example
from langchain_community.utilities import GoogleSerperAPIWrapper
google_serper = GoogleSerperAPIWrapper()
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param aiosession: Optional[ClientSession] = None¶
param gl: str = 'us'¶
param hl: str = 'en'¶
param k: int = 10¶
param serper_api_key: Optional[str] = None¶
param tbs: Optional[str] = None¶
param type: Literal['news', 'search', 'places', 'images'] = 'search'¶
async aresults(query: str, **kwargs: Any) → Dict[source]¶
Run query through GoogleSearch.
Parameters
query (str) – 
kwargs (Any) – 
Return type
Dict
async arun(query: str, **kwargs: Any) → str[source]¶
Run query through GoogleSearch and parse result async.
Parameters
query (str) – 
kwargs (Any) – 
Return type
str
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
dumps_kwargs (Any) – 
Return type
unicode
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
path (Union[str, Path]) – 
content_type (unicode) – 
encoding (unicode) – 
proto (Protocol) – 
allow_pickle (bool) – 
Return type
Model
classmethod parse_obj(obj: Any) → Model¶
Parameters
obj (Any) – 
Return type
Model
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
Parameters
b (Union[str, bytes]) – 
content_type (unicode) – 
encoding (unicode) – 
proto (Protocol) – 
allow_pickle (bool) – 
Return type
Model
results(query: str, **kwargs: Any) → Dict[source]¶
Run query through GoogleSearch.
Parameters
query (str) – 
kwargs (Any) – 
Return type
Dict
run(query: str, **kwargs: Any) → str[source]¶
Run query through GoogleSearch and parse result.
Parameters
query (str) – 
kwargs (Any) – 
Return type
str
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
Parameters
by_alias (bool) – 
ref_template (unicode) – 
Return type
DictStrAny
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶
Parameters
Parameters
by_alias (bool) – 
ref_template (unicode) – 
dumps_kwargs (Any) – 
Return type
unicode
classmethod update_forward_refs(**localns: Any) → None¶
Try to update ForwardRefs on fields based on this Model, globalns and localns.
Parameters
localns (Any) – 
Return type
None
classmethod validate(value: Any) → Model¶
Parameters
value (Any) – 
Return type
Model
Examples using GoogleSerperAPIWrapper¶
Google
Google Serper
Serper - Google Search API
langchain_community.utilities.clickup.extract_dict_elements_from_component_fields¶
langchain_community.utilities.clickup.extract_dict_elements_from_component_fields(data: dict, component: Type[Component]) → dict[source]¶
Extract elements from a dictionary.
Parameters
data (dict) – The dictionary to extract elements from.
component (Type[Component]) – The component to extract elements from.
Returns
A dictionary containing the elements from the input dictionary that are also
in the component.
Return type
dict
langchain_community.utilities.redis.TokenEscaper¶
class langchain_community.utilities.redis.TokenEscaper(escape_chars_re: Optional[Pattern] = None)[source]¶
Escape punctuation within an input string.
Attributes
DEFAULT_ESCAPED_CHARS
Methods
__init__([escape_chars_re])
escape(value)
Parameters
escape_chars_re (Optional[Pattern]) – 
__init__(escape_chars_re: Optional[Pattern] = None)[source]¶
Parameters
escape_chars_re (Optional[Pattern]) – 
escape(value: str) → str[source]¶
Parameters
value (str) – 
Return type
str
langchain_community.utilities.requests.Requests¶
class langchain_community.utilities.requests.Requests[source]¶
Bases: BaseModel
Wrapper around requests to handle auth and async.
The main purpose of this wrapper is to handle authentication (by saving
headers) and enable easy async methods on the same base object.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param aiosession: Optional[ClientSession] = None¶
param auth: Optional[Any] = None¶
param headers: Optional[Dict[str, str]] = None¶
adelete(url: str, **kwargs: Any) → AsyncGenerator[ClientResponse, None][source]¶
DELETE the URL and return the text asynchronously.
Parameters
url (str) – 
kwargs (Any) – 
Return type
AsyncGenerator[ClientResponse, None]
aget(url: str, **kwargs: Any) → AsyncGenerator[ClientResponse, None][source]¶
GET the URL and return the text asynchronously.
Parameters
url (str) – 
kwargs (Any) – 
Return type
AsyncGenerator[ClientResponse, None]
apatch(url: str, data: Dict[str, Any], **kwargs: Any) → AsyncGenerator[ClientResponse, None][source]¶
PATCH the URL and return the text asynchronously.
Parameters
url (str) – 
data (Dict[str, Any]) – 
kwargs (Any) – 
Return type
AsyncGenerator[ClientResponse, None]
apost(url: str, data: Dict[str, Any], **kwargs: Any) → AsyncGenerator[ClientResponse, None][source]¶
POST to the URL and return the text asynchronously.
Parameters
url (str) – 
data (Dict[str, Any]) –
Parameters
url (str) – 
data (Dict[str, Any]) – 
kwargs (Any) – 
Return type
AsyncGenerator[ClientResponse, None]
aput(url: str, data: Dict[str, Any], **kwargs: Any) → AsyncGenerator[ClientResponse, None][source]¶
PUT the URL and return the text asynchronously.
Parameters
url (str) – 
data (Dict[str, Any]) – 
kwargs (Any) – 
Return type
AsyncGenerator[ClientResponse, None]
classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) → Model¶
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data.
Default values are respected, but no other validation is performed.
Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
Parameters
_fields_set (Optional[SetStr]) – 
values (Any) – 
Return type
Model
copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) → Model¶
Duplicate a model, optionally choose which fields to include, exclude and change.
Parameters
include (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to include in new model
exclude (Optional[Union[AbstractSetIntStr, MappingIntStrAny]]) – fields to exclude from new model, as with values this takes precedence over include
update (Optional[DictStrAny]) – values to change/add in the new model. Note: the data is not validated before creating
the new model: you should trust this data