id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
36,845
import logging from typing import Any, Dict, List, Optional, cast from uuid import uuid4 from llama_index.legacy.bridge.pydantic import Field, PrivateAttr from llama_index.legacy.schema import BaseNode from llama_index.legacy.vector_stores.types import ( BasePydanticVectorStore, MetadataFilters, VectorStore...
null
36,846
import logging import math from typing import Any, List from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.types import ( MetadataFilters, VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.legacy.vector_stores.utils import...
Translate standard metadata filters to Bagel specific spec.
36,847
from typing import Any, Dict, List, Optional from llama_index.legacy.schema import BaseNode, MetadataMode from llama_index.legacy.vector_stores.types import ( VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.legacy.vector_stores.utils import ( metadata_dict_to_node, node_to_...
Check if variable is not null and raise error accordingly.
36,848
from typing import Any, Dict, List, Optional from llama_index.legacy.schema import BaseNode, MetadataMode from llama_index.legacy.vector_stores.types import ( VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.legacy.vector_stores.utils import ( metadata_dict_to_node, node_to_...
Sort first element to match the index_name if exists.
36,849
from typing import Any, Dict, List, Optional from llama_index.legacy.schema import BaseNode, MetadataMode from llama_index.legacy.vector_stores.types import ( VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.legacy.vector_stores.utils import ( metadata_dict_to_node, node_to_...
Convert BaseNode object to a dictionary to be imported into Neo4j.
36,850
from typing import Any, Dict, List, Optional from llama_index.legacy.schema import BaseNode, MetadataMode from llama_index.legacy.vector_stores.types import ( VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.legacy.vector_stores.utils import ( metadata_dict_to_node, node_to_...
null
36,851
from typing import Any, Dict, List, Optional from llama_index.legacy.schema import BaseNode, MetadataMode from llama_index.legacy.vector_stores.types import ( VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.legacy.vector_stores.utils import ( metadata_dict_to_node, node_to_...
Remove Lucene special characters.
36,852
import logging from typing import Any, List, Optional import numpy as np from pandas import DataFrame from llama_index.legacy.schema import ( BaseNode, MetadataMode, NodeRelationship, RelatedNodeInfo, TextNode, ) from llama_index.legacy.vector_stores.types import ( MetadataFilters, VectorSto...
Translate standard metadata filters to Lance specific spec.
36,853
import logging from typing import Any, List, Optional import numpy as np from pandas import DataFrame from llama_index.legacy.schema import ( BaseNode, MetadataMode, NodeRelationship, RelatedNodeInfo, TextNode, ) from llama_index.legacy.vector_stores.types import ( MetadataFilters, VectorSto...
null
36,854
import logging import uuid from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, cast from llama_index.legacy.bridge.pydantic import ( # type: ignore BaseModel, Field, PrivateAttr, ) from llama_index.legacy.indices.service_context import ServiceContext from llama_index.legacy.schema import...
Set the configuration for Google Generative AI API. Parameters are optional, Normally, the defaults should work fine. If provided, they will override the default values in the Config class. See the docstring in `genai_extension.py` for more details. auth_credentials: Optional["credentials.Credentials"] = None, Use this...
36,855
import logging import uuid from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, cast from llama_index.legacy.bridge.pydantic import ( # type: ignore BaseModel, Field, PrivateAttr, ) from llama_index.legacy.indices.service_context import ServiceContext from llama_index.legacy.schema import...
null
36,856
import logging import uuid from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, cast from llama_index.legacy.bridge.pydantic import ( # type: ignore BaseModel, Field, PrivateAttr, ) from llama_index.legacy.indices.service_context import ServiceContext from llama_index.legacy.schema import...
Returns a list of lists of nodes where each list has all the nodes from the same document.
36,857
import logging import uuid from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, cast from llama_index.legacy.bridge.pydantic import ( # type: ignore BaseModel, Field, PrivateAttr, ) from llama_index.legacy.indices.service_context import ServiceContext from llama_index.legacy.schema import...
null
36,858
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,859
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,860
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,861
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,862
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,863
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,864
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,865
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,866
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,867
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,868
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,869
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,870
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,871
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,872
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,873
import datetime import logging import re from dataclasses import dataclass from typing import Any, Dict, Iterator, List, MutableSequence, Optional import google.ai.generativelanguage as genai from google.api_core import client_options as client_options_lib from google.api_core import exceptions as gapi_exception from g...
null
36,874
import math from typing import Any, List from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.types import ( MetadataFilters, VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.legacy.vector_stores.utils import ( legacy_m...
null
36,875
import logging from typing import Any, List, Optional, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.types import ( MetadataFilters, VectorStore, VectorStoreQuery, VectorStoreQueryMode, VectorStoreQueryResult, ) from llama_index.leg...
Convert from standard filter to dashvector filter dict.
36,876
from typing import Dict, Type from llama_index.legacy.vector_stores.chroma import ChromaVectorStore from llama_index.legacy.vector_stores.lantern import LanternVectorStore from llama_index.legacy.vector_stores.pinecone import PineconeVectorStore from llama_index.legacy.vector_stores.postgres import PGVectorStore from l...
null
36,877
from typing import Any, Callable, List, Protocol, Tuple, runtime_checkable from llama_index.legacy.vector_stores.types import VectorStoreQueryResult SparseEncoderCallable = Callable[[List[str]], Tuple[List[List[int]], List[List[float]]]] def default_sparse_encoder(model_id: str) -> SparseEncoderCallable: try: ...
null
36,878
from typing import Any, Callable, List, Protocol, Tuple, runtime_checkable from llama_index.legacy.vector_stores.types import VectorStoreQueryResult class VectorStoreQueryResult: """Vector store query result.""" nodes: Optional[Sequence[BaseNode]] = None similarities: Optional[List[float]] = None ids:...
Fuse dense and sparse results using relative score fusion.
36,879
import asyncio import uuid from logging import getLogger from typing import Any, Callable, Dict, List, Literal, Optional, Union, cast import nest_asyncio import numpy as np from llama_index.legacy.bridge.pydantic import PrivateAttr from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index....
Get AsyncElasticsearch client. Args: es_url: Elasticsearch URL. cloud_id: Elasticsearch cloud ID. api_key: Elasticsearch API key. username: Elasticsearch username. password: Elasticsearch password. Returns: AsyncElasticsearch client. Raises: ConnectionError: If Elasticsearch client cannot connect to Elasticsearch.
36,880
import asyncio import uuid from logging import getLogger from typing import Any, Callable, Dict, List, Literal, Optional, Union, cast import nest_asyncio import numpy as np from llama_index.legacy.bridge.pydantic import PrivateAttr from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index....
Convert standard filters to Elasticsearch filter. Args: standard_filters: Standard Llama-index filters. Returns: Elasticsearch filter.
36,881
import asyncio import uuid from logging import getLogger from typing import Any, Callable, Dict, List, Literal, Optional, Union, cast import nest_asyncio import numpy as np from llama_index.legacy.bridge.pydantic import PrivateAttr from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index....
null
36,882
from __future__ import annotations from enum import Enum from os import getenv from time import sleep from types import ModuleType from typing import Any, List, Type, TypeVar from llama_index.legacy.schema import BaseNode from llama_index.legacy.vector_stores.types import ( VectorStore, VectorStoreQuery, Ve...
Returns the passed in client object if valid, else constructs and returns one. Returns: The rockset client object (rockset.RocksetClient)
36,883
import json import uuid from typing import Any, Dict, Iterable, List, Optional, Union, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.types import ( MetadataFilters, VectorStore, VectorStoreQuery, VectorStoreQueryMode, VectorStoreQue...
Get OpenSearch client from the opensearch_url, otherwise raise error.
36,884
import json import uuid from typing import Any, Dict, Iterable, List, Optional, Union, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.types import ( MetadataFilters, VectorStore, VectorStoreQuery, VectorStoreQueryMode, VectorStoreQue...
Bulk Ingest Embeddings into given index.
36,885
import json import uuid from typing import Any, Dict, Iterable, List, Optional, Union, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.types import ( MetadataFilters, VectorStore, VectorStoreQuery, VectorStoreQueryMode, VectorStoreQue...
null
36,886
import json import uuid from typing import Any, Dict, Iterable, List, Optional, Union, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.types import ( MetadataFilters, VectorStore, VectorStoreQuery, VectorStoreQueryMode, VectorStoreQue...
Check if the service is http_auth is set as `aoss`.
36,887
import json import logging import os from dataclasses import dataclass, field from typing import Any, Callable, Dict, List, Mapping, Optional, cast import fsspec from dataclasses_json import DataClassJsonMixin from llama_index.legacy.indices.query.embedding_utils import ( get_top_k_embeddings, get_top_k_embeddi...
Build metadata filter function.
36,888
import logging from typing import Any, Dict, Iterable, List, Optional, TypeVar, cast from llama_index.legacy.indices.query.embedding_utils import ( get_top_k_mmr_embeddings, ) from llama_index.legacy.schema import BaseNode, MetadataMode from llama_index.legacy.vector_stores.types import ( ExactMatchFilter, ...
null
36,889
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional from llama_index.legacy.schema import ( BaseNode, MetadataMode, NodeRelationship, RelatedNodeInfo, TextNode, ) from llama_index.legacy.vector_stores.types import ( MetadataFilters, VectorStore, VectorStoreQuery, ...
null
36,890
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.utils import ( DEFAULT_TEXT_KEY, legacy_metadata_dict_to_node, metadata_dict_to_node, node_to_metadata_dict, ) Th...
Parse get response from Weaviate.
36,891
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.utils import ( DEFAULT_TEXT_KEY, legacy_metadata_dict_to_node, metadata_dict_to_node, node_to_metadata_dict, ) def...
Check if class schema exists.
36,892
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.utils import ( DEFAULT_TEXT_KEY, legacy_metadata_dict_to_node, metadata_dict_to_node, node_to_metadata_dict, ) NOD...
Create default schema.
36,893
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.utils import ( DEFAULT_TEXT_KEY, legacy_metadata_dict_to_node, metadata_dict_to_node, node_to_metadata_dict, ) def...
Get all properties of a class.
36,894
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.utils import ( DEFAULT_TEXT_KEY, legacy_metadata_dict_to_node, metadata_dict_to_node, node_to_metadata_dict, ) Th...
Get converted node similarity from distance.
36,895
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.utils import ( DEFAULT_TEXT_KEY, legacy_metadata_dict_to_node, metadata_dict_to_node, node_to_metadata_dict, ) _lo...
Convert to Node.
36,896
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.utils import ( DEFAULT_TEXT_KEY, legacy_metadata_dict_to_node, metadata_dict_to_node, node_to_metadata_dict, ) cl...
Add node.
36,897
import logging import os from typing import Any, Dict, List, Optional, cast from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.types import ( MetadataFilters, VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.legacy.vector...
Convert from standard dataclass to filter dict.
36,898
import json from typing import Any, Dict, List, Optional from llama_index.legacy.schema import ( BaseNode, NodeRelationship, RelatedNodeInfo, TextNode, ) from llama_index.legacy.vector_stores.types import ( VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.legacy.vect...
null
36,899
import os from typing import Any, Dict, List, Optional import requests from requests.adapters import HTTPAdapter, Retry from llama_index.legacy.schema import ( BaseNode, MetadataMode, NodeRelationship, RelatedNodeInfo, TextNode, ) from llama_index.legacy.utils import get_tqdm_iterable from llama_ind...
Convert docs to JSON.
36,900
import logging from typing import Any, Dict, List, Optional, Union from llama_index.legacy.schema import BaseNode, TextNode from llama_index.legacy.vector_stores.types import ( MetadataFilters, VectorStore, VectorStoreQuery, VectorStoreQueryMode, VectorStoreQueryResult, ) from llama_index.legacy.vec...
Translate standard metadata filters to Milvus specific spec.
36,901
import logging import math from typing import Any, Dict, Generator, List, Optional, cast from llama_index.legacy.bridge.pydantic import Field, PrivateAttr from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.utils import truncate_text from llama_index.legacy.vector_stores.types...
Translate standard metadata filters to Chroma specific spec.
36,902
import logging import math from typing import Any, Dict, Generator, List, Optional, cast from llama_index.legacy.bridge.pydantic import Field, PrivateAttr from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.utils import truncate_text from llama_index.legacy.vector_stores.types...
Yield successive max_chunk_size-sized chunks from lst. Args: lst (List[BaseNode]): list of nodes with embeddings max_chunk_size (int): max chunk size Yields: Generator[List[BaseNode], None, None]: list of nodes with embeddings
36,903
import logging from typing import Any, List, NamedTuple, Optional, Type from llama_index.legacy.bridge.pydantic import PrivateAttr from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.types import ( BasePydanticVectorStore, MetadataFilters, VectorStore...
This part create a dynamic sqlalchemy model with a new table.
36,904
import logging from typing import Any, List, NamedTuple, Optional, Type from llama_index.legacy.bridge.pydantic import PrivateAttr from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.types import ( BasePydanticVectorStore, MetadataFilters, VectorStore...
null
36,905
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional import fsspec from llama_index.legacy.bridge.pydantic import PrivateAttr from llama_index.legacy.readers.redis.utils import ( TokenEscaper, array_to_buffer, check_redis_modules_exist, convert_bytes, get_redis_query, ) from ll...
null
36,906
import logging from typing import Any, List, NamedTuple, Optional, Type from llama_index.legacy.bridge.pydantic import PrivateAttr from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.types import ( BasePydanticVectorStore, FilterOperator, MetadataFilt...
This part create a dynamic sqlalchemy model with a new table.
36,907
import logging from typing import Any, List, NamedTuple, Optional, Type from llama_index.legacy.bridge.pydantic import PrivateAttr from llama_index.legacy.schema import BaseNode, MetadataMode, TextNode from llama_index.legacy.vector_stores.types import ( BasePydanticVectorStore, FilterOperator, MetadataFilt...
null
36,908
import asyncio from inspect import signature from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Type, Union from llama_index.legacy.bridge.pydantic import BaseModel from llama_index.legacy.tools.function_tool import FunctionTool from llama_index.legacy.tools.types import ToolMetadata from llama_i...
Patch sync function from async function.
36,909
from inspect import signature from typing import Any, Callable, List, Optional, Tuple, Type, Union, cast from llama_index.legacy.bridge.pydantic import BaseModel, FieldInfo, create_model The provided code snippet includes necessary dependencies for implementing the `create_schema_from_function` function. Write a Pytho...
Create schema from function.
36,910
import json from abc import abstractmethod from dataclasses import dataclass from typing import TYPE_CHECKING, Any, Dict, Optional, Type from deprecated import deprecated from llama_index.legacy.bridge.pydantic import BaseModel class BaseTool: def metadata(self) -> ToolMetadata: pass def __call__(self, ...
Converts a synchronous tool to an async tool.
36,911
from typing import Optional, Type from llama_index.legacy.download.module import ( LLAMA_HUB_URL, MODULE_TYPE, download_llama_module, track_download, ) from llama_index.legacy.tools.tool_spec.base import BaseToolSpec LLAMA_HUB_URL = LLAMA_HUB_CONTENTS_URL + LLAMA_HUB_PATH class MODULE_TYPE(str, Enu...
Download a single tool from Llama Hub. Args: tool_class: The name of the tool class you want to download, such as `GmailToolSpec`. refresh_cache: If true, the local cache will be skipped and the loader will be fetched directly from the remote repo. custom_path: Custom dirpath to download loader into. Returns: A Loader.
36,912
import asyncio from inspect import signature from typing import TYPE_CHECKING, Any, Awaitable, Callable, Optional, Type from llama_index.legacy.bridge.pydantic import BaseModel from llama_index.legacy.tools.types import AsyncBaseTool, ToolMetadata, ToolOutput from llama_index.legacy.tools.utils import create_schema_fro...
Sync to async.
36,913
import json import os from pathlib import Path from typing import Any, Dict, List, Optional, Union import requests import tqdm from llama_index.legacy.download.module import LLAMA_HUB_URL from llama_index.legacy.download.utils import ( get_file_content, get_file_content_bytes, initialize_directory, ) LLAMA_...
Download a module from LlamaHub. Can be a loader, tool, pack, or more. Args: loader_class: The name of the llama module class you want to download, such as `GmailOpenAIAgentPack`. refresh_cache: If true, the local cache will be skipped and the loader will be fetched directly from the remote repo. custom_dir: Custom dir...
36,914
import re from typing import Optional, Set import pandas as pd from llama_index.legacy.indices.utils import expand_tokens_with_subtokens from llama_index.legacy.utils import globals_helper def expand_tokens_with_subtokens(tokens: Set[str]) -> Set[str]: """Get subtokens from a list of tokens., filtering for stopwor...
Extract keywords with RAKE.
36,915
import re from typing import Optional, Set import pandas as pd from llama_index.legacy.indices.utils import expand_tokens_with_subtokens from llama_index.legacy.utils import globals_helper def expand_tokens_with_subtokens(tokens: Set[str]) -> Set[str]: """Get subtokens from a list of tokens., filtering for stopwor...
Extract keywords given the GPT-generated response. Used by keyword table indices. Parses <start_token>: <word1>, <word2>, ... into [word1, word2, ...] Raises exception if response doesn't start with <start_token>
36,916
import logging import re from typing import Dict, List, Optional, Sequence, Set, Tuple from llama_index.legacy.embeddings.base import BaseEmbedding from llama_index.legacy.embeddings.multi_modal_base import MultiModalEmbedding from llama_index.legacy.schema import BaseNode, ImageNode, MetadataMode from llama_index.lega...
Get sorted node list. Used by tree-strutured indices.
36,917
import logging import re from typing import Dict, List, Optional, Sequence, Set, Tuple from llama_index.legacy.embeddings.base import BaseEmbedding from llama_index.legacy.embeddings.multi_modal_base import MultiModalEmbedding from llama_index.legacy.schema import BaseNode, ImageNode, MetadataMode from llama_index.lega...
Extract number given the GPT-generated response. Used by tree-structured indices.
36,918
import logging import re from typing import Dict, List, Optional, Sequence, Set, Tuple from llama_index.legacy.embeddings.base import BaseEmbedding from llama_index.legacy.embeddings.multi_modal_base import MultiModalEmbedding from llama_index.legacy.schema import BaseNode, ImageNode, MetadataMode from llama_index.lega...
Log vector store query result.
36,919
import logging import re from typing import Dict, List, Optional, Sequence, Set, Tuple from llama_index.legacy.embeddings.base import BaseEmbedding from llama_index.legacy.embeddings.multi_modal_base import MultiModalEmbedding from llama_index.legacy.schema import BaseNode, ImageNode, MetadataMode from llama_index.lega...
Default format node batch function. Assign each summary node a number, and format the batch of nodes.
36,920
import logging import re from typing import Dict, List, Optional, Sequence, Set, Tuple from llama_index.legacy.embeddings.base import BaseEmbedding from llama_index.legacy.embeddings.multi_modal_base import MultiModalEmbedding from llama_index.legacy.schema import BaseNode, ImageNode, MetadataMode from llama_index.lega...
Default parse choice select answer function.
36,921
import logging import re from typing import Dict, List, Optional, Sequence, Set, Tuple from llama_index.legacy.embeddings.base import BaseEmbedding from llama_index.legacy.embeddings.multi_modal_base import MultiModalEmbedding from llama_index.legacy.schema import BaseNode, ImageNode, MetadataMode from llama_index.lega...
Get embeddings of the given nodes, run embedding model if necessary. Args: nodes (Sequence[BaseNode]): The nodes to embed. embed_model (BaseEmbedding): The embedding model to use. show_progress (bool): Whether to show progress bar. Returns: Dict[str, List[float]]: A map from node id to embedding.
36,922
import logging import re from typing import Dict, List, Optional, Sequence, Set, Tuple from llama_index.legacy.embeddings.base import BaseEmbedding from llama_index.legacy.embeddings.multi_modal_base import MultiModalEmbedding from llama_index.legacy.schema import BaseNode, ImageNode, MetadataMode from llama_index.lega...
Get image embeddings of the given nodes, run image embedding model if necessary. Args: nodes (Sequence[ImageNode]): The nodes to embed. embed_model (MultiModalEmbedding): The embedding model to use. show_progress (bool): Whether to show progress bar. Returns: Dict[str, List[float]]: A map from node id to embedding.
36,923
import logging import re from typing import Dict, List, Optional, Sequence, Set, Tuple from llama_index.legacy.embeddings.base import BaseEmbedding from llama_index.legacy.embeddings.multi_modal_base import MultiModalEmbedding from llama_index.legacy.schema import BaseNode, ImageNode, MetadataMode from llama_index.lega...
Async get embeddings of the given nodes, run embedding model if necessary. Args: nodes (Sequence[BaseNode]): The nodes to embed. embed_model (BaseEmbedding): The embedding model to use. show_progress (bool): Whether to show progress bar. Returns: Dict[str, List[float]]: A map from node id to embedding.
36,924
import logging import re from typing import Dict, List, Optional, Sequence, Set, Tuple from llama_index.legacy.embeddings.base import BaseEmbedding from llama_index.legacy.embeddings.multi_modal_base import MultiModalEmbedding from llama_index.legacy.schema import BaseNode, ImageNode, MetadataMode from llama_index.lega...
Get image embeddings of the given nodes, run image embedding model if necessary. Args: nodes (Sequence[ImageNode]): The nodes to embed. embed_model (MultiModalEmbedding): The embedding model to use. show_progress (bool): Whether to show progress bar. Returns: Dict[str, List[float]]: A map from node id to embedding.
36,925
import logging from typing import Any, List, Optional, Sequence from llama_index.legacy.indices.base import BaseIndex from llama_index.legacy.indices.composability.graph import ComposableGraph from llama_index.legacy.indices.registry import INDEX_STRUCT_TYPE_TO_INDEX_CLASS from llama_index.legacy.storage.storage_contex...
Load index from storage context. Args: storage_context (StorageContext): storage context containing docstore, index store and vector store. index_id (Optional[str]): ID of the index to load. Defaults to None, which assumes there's only a single index in the index store and load it. **kwargs: Additional keyword args to ...
36,926
import logging from typing import Any, List, Optional, Sequence from llama_index.legacy.indices.base import BaseIndex from llama_index.legacy.indices.composability.graph import ComposableGraph from llama_index.legacy.indices.registry import INDEX_STRUCT_TYPE_TO_INDEX_CLASS from llama_index.legacy.storage.storage_contex...
Load composable graph from storage context. Args: storage_context (StorageContext): storage context containing docstore, index store and vector store. root_id (str): ID of the root index of the graph. **kwargs: Additional keyword args to pass to the index constructors.
36,927
import logging from typing import Any, Dict, Optional, Sequence, Type import requests from llama_index.legacy.core.base_retriever import BaseRetriever from llama_index.legacy.data_structs.data_structs import IndexDict, IndexStructType from llama_index.legacy.indices.managed.base import BaseManagedIndex, IndexType from ...
null
36,928
from typing import List, Optional from llama_index.legacy.node_parser.text import TokenTextSplitter from llama_index.legacy.node_parser.text.utils import truncate_text from llama_index.legacy.schema import BaseNode def truncate_text(text: str, text_splitter: TextSplitter) -> str: """Truncate text to fit within the...
Get text from nodes in the format of a numbered list. Used by tree-structured indices.
36,929
import logging from typing import Any, Dict, List, Optional, cast from llama_index.legacy.callbacks.base import CallbackManager from llama_index.legacy.core.base_retriever import BaseRetriever from llama_index.legacy.core.response.schema import Response from llama_index.legacy.indices.query.schema import QueryBundle fr...
Get text from node.
36,930
import json import logging from typing import Any, Callable, Dict, List, Optional, Union from llama_index.legacy.core.base_query_engine import BaseQueryEngine from llama_index.legacy.core.response.schema import Response from llama_index.legacy.prompts import BasePromptTemplate, PromptTemplate from llama_index.legacy.pr...
Default output processor that extracts values based on JSON Path expressions.
36,931
import re from typing import Any, Callable, Dict, Generic, Optional, Sequence, TypeVar from llama_index.legacy.data_structs.table import BaseStructTable from llama_index.legacy.indices.base import BaseIndex from llama_index.legacy.prompts import BasePromptTemplate from llama_index.legacy.prompts.default_prompts import ...
Parse output of schema extraction. Attempt to parse the following format from the default prompt: field1: <value>, field2: <value>, ...
36,932
import logging from abc import abstractmethod from typing import Any, Dict, List, Optional, Tuple, Union, cast from sqlalchemy import Table from llama_index.legacy.core.base_query_engine import BaseQueryEngine from llama_index.legacy.core.response.schema import Response from llama_index.legacy.indices.struct_store.cont...
Validate prompt.
36,933
import heapq import math from typing import Any, Callable, List, Optional, Tuple import numpy as np from llama_index.legacy.core.embeddings.base import similarity as default_similarity_fn from llama_index.legacy.vector_stores.types import VectorStoreQueryMode class VectorStoreQueryMode(str, Enum): """Vector store ...
Get top embeddings by fitting a learner against query. Inspired by Karpathy's SVM demo: https://github.com/karpathy/randomfun/blob/master/knn_vs_svm.ipynb Can fit SVM, linear regression, and more.
36,934
import heapq import math from typing import Any, Callable, List, Optional, Tuple import numpy as np from llama_index.legacy.core.embeddings.base import similarity as default_similarity_fn from llama_index.legacy.vector_stores.types import VectorStoreQueryMode def similarity( embedding1: Embedding, embedding2: ...
Get top nodes by similarity to the query, discount by their similarity to previous results. A mmr_threshold of 0 will strongly avoid similarity to previous results. A mmr_threshold of 1 will check similarity the query and ignore previous results.
36,936
import textwrap from pprint import pprint from typing import Any, Dict from llama_index.legacy.core.response.schema import Response from llama_index.legacy.schema import NodeWithScore from llama_index.legacy.utils import truncate_text The provided code snippet includes necessary dependencies for implementing the `ppri...
Display metadata for jupyter notebook.
36,937
import textwrap from pprint import pprint from typing import Any, Dict from llama_index.legacy.core.response.schema import Response from llama_index.legacy.schema import NodeWithScore from llama_index.legacy.utils import truncate_text def pprint_source_node( source_node: NodeWithScore, source_length: int = 350, wra...
Pretty print response for jupyter notebook.
36,938
import os from io import BytesIO from typing import Any, Dict, List, Tuple import matplotlib.pyplot as plt import requests from IPython.display import Markdown, display from PIL import Image from llama_index.legacy.core.response.schema import Response from llama_index.legacy.img_utils import b64_2_img from llama_index....
Display base64 encoded image str as image for jupyter notebook.
36,939
import os from io import BytesIO from typing import Any, Dict, List, Tuple import matplotlib.pyplot as plt import requests from IPython.display import Markdown, display from PIL import Image from llama_index.legacy.core.response.schema import Response from llama_index.legacy.img_utils import b64_2_img from llama_index....
Display response for jupyter notebook.
36,940
import os from io import BytesIO from typing import Any, Dict, List, Tuple import matplotlib.pyplot as plt import requests from IPython.display import Markdown, display from PIL import Image from llama_index.legacy.core.response.schema import Response from llama_index.legacy.img_utils import b64_2_img from llama_index....
For displaying a query and its multi-modal response.
36,941
from typing import Any, Dict, Optional, Sequence from llama_index.legacy.core.base_selector import ( BaseSelector, MultiSelection, SelectorResult, SingleSelection, ) from llama_index.legacy.llms.openai import OpenAI from llama_index.legacy.program.openai_program import OpenAIPydanticProgram from llama_i...
Convert pydantic output to selector result. Takes into account zero-indexing on answer indexes.
36,942
from typing import Optional from llama_index.legacy.core.base_selector import BaseSelector from llama_index.legacy.selectors.llm_selectors import ( LLMMultiSelector, LLMSingleSelector, ) from llama_index.legacy.selectors.pydantic_selectors import ( PydanticMultiSelector, PydanticSingleSelector, ) from l...
Get a selector from a service context. Prefers Pydantic selectors if possible.
36,943
from typing import Any, Dict, List, Optional, Sequence, cast from llama_index.legacy.core.base_selector import ( BaseSelector, SelectorResult, SingleSelection, ) from llama_index.legacy.llm_predictor.base import LLMPredictorType from llama_index.legacy.output_parsers.base import StructuredOutput from llama_...
Convert sequence of metadata to enumeration text.
36,944
from typing import Any, Dict, List, Optional, Sequence, cast from llama_index.legacy.core.base_selector import ( BaseSelector, SelectorResult, SingleSelection, ) from llama_index.legacy.llm_predictor.base import LLMPredictorType from llama_index.legacy.output_parsers.base import StructuredOutput from llama_...
Convert structured output to selector result.
36,945
import json import os import sys from collections import defaultdict from typing import Dict, List import numpy as np import tiktoken def validate_json(data_path: str) -> None: # Load dataset with open(data_path) as f: dataset = [json.loads(line) for line in f] # We can inspect the data quickly by...
null