viruPVS/langchain-docs huggingface dataset:
langchain_community.utilities.github.GitHubAPIWrapper¶
class langchain_community.utilities.github.GitHubAPIWrapper[source]¶
Bases: BaseModel
Wrapper for GitHub API.
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 active_branch: Optional[str] = None¶
param github_app_id: Optional[str] = None¶
param github_app_private_key: Optional[str] = None¶
param github_base_branch: Optional[str] = None¶
param github_repository: Optional[str] = None¶
comment_on_issue(comment_query: str) → str[source]¶
Adds a comment to a github issue
Parameters:
comment_query(str): a string which contains the issue number,
two newlines, and the comment.
for example: “1
Working on it now”
adds the comment “working on it now” to issue 1
Returns:str: A success or failure message
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
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 – fields to include in new model
exclude – fields to exclude from new model, as with values this takes precedence over include
exclude – fields to exclude from new model, as with values this takes precedence over include
update – 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 – set to True to make a deep copy of the model
Returns
new model instance
create_branch(proposed_branch_name: str) → str[source]¶
Create a new branch, and set it as the active bot branch.
Equivalent to git switch -c proposed_branch_name
If the proposed branch already exists, we append _v1 then _v2…
until a unique name is found.
Returns
A plaintext success message.
Return type
str
create_file(file_query: str) → str[source]¶
Creates a new file on the Github 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
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
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
create_review_request(reviewer_username: str) → str[source]¶
Creates a review request on THE open pull request
that matches the current active_branch.
Parameters
reviewer_username (str) – The username of the person who is being requested
Returns
A message confirming the creation of the review request
Return type
str
Returns
A message confirming the creation of the review request
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
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.
classmethod from_orm(obj: Any) → Model¶
get_files_from_directory(directory_path: str) → str[source]¶
Recursively fetches files from a directory in the repo.
Parameters
directory_path (str) – Path to the directory
Returns
List of file paths, or an error message.
Return type
str
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 github issue
:type issue_number: int
Returns
A dictionary containing the issue’s title,
body, comments as a string, and the username of the user
who opened the issue
Return type
dict
get_issues() → str[source]¶
Fetches all open issues from the repo excluding pull requests
Returns
A plaintext report containing the number of issues
and each issue’s title and number.
Return type
str
get_pull_request(pr_number: int) → Dict[str, Any][source]¶
Fetches a specific pull request and its first 10 comments,
Fetches a specific pull request and its first 10 comments,
limited by max_tokens.
Parameters
pr_number (int) – The number for the Github pull
max_tokens (int) – The maximum number of tokens in the response
Returns
A dictionary containing the pull’s title, body,
and comments as a string
Return type
dict
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().
list_branches_in_repo() → str[source]¶
Fetches a list of all branches in the repository.
Returns
A plaintext report containing the names of the branches.
Return type
str
list_files_in_bot_branch() → str[source]¶
Fetches all files in the active branch of the repo,
the branch the bot uses to make changes.
Returns
A plaintext list containing the the filepaths in the branch.
Return type
str
list_files_in_main_branch() → str[source]¶
Fetches all files in the main branch of the repo.
Returns
A plaintext report containing the paths and names of the files.
Return type
str
list_open_pull_requests() → str[source]¶
Fetches all open PRs from the repo
Returns
A plaintext report containing the number of PRs
Returns
A plaintext report containing the number of PRs
and each PR’s title and number.
Return type
str
list_pull_request_files(pr_number: int) → List[Dict[str, Any]][source]¶
Fetches the full text of all files in a PR. Truncates after first 3k tokens.
# TODO: Enhancement to summarize files with ctags if they’re getting long.
Parameters
pr_number (int) – The number of the pull request on Github
Returns
A dictionary containing the issue’s title,
body, and comments as a string
Return type
dict
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → 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 Github Issue objects
:type issues: List[Issue]
Returns
A dictionary of issue titles and numbers
Return type
List[dict]
classmethod parse_obj(obj: Any) → Model¶
parse_pull_requests(pull_requests: List[PullRequest]) → List[dict][source]¶
Extracts title and number from each Issue and puts them in a dictionary
:param issues: A list of Github Issue objects
:type issues: List[Issue]
Returns
A dictionary of issue titles and numbers
Return type
List[dict]
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
read_file(file_path: str) → str[source]¶
Read a file from this agent’s branch, defined by self.active_branch,
Read a file from this agent’s branch, defined by self.active_branch,
which supports PR branches.
:param file_path: the file path
:type file_path: str
Returns
The file decoded as a string, or an error message if not found
Return type
str
run(mode: str, query: str) → str[source]¶
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶
search_code(query: str) → str[source]¶
Searches code in the repository.
# Todo: limit total tokens returned…
Parameters
query (str) – The search query
Returns
A string containing, at most, the top 5 search results
Return type
str
search_issues_and_prs(query: str) → str[source]¶
Searches issues and pull requests in the repository.
Parameters
query (str) – The search query
Returns
A string containing the first 5 issues and pull requests
Return type
str
set_active_branch(branch_name: str) → str[source]¶
Equivalent to git checkout branch_name for this Agent.
Clones formatting from Github.
Returns an Error (as a string) if branch doesn’t exist.
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
langchain_community.utilities.dalle_image_generator.DallEAPIWrapper¶
class langchain_community.utilities.dalle_image_generator.DallEAPIWrapper[source]¶
Bases: BaseModel
Wrapper for OpenAI’s DALL-E Image Generator.
https://platform.openai.com/docs/guides/images/generations?context=node
Usage instructions:
pip install openai
save your OPENAI_API_KEY in an environment variable
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 default_headers: Optional[Mapping[str, str]] = None¶
param default_query: Optional[Mapping[str, object]] = None¶
param http_client: Optional[Any] = None¶
Optional httpx.Client.
param max_retries: int = 2¶
Maximum number of retries to make when generating.
param model_kwargs: Dict[str, Any] [Optional]¶
param model_name: str = 'dall-e-2' (alias 'model')¶
param n: int = 1¶
Number of images to generate
param openai_api_base: Optional[str] = None (alias 'base_url')¶
Base URL path for API requests, leave blank if not using a proxy or service
emulator.
param openai_api_key: Optional[str] = None (alias 'api_key')¶
Automatically inferred from env var OPENAI_API_KEY if not provided.
param openai_organization: Optional[str] = None (alias 'organization')¶
Automatically inferred from env var OPENAI_ORG_ID if not provided.
param openai_proxy: Optional[str] = None¶
param quality: Optional[str] = 'standard'¶
Quality of the image that will be generated
param request_timeout: Optional[Union[float, Tuple[float, float], Any]] = None (alias 'timeout')¶
param separator: str = '\n'¶
Separator to use when multiple URLs are returned.
param size: str = '1024x1024'¶
Size of image to generate
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
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 – fields to include in new model
exclude – fields to exclude from new model, as with values this takes precedence over include
update – 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 – set to True to make a deep copy of the model
Returns
new model instance
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.
classmethod from_orm(obj: Any) → Model¶
classmethod from_orm(obj: Any) → Model¶
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().
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
classmethod parse_obj(obj: Any) → Model¶
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
run(query: str) → str[source]¶
Run query through OpenAI and parse result.
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶
classmethod update_forward_refs(**localns: Any) → None¶
Try to update ForwardRefs on fields based on this Model, globalns and localns.
classmethod validate(value: Any) → Model¶
Examples using DallEAPIWrapper¶
Dall-E Image Generator
langchain_community.utilities.vertexai.get_client_info¶
langchain_community.utilities.vertexai.get_client_info(module: Optional[str] = None) → ClientInfo[source]¶
Returns a custom user agent header.
Parameters
module (Optional[str]) – Optional. The module for a custom user agent header.
Returns
google.api_core.gapic_v1.client_info.ClientInfo
langchain_community.utilities.tensorflow_datasets.TensorflowDatasets¶
class langchain_community.utilities.tensorflow_datasets.TensorflowDatasets[source]¶
Bases: BaseModel
Access to the TensorFlow Datasets.
The Current implementation can work only with datasets that fit in a memory.
TensorFlow Datasets is a collection of datasets ready to use, with TensorFlow
or other Python ML frameworks, such as Jax. All datasets are exposed
as tf.data.Datasets.
To get started see the Guide: https://www.tensorflow.org/datasets/overview and
the list of datasets: https://www.tensorflow.org/datasets/catalog/
overview#all_datasets
You have to provide the sample_to_document_function: a function thata sample from the dataset-specific format to the Document.
dataset_name¶
the name of the dataset to load
split_name¶
the name of the split to load. Defaults to “train”.
load_max_docs¶
a limit to the number of loaded documents. Defaults to 100.
sample_to_document_function¶
a function that converts a dataset sample
to a Document
Example
from langchain_community.utilities import TensorflowDatasets
def mlqaen_example_to_document(example: dict) -> Document:
    return Document(
        page_content=decode_to_str(example["context"]),
        metadata={
            "id": decode_to_str(example["id"]),
            "title": decode_to_str(example["title"]),
            "question": decode_to_str(example["question"]),
            "answer": decode_to_str(example["answers"]["text"][0]),
        },
    )
