id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
36,412
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast from llama_index.core.schema import BaseNode, MetadataMode, TextNode from llama_index.core.vector_stores.utils import ( DEFAULT_TEXT_KEY, legacy_metadata_dict_to_node, metadata_dict_to_node, node_to_metadata_dict, ) def val...
Get all properties of a class.
36,413
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast from llama_index.core.schema import BaseNode, MetadataMode, TextNode from llama_index.core.vector_stores.utils import ( DEFAULT_TEXT_KEY, legacy_metadata_dict_to_node, metadata_dict_to_node, node_to_metadata_dict, ) The pr...
Get converted node similarity from distance.
36,414
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast from llama_index.core.schema import BaseNode, MetadataMode, TextNode from llama_index.core.vector_stores.utils import ( DEFAULT_TEXT_KEY, legacy_metadata_dict_to_node, metadata_dict_to_node, node_to_metadata_dict, ) _logger...
Convert to Node.
36,415
import logging from typing import TYPE_CHECKING, Any, Dict, List, Optional, cast from llama_index.core.schema import BaseNode, MetadataMode, TextNode from llama_index.core.vector_stores.utils import ( DEFAULT_TEXT_KEY, legacy_metadata_dict_to_node, metadata_dict_to_node, node_to_metadata_dict, ) class ...
Add node.
36,416
import logging from typing import Any, Dict, List, Optional, cast from uuid import uuid4 from llama_index.core.bridge.pydantic import Field, PrivateAttr from llama_index.core.schema import BaseNode from llama_index.core.vector_stores.types import ( BasePydanticVectorStore, MetadataFilters, VectorStoreQuery,...
null
36,417
from typing import Any, Callable, List, Protocol, Tuple, runtime_checkable from llama_index.core.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,418
from typing import Any, Callable, List, Protocol, Tuple, runtime_checkable from llama_index.core.vector_stores.types import VectorStoreQueryResult class VectorStoreQueryResult: """Vector store query result.""" nodes: Optional[Sequence[BaseNode]] = None similarities: Optional[List[float]] = None ids: O...
Fuse dense and sparse results using relative score fusion.
36,419
import logging from typing import Any, Dict, List, Optional from llama_index.core.schema import ( BaseNode, MetadataMode, NodeRelationship, RelatedNodeInfo, TextNode, ) from llama_index.core.vector_stores.types import ( MetadataFilters, VectorStore, VectorStoreQuery, VectorStoreQuery...
null
36,420
from typing import Any, Dict, List, Optional import neo4j from llama_index.core.schema import BaseNode, MetadataMode from llama_index.core.vector_stores.types import ( VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.core.vector_stores.utils import ( metadata_dict_to_node, n...
Check if variable is not null and raise error accordingly.
36,421
from typing import Any, Dict, List, Optional import neo4j from llama_index.core.schema import BaseNode, MetadataMode from llama_index.core.vector_stores.types import ( VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.core.vector_stores.utils import ( metadata_dict_to_node, n...
Sort first element to match the index_name if exists.
36,422
from typing import Any, Dict, List, Optional import neo4j from llama_index.core.schema import BaseNode, MetadataMode from llama_index.core.vector_stores.types import ( VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.core.vector_stores.utils import ( metadata_dict_to_node, n...
Convert BaseNode object to a dictionary to be imported into Neo4j.
36,423
from typing import Any, Dict, List, Optional import neo4j from llama_index.core.schema import BaseNode, MetadataMode from llama_index.core.vector_stores.types import ( VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.core.vector_stores.utils import ( metadata_dict_to_node, n...
null
36,424
from typing import Any, Dict, List, Optional import neo4j from llama_index.core.schema import BaseNode, MetadataMode from llama_index.core.vector_stores.types import ( VectorStore, VectorStoreQuery, VectorStoreQueryResult, ) from llama_index.core.vector_stores.utils import ( metadata_dict_to_node, n...
Remove Lucene special characters.
36,425
import logging from typing import Any, List, NamedTuple, Optional, Type import asyncpg import pgvector import psycopg2 import sqlalchemy import sqlalchemy.ext.asyncio from llama_index.core.bridge.pydantic import PrivateAttr from llama_index.core.schema import BaseNode, MetadataMode, TextNode from llama_index.core.v...
This part create a dynamic sqlalchemy model with a new table.
36,426
import logging from typing import Any, List, NamedTuple, Optional, Type import asyncpg import pgvector import psycopg2 import sqlalchemy import sqlalchemy.ext.asyncio from llama_index.core.bridge.pydantic import PrivateAttr from llama_index.core.schema import BaseNode, MetadataMode, TextNode from llama_index.core.v...
null
36,427
import logging from typing import Any, List, Optional import numpy as np from llama_index.core.bridge.pydantic import PrivateAttr from llama_index.core.schema import ( BaseNode, MetadataMode, NodeRelationship, RelatedNodeInfo, TextNode, ) from llama_index.core.vector_stores.types import ( Metada...
Translate standard metadata filters to Lance specific spec.
36,428
import logging from typing import Any, List, Optional import numpy as np from llama_index.core.bridge.pydantic import PrivateAttr from llama_index.core.schema import ( BaseNode, MetadataMode, NodeRelationship, RelatedNodeInfo, TextNode, ) from llama_index.core.vector_stores.types import ( Metada...
null
36,429
import logging import uuid from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, cast from llama_index.core.bridge.pydantic import ( # type: ignore BaseModel, Field, PrivateAttr, ) from llama_index.core.schema import BaseNode, RelatedNodeInfo, TextNode from llama_index.core.vector_stores.t...
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,430
import logging import uuid from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, cast from llama_index.core.bridge.pydantic import ( # type: ignore BaseModel, Field, PrivateAttr, ) from llama_index.core.schema import BaseNode, RelatedNodeInfo, TextNode from llama_index.core.vector_stores.t...
null
36,431
import logging import uuid from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, cast from llama_index.core.bridge.pydantic import ( # type: ignore BaseModel, Field, PrivateAttr, ) from llama_index.core.schema import BaseNode, RelatedNodeInfo, TextNode from llama_index.core.vector_stores.t...
Returns a list of lists of nodes where each list has all the nodes from the same document.
36,432
import logging import uuid from typing import TYPE_CHECKING, Any, Dict, List, Optional, Sequence, cast from llama_index.core.bridge.pydantic import ( # type: ignore BaseModel, Field, PrivateAttr, ) from llama_index.core.schema import BaseNode, RelatedNodeInfo, TextNode from llama_index.core.vector_stores.t...
null
36,433
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,434
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,435
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,436
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,437
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,438
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,439
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,440
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,441
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,442
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,443
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,444
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,445
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,446
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,447
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,448
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,449
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 import rockset from llama_index.core.schema import BaseNode from llama_index.core.vector_stores.types import ( VectorStore, VectorStoreQu...
Returns the passed in client object if valid, else constructs and returns one. Returns: The rockset client object (rockset.RocksetClient)
36,450
import json import time from typing import Any, Dict, List, Optional from llama_index.core.schema import ( BaseNode, NodeRelationship, RelatedNodeInfo, TextNode, ) from llama_index.core.vector_stores.types import ( MetadataFilters, VectorStore, VectorStoreQuery, VectorStoreQueryResult, )...
null
36,451
from typing import final, NoReturn from datetime import datetime, timedelta import requests from llama_index.core.tools.tool_spec.base import BaseToolSpec def retry(f, *args, **kwargs): return f
null
36,452
from typing import final, NoReturn from datetime import datetime, timedelta import requests from llama_index.core.tools.tool_spec.base import BaseToolSpec def stop_after_attempt(n): return None
null
36,453
from typing import final, NoReturn from datetime import datetime, timedelta import requests from llama_index.core.tools.tool_spec.base import BaseToolSpec def wait_random(a, b): return None
null
36,454
from typing import final, NoReturn from datetime import datetime, timedelta import requests from llama_index.core.tools.tool_spec.base import BaseToolSpec def wait_exponential(multiplier, min, max): return None
null
36,455
from typing import final, NoReturn from datetime import datetime, timedelta import requests from llama_index.core.tools.tool_spec.base import BaseToolSpec def is_http_retryable(rsp): # -return rsp and rsp.status_code >= 500 return ( rsp and not isinstance(rsp, dict) and rsp.status_code ...
null
36,456
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request def get_df(url: ...
Return gainers of the day from yahoo finace including all cap stocks.
36,457
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request def get_df(url: ...
Get data for today's losers from yahoo finance including all cap stocks.
36,458
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request def get_df(url: ...
Get data for today's stocks with low PR ratio and growth rate better than 25%.
36,459
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request def get_df(url: ...
Get data for today's stocks with low PR ratio and growth rate better than 25%.
36,460
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request def get_df(url: ...
Get data for today's stocks in descending order based on intraday trading volume.
36,461
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request def get_df(url: ...
Get data for today's potentially undervalued large cap stocks from Yahoo finance.
36,462
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request def get_df(url: ...
Get data for today'sagressive / high growth small cap stocks from Yahoo finance.
36,463
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request def get_df(url: ...
Return data for today's hot penny stocks from pennystockflow.com.
36,464
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request def request(url:...
Return current price information given a stock ticker symbol.
36,465
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request The provided cod...
Returns latest news for a given stock_name by querying results via newsapi.
36,466
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request def request(url:...
Returns top Kk trending news from seekingalpha.
36,467
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request The provided cod...
Returns overall trending searches in US unless region is provided.
36,468
import pandas as pd from collections import defaultdict from datetime import datetime, timedelta from bs4 import BeautifulSoup from pytrends.request import TrendReq from typing import List, Dict, Optional, Any from newsapi import NewsApiClient from llama_index.tools.finance.util import get_df, request The provided cod...
Find google search trends for a given query filtered by region if provided.
36,469
from typing import Dict from llama_index.tools.finance.util import request def request(url: str, method: str = "get", timeout: int = 10, **kwargs): """Helper to make requests from a url.""" method = method.lower() assert method in [ "delete", "get", "head", "patch", ...
Returns a list of companies similar to provided stock symbol. If country is None, performs a global search across all indices.
36,470
import csv import requests import pandas as pd import yfinance as yf from typing import Dict The provided code snippet includes necessary dependencies for implementing the `get_earnings_history` function. Write a Python function `def get_earnings_history(api_key: Dict[str, str], symbol: str) -> pd.DataFrame` to solve ...
Get actual, estimated earnings and surprise history for a given stock ticker symbol. If somehow api response is not found, returns an empty dataframe.
36,471
import csv import requests import pandas as pd import yfinance as yf from typing import Dict The provided code snippet includes necessary dependencies for implementing the `get_latest_earning_estimate` function. Write a Python function `def get_latest_earning_estimate(symbol: str) -> float` to solve the following prob...
Gets latest actual and estimated earning estimate for a stock symbol.
36,472
import csv import requests import pandas as pd import yfinance as yf from typing import Dict The provided code snippet includes necessary dependencies for implementing the `get_upcoming_earnings` function. Write a Python function `def get_upcoming_earnings( api_key: Dict[str, str], start_date: str, end_dat...
Returns stocks announcing there earnings in next 3 months.
36,473
import logging from typing import Any, Dict, List, Optional, Sequence, Type import requests from llama_index.core.base.base_retriever import BaseRetriever from llama_index.core.callbacks.base import CallbackManager from llama_index.core.data_structs.data_structs import IndexDict, IndexStructType from llama_index.core.i...
null
36,474
import re from typing import Any, Dict, List, Optional import numpy as np from llama_index.core import VectorStoreIndex from llama_index.core.base.embeddings.base import BaseEmbedding from llama_index.core.bridge.pydantic import Field from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.node...
Combine sentences. Ported over from: https://github.com/FullStackRetrieval-com/RetrievalTutorials/blob/main/5_Levels_Of_Text_Splitting.ipynb
36,475
import re from typing import Any, Dict, List, Optional import numpy as np from llama_index.core import VectorStoreIndex from llama_index.core.base.embeddings.base import BaseEmbedding from llama_index.core.bridge.pydantic import Field from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.node...
Calculate cosine distances.
36,476
import re from typing import Any, Dict, List, Optional import numpy as np from llama_index.core import VectorStoreIndex from llama_index.core.base.embeddings.base import BaseEmbedding from llama_index.core.bridge.pydantic import Field from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.node...
Get indices above threshold.
36,477
import re from typing import Any, Dict, List, Optional import numpy as np from llama_index.core import VectorStoreIndex from llama_index.core.base.embeddings.base import BaseEmbedding from llama_index.core.bridge.pydantic import Field from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.node...
Make chunks.
36,478
import json from typing import List, Optional, TYPE_CHECKING import pandas as pd from llama_index.core.bridge.pydantic import BaseModel from llama_index.core.download.module import LLAMA_HUB_URL from llama_index.core.download.utils import get_file_content from llama_index.core.indices.base import BaseIndex from llama_i...
Converts a given string to camel casing.
36,479
import os import pickle from pathlib import Path import nest_asyncio import panel as pn import param from llama_index.core import VectorStoreIndex from llama_index.readers.github import GithubClient, GithubRepositoryReader def _split_and_clean(cstext): return cstext.split(",")
null
36,480
import os import pickle from pathlib import Path import nest_asyncio import panel as pn import param from llama_index.core import VectorStoreIndex from llama_index.readers.github import GithubClient, GithubRepositoryReader pn.chat.ChatMessage.default_avatars.update( { "assistant": GITHUB_COPILOT_LOGO, ...
Returns the Chat UI.
36,481
from llama_index.core.bridge.pydantic import Field, BaseModel, PrivateAttr from llama_index.core import PromptTemplate from typing import Any, Dict, List, Optional from dataclasses import dataclass, field import uuid from llama_index.core.agent.types import ( Task, TaskStep, TaskStepOutput, ) from llama_ind...
null
36,482
import re from abc import abstractmethod from typing import Any, Callable, Dict, List, Optional, Tuple import pandas as pd from llama_index.core.base.query_pipeline.query import QueryComponent from llama_index.core.base.response.schema import Response from llama_index.core.bridge.pydantic import BaseModel, Field from l...
Get regex parser.
36,483
import re from abc import abstractmethod from typing import Any, Callable, Dict, List, Optional, Tuple import pandas as pd from llama_index.core.base.query_pipeline.query import QueryComponent from llama_index.core.base.response.schema import Response from llama_index.core.bridge.pydantic import BaseModel, Field from l...
Parse dynamic plan.
36,484
import re from abc import abstractmethod from typing import Any, Callable, Dict, List, Optional, Tuple import pandas as pd from llama_index.core.base.query_pipeline.query import QueryComponent from llama_index.core.base.response.schema import Response from llama_index.core.bridge.pydantic import BaseModel, Field from l...
Serialize operation chain. Operation chain is list of (fn, args) tuples. Return string in form: fn1(args1) -> fn2(args2) -> ... Leave dangling arrow at end.
36,485
import re from abc import abstractmethod from typing import Any, Callable, Dict, List, Optional, Tuple import pandas as pd from llama_index.core.base.query_pipeline.query import QueryComponent from llama_index.core.base.response.schema import Response from llama_index.core.bridge.pydantic import BaseModel, Field from l...
Serialize keys.
36,486
import re from abc import abstractmethod from typing import Any, Callable, Dict, List, Optional, Tuple import pandas as pd from llama_index.core.base.query_pipeline.query import QueryComponent from llama_index.core.base.response.schema import Response from llama_index.core.bridge.pydantic import BaseModel, Field from l...
Serialize table.
36,487
import asyncio from enum import Enum from typing import Any, Dict, List, Optional import pandas as pd from llama_index.core.base.response.schema import RESPONSE_TYPE from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.llms import LLM from llama_index.core.llms.utils import LLMType, resolve_...
null
36,488
import asyncio from enum import Enum from typing import Any, Dict, List, Optional import pandas as pd from llama_index.core.base.response.schema import RESPONSE_TYPE from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.llms import LLM from llama_index.core.llms.utils import LLMType, resolve_...
null
36,489
import asyncio from enum import Enum from typing import Any, Dict, List, Optional import pandas as pd from llama_index.core.base.response.schema import RESPONSE_TYPE from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.llms import LLM from llama_index.core.llms.utils import LLMType, resolve_...
null
36,490
from typing import Any, Dict, Optional from llama_index.embeddings.openai import OpenAIEmbedding from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.schema import TextNode from llama_index.core.ingestion import IngestionPipeline from llama_index.core import VectorStoreIndex from llama_index...
Infer retrieve rerank.
36,491
import ast import re from typing import Any, Dict, List, Sequence, Tuple, Union from llama_index.core.tools.function_tool import FunctionTool from llama_index.core.tools.types import BaseTool, adapt_to_async_tool from .schema import ( LLMCompilerParseResult, LLMCompilerTask, ) def instantiate_new_step( tool...
Get graph dict.
36,492
import ast import re from typing import Any, Dict, List, Sequence, Tuple, Union from llama_index.core.tools.function_tool import FunctionTool from llama_index.core.tools.types import BaseTool, adapt_to_async_tool from .schema import ( LLMCompilerParseResult, LLMCompilerTask, ) class LLMCompilerTask(BaseModel):...
Generate context for replanning. Formatted like this. ``` 1. action 1 Observation: xxx 2. action 2 Observation: yyy ... Thought: joinner_thought ```
36,493
import ast import re from typing import Any, Dict, List, Sequence, Tuple, Union from llama_index.core.tools.function_tool import FunctionTool from llama_index.core.tools.types import BaseTool, adapt_to_async_tool from .schema import ( LLMCompilerParseResult, LLMCompilerTask, ) The provided code snippet include...
Format contexts. Taken from https://github.com/SqueezeAILab/LLMCompiler/blob/main/src/llm_compiler/llm_compiler.py Contexts is a list of context. Each context is formatted as the description of generate_context_for_replanner
36,494
import re from typing import Any, Dict, List, Sequence from llama_index.core.tools import BaseTool from llama_index.core.types import BaseOutputParser from .schema import JoinerOutput, LLMCompilerParseResult from .utils import get_graph_dict ID_PATTERN = r"\$\{?(\d+)\}?" The provided code snippet includes necessary de...
Default dependency rule.
36,495
import asyncio import uuid from typing import ( Any, Dict, List, Optional, Sequence, cast, ) from llama_index.core.agent.types import ( BaseAgentWorker, Task, TaskStep, TaskStepOutput, ) from llama_index.core.base.llms.types import ChatMessage, ChatResponse, MessageRole from llam...
Generate LLM Compiler prompt.
36,496
import asyncio from typing import Any, Collection, Dict, List, Set, Tuple, Union from llama_index.core.utils import print_text from pydantic import BaseModel from .schema import LLMCompilerTask from .utils import parse_llm_compiler_action_args class LLMCompilerTask(BaseModel): """LLM Compiler Task. Object tak...
null
36,497
from typing import Any, Collection, List, Optional, Tuple, Union from llama_index.core.tools.types import AsyncBaseTool from pydantic import BaseModel def _default_stringify_rule_for_arguments(args: Union[List, Tuple]) -> str: if len(args) == 1: return str(args[0]) else: return str(tuple(args))
null
36,498
from dataclasses import dataclass from typing import Any, Dict, List import numpy as np from llama_index.core.response import Response from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.bridge.pydantic import Field from llama_index.core.query_engine import CustomQueryEngine from llama_inde...
null
36,499
from dataclasses import dataclass from typing import Any, Dict, List import numpy as np from llama_index.core.response import Response from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.bridge.pydantic import Field from llama_index.core.query_engine import CustomQueryEngine from llama_inde...
null
36,500
from dataclasses import dataclass from typing import Any, Dict, List import numpy as np from llama_index.core.response import Response from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.bridge.pydantic import Field from llama_index.core.query_engine import CustomQueryEngine from llama_inde...
Compute relevance score. Args: pred_log_probs (Dict[str, float]): log probabilities of tokens Returns: float: relevance score
36,501
from dataclasses import dataclass from typing import Any, Dict, List import numpy as np from llama_index.core.response import Response from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.bridge.pydantic import Field from llama_index.core.query_engine import CustomQueryEngine from llama_inde...
Compute support score. Args: pred_tokens (List[int]): List of predicted tokens pred_log_probs_dict (List[Dict[str, float]]): log probabilities of tokens for each predicted tokens Returns: float: support score
36,502
from dataclasses import dataclass from typing import Any, Dict, List import numpy as np from llama_index.core.response import Response from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.bridge.pydantic import Field from llama_index.core.query_engine import CustomQueryEngine from llama_inde...
Compute usefulness score. Args: pred_tokens (List[int]): List of predicted tokens pred_log_probs_dict (List[Dict[str, float]]): log probabilities of tokens for each predicted tokens Returns: float: relevance score
36,503
import numpy as np import random import tiktoken import umap from sklearn.mixture import GaussianMixture from typing import Dict, List, Optional from llama_index.core.schema import BaseNode def perform_clustering( embeddings: np.ndarray, dim: int, threshold: float, ) -> List[np.ndarray]: # If the number...
null
36,504
from pathlib import Path from typing import Any, Dict, List, Optional from llama_index.core import ServiceContext from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.response_synthesizers import TreeSummarize from llama_index.core.schema import NodeWithScore from llama_index.llms.openai imp...
null
36,505
import os from typing import Any, Dict, List from llama_index.core import ServiceContext, SQLDatabase from llama_index.core.indices.struct_store.sql_query import NLSQLTableQueryEngine from llama_index.core.llama_pack.base import BaseLlamaPack from sqlalchemy import create_engine def snowflake_sqlalchemy_20_monkey_patc...
null
36,506
import asyncio from typing import Any, Dict from llama_index.core import SimpleDirectoryReader from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core.output_parsers import PydanticOutputParser from llama_index.core.program.multi_modal_llm_program import ( MultiModalLLMCompletionProgram, ) ...
null
36,507
from dataclasses import asdict from typing import List from llama_index.core.base.llms.types import ChatResponse from llama_index.core.schema import NodeWithScore from .types import Document, Citation, CitationsSettings class NodeWithScore(BaseComponent): node: BaseNode score: Optional[float] = None def _...
null
36,508
from dataclasses import asdict from typing import List from llama_index.core.base.llms.types import ChatResponse from llama_index.core.schema import NodeWithScore from .types import Document, Citation, CitationsSettings class ChatResponse(BaseModel): def __str__(self) -> str: class Citation: class CitationsS...
null
36,509
from dataclasses import asdict from typing import List from llama_index.core.base.llms.types import ChatResponse from llama_index.core.schema import NodeWithScore from .types import Document, Citation, CitationsSettings class ChatResponse(BaseModel): """Chat response.""" message: ChatMessage raw: Optional...
null
36,510
import regex import string import json from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core import VectorStoreIndex, SimpleDirectoryReader from llama_index.llms.openai import OpenAI from llama_index.core.llms import ChatMessage from transformers import DPRReader, DPRReaderTokenizer import to...
null
36,511
import regex import string import json from llama_index.core.llama_pack.base import BaseLlamaPack from llama_index.core import VectorStoreIndex, SimpleDirectoryReader from llama_index.llms.openai import OpenAI from llama_index.core.llms import ChatMessage from transformers import DPRReader, DPRReaderTokenizer import to...
null