tsds_client = TensorflowDatasets(
        dataset_name="mlqa/en",
        split_name="train",
        load_max_docs=MAX_DOCS,
        sample_to_document_function=mlqaen_example_to_document,
    )
sample_to_document_function=mlqaen_example_to_document,
    )
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 dataset_name: str = ''¶
param load_max_docs: int = 100¶
param sample_to_document_function: Optional[Callable[[Dict], langchain_core.documents.base.Document]] = None¶
param split_name: str = 'train'¶
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
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 – fields to include in new model
exclude – fields to exclude from new model, as with values this takes precedence over include
update – 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 – set to True to make a deep copy of the model
Returns
new model instance
deep – set to True to make a deep copy of the model
Returns
new model instance
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.
classmethod from_orm(obj: Any) → Model¶
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().
lazy_load() → Iterator[Document][source]¶
Download a selected dataset lazily.
Returns: an iterator of Documents.
load() → List[Document][source]¶
Download a selected dataset.
Returns: a list of Documents.
classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) → Model¶
classmethod parse_obj(obj: Any) → Model¶
langchain_community.utilities.scenexplain.SceneXplainAPIWrapper¶
class langchain_community.utilities.scenexplain.SceneXplainAPIWrapper[source]¶
Bases: BaseSettings, BaseModel
Wrapper for SceneXplain API.
In order to set this up, you need API key for the SceneXplain API.
You can obtain a key by following the steps below.
- Sign up for a free account at https://scenex.jina.ai/.
- Navigate to the API Access page (https://scenex.jina.ai/api)
and create a new API key.
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 scenex_api_key: str [Required]¶
param scenex_api_url: str = 'https://api.scenex.jina.ai/v1/describe'¶
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
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 – fields to include in new model
exclude – fields to exclude from new model, as with values this takes precedence over include
update – values to change/add in the new model. Note: the data is not validated before creating
run(image: str) → str[source]¶
Run SceneXplain image explainer.
classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') → DictStrAny¶
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) → unicode¶
classmethod update_forward_refs(**localns: Any) → None¶
Try to update ForwardRefs on fields based on this Model, globalns and localns.
classmethod validate(value: Any) → Model¶
langchain_community.utilities.clickup.Space¶
class langchain_community.utilities.clickup.Space(id: int, name: str, private: bool, enabled_features: Dict[str, Any])[source]¶
Component class for a space.
Attributes
id
name
private
enabled_features
Methods
__init__(id, name, private, enabled_features)
from_data(data)
__init__(id: int, name: str, private: bool, enabled_features: Dict[str, Any]) → None¶
classmethod from_data(data: Dict[str, Any]) → Space[source]¶
langchain_community.utilities.clickup.parse_dict_through_component¶
langchain_community.utilities.clickup.parse_dict_through_component(data: dict, component: Type[Component], fault_tolerant: bool = False) → Dict[source]¶
Parse a dictionary by creating
a component and then turning it back into a dictionary.
This helps with two things
1. Extract and format data from a dictionary according to schema
2. Provide a central place to do this in a fault-tolerant way
langchain_community.utilities.vertexai.init_vertexai¶
langchain_community.utilities.vertexai.init_vertexai(project: Optional[str] = None, location: Optional[str] = None, credentials: Optional[Credentials] = None) → None[source]¶
Init vertexai.
Parameters
project – The default GCP project to use when making Vertex API calls.
location – The default location to use when making API calls.
credentials – The default custom
credentials to use when making API calls. If not provided credentials
will be ascertained from the environment.
Raises
ImportError – If importing vertexai SDK did not succeed.
langchain_community.utilities.max_compute.MaxComputeAPIWrapper¶
class langchain_community.utilities.max_compute.MaxComputeAPIWrapper(client: ODPS)[source]¶
Interface for querying Alibaba Cloud MaxCompute tables.
Initialize MaxCompute document loader.
Parameters
client – odps.ODPS MaxCompute client object.
Methods
__init__(client)
Initialize MaxCompute document loader.
from_params(endpoint, project, *[, ...])
Convenience constructor that builds the odsp.ODPS MaxCompute client from
lazy_query(query)
query(query)
__init__(client: ODPS)[source]¶
Initialize MaxCompute document loader.
Parameters
client – odps.ODPS MaxCompute client object.
classmethod from_params(endpoint: str, project: str, *, access_id: Optional[str] = None, secret_access_key: Optional[str] = None) → MaxComputeAPIWrapper[source]¶
Convenience constructor that builds the odsp.ODPS MaxCompute client fromgiven parameters.
Parameters
endpoint – MaxCompute endpoint.
project – A project is a basic organizational unit of MaxCompute, which is
similar to a database.
access_id – MaxCompute access ID. Should be passed in directly or set as the
environment variable MAX_COMPUTE_ACCESS_ID.
secret_access_key – MaxCompute secret access key. Should be passed in
directly or set as the environment variable
MAX_COMPUTE_SECRET_ACCESS_KEY.
lazy_query(query: str) → Iterator[dict][source]¶
query(query: str) → List[dict][source]¶