code stringlengths 161 233k | apis sequencelengths 1 24 | extract_api stringlengths 162 68.5k |
|---|---|---|
"""FastAPI app creation, logger configuration and main API routes."""
import logging
from fastapi import Depends, FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from injector import Injector
from llama_index.core.callbacks import CallbackManager
from llama_index.core.callbacks.global_handlers imp... | [
"llama_index.core.callbacks.CallbackManager",
"llama_index.core.callbacks.global_handlers.create_global_handler"
] | [((894, 921), 'logging.getLogger', 'logging.getLogger', (['__name__'], {}), '(__name__)\n', (911, 921), False, 'import logging\n'), ((1479, 1510), 'llama_index.core.callbacks.global_handlers.create_global_handler', 'create_global_handler', (['"""simple"""'], {}), "('simple')\n", (1500, 1510), False, 'from llama_index.c... |
import json
import os
from typing import Dict, List, Optional, Type
from loguru import logger
from datastore.datastore import DataStore
from models.models import (
DocumentChunk,
DocumentChunkMetadata,
DocumentChunkWithScore,
DocumentMetadataFilter,
Query,
QueryResult,
QueryWithEmbedding,
)
... | [
"llama_index.data_structs.struct_type.IndexStructType",
"llama_index.indices.query.schema.QueryBundle"
] | [((860, 929), 'os.environ.get', 'os.environ.get', (['"""LLAMA_INDEX_TYPE"""', 'IndexStructType.SIMPLE_DICT.value'], {}), "('LLAMA_INDEX_TYPE', IndexStructType.SIMPLE_DICT.value)\n", (874, 929), False, 'import os\n'), ((954, 999), 'os.environ.get', 'os.environ.get', (['"""LLAMA_INDEX_JSON_PATH"""', 'None'], {}), "('LLAM... |
import os
import weaviate
from llama_index.storage.storage_context import StorageContext
from llama_index.vector_stores import WeaviateVectorStore
from llama_index.query_engine.retriever_query_engine import RetrieverQueryEngine
from llama_index.callbacks.base import CallbackManager
from llama_index import (
LLMPr... | [
"llama_index.LLMPredictor",
"llama_index.StorageContext.from_defaults",
"llama_index.vector_stores.WeaviateVectorStore",
"llama_index.llms.LocalAI",
"llama_index.VectorStoreIndex.from_vector_store",
"llama_index.embeddings.HuggingFaceEmbedding"
] | [((1360, 1409), 'llama_index.embeddings.HuggingFaceEmbedding', 'HuggingFaceEmbedding', ([], {'model_name': 'embed_model_name'}), '(model_name=embed_model_name)\n', (1380, 1409), False, 'from llama_index.embeddings import HuggingFaceEmbedding\n'), ((1418, 1534), 'llama_index.llms.LocalAI', 'LocalAI', ([], {'temperature'... |
import typer
import uuid
from typing import Optional, List, Any
import os
import numpy as np
from memgpt.utils import is_valid_url, printd
from memgpt.data_types import EmbeddingConfig
from memgpt.credentials import MemGPTCredentials
from memgpt.constants import MAX_EMBEDDING_DIM, EMBEDDING_TO_TOKENIZER_MAP, EMBEDDING... | [
"llama_index.embeddings.huggingface.HuggingFaceEmbedding",
"llama_index.embeddings.azure_openai.AzureOpenAIEmbedding",
"llama_index.core.node_parser.SentenceSplitter",
"llama_index.core.Document",
"llama_index.embeddings.openai.OpenAIEmbedding"
] | [((981, 1020), 'llama_index.core.node_parser.SentenceSplitter', 'SentenceSplitter', ([], {'chunk_size': 'chunk_size'}), '(chunk_size=chunk_size)\n', (997, 1020), False, 'from llama_index.core.node_parser import SentenceSplitter\n'), ((5381, 5419), 'llama_index.embeddings.huggingface.HuggingFaceEmbedding', 'HuggingFaceE... |
import logging
import os
from typing import Optional
from typing import Type
import openai
from langchain.chat_models import ChatOpenAI
from llama_index import VectorStoreIndex, LLMPredictor, ServiceContext
from llama_index.vector_stores.types import ExactMatchFilter, MetadataFilters
from pydantic import BaseModel, Fi... | [
"llama_index.ServiceContext.from_defaults",
"llama_index.VectorStoreIndex.from_vector_store"
] | [((754, 816), 'pydantic.Field', 'Field', (['...'], {'description': '"""the search query to search resources"""'}), "(..., description='the search query to search resources')\n", (759, 816), False, 'from pydantic import BaseModel, Field\n'), ((1840, 1905), 'llama_index.ServiceContext.from_defaults', 'ServiceContext.from... |
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
from typing import Any, List, Optional
from sentence_transformers import CrossEncoder
from typing import Optional, Sequence
from langchain_core.documents import Document
from langchain.callbacks.manager import Callbacks
f... | [
"llama_index.bridge.pydantic.Field",
"llama_index.bridge.pydantic.PrivateAttr"
] | [((602, 609), 'llama_index.bridge.pydantic.Field', 'Field', ([], {}), '()\n', (607, 609), False, 'from llama_index.bridge.pydantic import Field, PrivateAttr\n'), ((628, 641), 'llama_index.bridge.pydantic.PrivateAttr', 'PrivateAttr', ([], {}), '()\n', (639, 641), False, 'from llama_index.bridge.pydantic import Field, Pr... |
'''
Below helper functions are implemented in this script:
build_sentence_window_index - VectorStore Index for Sentence window RAG technique
get_sentence_window_query_engine - query enginer for the above index
build_automerging_index - VectorStore Index for Auto-merging RAG technique
get_automerging_query_engine - que... | [
"llama_index.VectorStoreIndex.from_documents",
"llama_index.retrievers.AutoMergingRetriever",
"llama_index.node_parser.HierarchicalNodeParser.from_defaults",
"llama_index.VectorStoreIndex",
"llama_index.indices.postprocessor.SentenceTransformerRerank",
"llama_index.node_parser.SentenceWindowNodeParser.fro... | [((1446, 1596), 'llama_index.node_parser.SentenceWindowNodeParser.from_defaults', 'SentenceWindowNodeParser.from_defaults', ([], {'window_size': 'sentence_window_size', 'window_metadata_key': '"""window"""', 'original_text_metadata_key': '"""original_text"""'}), "(window_size=sentence_window_size,\n window_metadata_... |
import os
import streamlit as st
from llama_index.core import Settings, SimpleDirectoryReader, VectorStoreIndex
from llama_index.embeddings.openai import OpenAIEmbedding
from llama_index.llms.openai import OpenAI
st.set_page_config(
page_title="Chat with the PDM docs, powered by LlamaIndex",
page_icon="📝",
... | [
"llama_index.core.VectorStoreIndex.from_documents",
"llama_index.core.SimpleDirectoryReader"
] | [((215, 384), 'streamlit.set_page_config', 'st.set_page_config', ([], {'page_title': '"""Chat with the PDM docs, powered by LlamaIndex"""', 'page_icon': '"""📝"""', 'layout': '"""centered"""', 'initial_sidebar_state': '"""auto"""', 'menu_items': 'None'}), "(page_title=\n 'Chat with the PDM docs, powered by LlamaInde... |
from typing import Callable, List
def split_text_keep_separator(text: str, separator: str) -> List[str]:
"""Split text with separator and keep the separator at the end of each split."""
parts = text.split(separator)
result = [separator + s if i > 0 else s for i, s in enumerate(parts)]
return [s for s ... | [
"llama_index.utils.get_cache_dir"
] | [((876, 891), 'llama_index.utils.get_cache_dir', 'get_cache_dir', ([], {}), '()\n', (889, 891), False, 'from llama_index.utils import get_cache_dir\n'), ((912, 950), 'os.environ.get', 'os.environ.get', (['"""NLTK_DATA"""', 'cache_dir'], {}), "('NLTK_DATA', cache_dir)\n", (926, 950), False, 'import os\n'), ((1252, 1290)... |
#
# Copyright 2016 The BigDL Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in ... | [
"llama_index.vector_stores.postgres.PGVectorStore.from_params",
"llama_index.embeddings.huggingface.HuggingFaceEmbedding",
"llama_index.core.schema.TextNode",
"llama_index.core.node_parser.SentenceSplitter",
"llama_index.core.schema.NodeWithScore",
"llama_index.core.vector_stores.VectorStoreQuery",
"lla... | [((1521, 1612), 'psycopg2.connect', 'psycopg2.connect', ([], {'dbname': '"""postgres"""', 'host': 'host', 'password': 'password', 'port': 'port', 'user': 'user'}), "(dbname='postgres', host=host, password=password, port=port,\n user=user)\n", (1537, 1612), False, 'import psycopg2\n'), ((1841, 1982), 'llama_index.vec... |
import os
import logging
import hashlib
import random
import uuid
import openai
from pathlib import Path
from llama_index import ServiceContext, GPTVectorStoreIndex, LLMPredictor, RssReader, SimpleDirectoryReader, StorageContext, load_index_from_storage
from llama_index.readers.schema.base import Document
from langcha... | [
"llama_index.RssReader",
"llama_index.SimpleDirectoryReader",
"llama_index.ServiceContext.from_defaults",
"llama_index.StorageContext.from_defaults",
"llama_index.load_index_from_storage",
"llama_index.GPTVectorStoreIndex.from_documents",
"llama_index.readers.schema.base.Document"
] | [((795, 827), 'os.environ.get', 'os.environ.get', (['"""OPENAI_API_KEY"""'], {}), "('OPENAI_API_KEY')\n", (809, 827), False, 'import os\n'), ((841, 869), 'os.environ.get', 'os.environ.get', (['"""SPEECH_KEY"""'], {}), "('SPEECH_KEY')\n", (855, 869), False, 'import os\n'), ((886, 917), 'os.environ.get', 'os.environ.get'... |
"""Configuration."""
import streamlit as st
import os
### DEFINE BUILDER_LLM #####
## Uncomment the LLM you want to use to construct the meta agent
## OpenAI
from llama_index.llms import OpenAI
# set OpenAI Key - use Streamlit secrets
os.environ["OPENAI_API_KEY"] = st.secrets.openai_key
# load LLM
BUILDER_LLM = Open... | [
"llama_index.llms.OpenAI"
] | [((316, 350), 'llama_index.llms.OpenAI', 'OpenAI', ([], {'model': '"""gpt-4-1106-preview"""'}), "(model='gpt-4-1106-preview')\n", (322, 350), False, 'from llama_index.llms import OpenAI\n')] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2024/1/4 20:58
@Author : alexanderwu
@File : embedding.py
"""
from llama_index.embeddings.openai import OpenAIEmbedding
from metagpt.config2 import config
def get_embedding() -> OpenAIEmbedding:
llm = config.get_openai_llm()
if llm is None:
... | [
"llama_index.embeddings.openai.OpenAIEmbedding"
] | [((273, 296), 'metagpt.config2.config.get_openai_llm', 'config.get_openai_llm', ([], {}), '()\n', (294, 296), False, 'from metagpt.config2 import config\n'), ((455, 514), 'llama_index.embeddings.openai.OpenAIEmbedding', 'OpenAIEmbedding', ([], {'api_key': 'llm.api_key', 'api_base': 'llm.base_url'}), '(api_key=llm.api_k... |
import os
# Uncomment to specify your OpenAI API key here (local testing only, not in production!), or add corresponding environment variable (recommended)
# os.environ['OPENAI_API_KEY']= ""
from llama_index import LLMPredictor, PromptHelper, SimpleDirectoryReader, ServiceContext
from langchain.llms.openai import O... | [
"llama_index.SimpleDirectoryReader",
"llama_index.ServiceContext.from_defaults",
"llama_index.StorageContext.from_defaults",
"llama_index.PromptHelper",
"llama_index.load_index_from_storage"
] | [((403, 464), 'os.environ.get', 'os.environ.get', (['"""OPENAI_API_BASE"""', '"""http://localhost:8080/v1"""'], {}), "('OPENAI_API_BASE', 'http://localhost:8080/v1')\n", (417, 464), False, 'import os\n'), ((788, 847), 'llama_index.PromptHelper', 'PromptHelper', (['max_input_size', 'num_output', 'max_chunk_overlap'], {}... |
from memgpt.data_types import Passage, Document, EmbeddingConfig, Source
from memgpt.utils import create_uuid_from_string
from memgpt.agent_store.storage import StorageConnector, TableType
from memgpt.embeddings import embedding_model
from memgpt.data_types import Document, Passage
from typing import List, Iterator, D... | [
"llama_index.core.node_parser.TokenTextSplitter",
"llama_index.readers.web.SimpleWebPageReader",
"llama_index.core.Document"
] | [((1472, 1505), 'memgpt.embeddings.embedding_model', 'embedding_model', (['embedding_config'], {}), '(embedding_config)\n', (1487, 1505), False, 'from memgpt.embeddings import embedding_model\n'), ((5412, 5452), 'llama_index.core.node_parser.TokenTextSplitter', 'TokenTextSplitter', ([], {'chunk_size': 'chunk_size'}), '... |
import os
from llama_index import SimpleDirectoryReader
from sqlalchemy.orm import Session
from superagi.config.config import get_config
from superagi.helper.resource_helper import ResourceHelper
from superagi.lib.logger import logger
from superagi.resource_manager.llama_vector_store_factory import LlamaVectorStoreFa... | [
"llama_index.VectorStoreIndex.from_documents",
"llama_index.SimpleDirectoryReader",
"llama_index.StorageContext.from_defaults"
] | [((1132, 1157), 'os.path.exists', 'os.path.exists', (['file_path'], {}), '(file_path)\n', (1146, 1157), False, 'import os\n'), ((1917, 1942), 'superagi.config.config.get_config', 'get_config', (['"""BUCKET_NAME"""'], {}), "('BUCKET_NAME')\n", (1927, 1942), False, 'from superagi.config.config import get_config\n'), ((25... |
import os
from argparse import Namespace, _SubParsersAction
from llama_index import SimpleDirectoryReader
from .configuration import load_index, save_index
def add_cli(args: Namespace) -> None:
"""Handle subcommand "add"."""
index = load_index()
for p in args.files:
if not os.path.exists(p):
... | [
"llama_index.SimpleDirectoryReader"
] | [((368, 384), 'os.path.isdir', 'os.path.isdir', (['p'], {}), '(p)\n', (381, 384), False, 'import os\n'), ((299, 316), 'os.path.exists', 'os.path.exists', (['p'], {}), '(p)\n', (313, 316), False, 'import os\n'), ((410, 434), 'llama_index.SimpleDirectoryReader', 'SimpleDirectoryReader', (['p'], {}), '(p)\n', (431, 434), ... |
from typing import Dict, List, Type
from llama_index.agent import OpenAIAgent, ReActAgent
from llama_index.agent.types import BaseAgent
from llama_index.llms import Anthropic, OpenAI
from llama_index.llms.llama_utils import messages_to_prompt
from llama_index.llms.llm import LLM
from llama_index.llms.replicate import ... | [
"llama_index.llms.Anthropic",
"llama_index.llms.OpenAI",
"llama_index.llms.replicate.Replicate"
] | [((1116, 1135), 'llama_index.llms.OpenAI', 'OpenAI', ([], {'model': 'model'}), '(model=model)\n', (1122, 1135), False, 'from llama_index.llms import Anthropic, OpenAI\n'), ((1186, 1208), 'llama_index.llms.Anthropic', 'Anthropic', ([], {'model': 'model'}), '(model=model)\n', (1195, 1208), False, 'from llama_index.llms i... |
import asyncio
import os
import shutil
from argparse import ArgumentParser
from glob import iglob
from pathlib import Path
from typing import Any, Callable, Dict, Optional, Union, cast
from llama_index.core import (
SimpleDirectoryReader,
VectorStoreIndex,
)
from llama_index.core.base.embeddings.base import Ba... | [
"llama_index.llms.openai.OpenAI",
"llama_index.core.bridge.pydantic.validator",
"llama_index.core.VectorStoreIndex.from_vector_store",
"llama_index.core.indices.service_context.ServiceContext.from_defaults",
"llama_index.core.bridge.pydantic.Field",
"llama_index.core.query_pipeline.components.function.FnC... | [((1789, 1840), 'llama_index.core.bridge.pydantic.Field', 'Field', ([], {'description': '"""Query Pipeline to use for Q&A."""'}), "(description='Query Pipeline to use for Q&A.')\n", (1794, 1840), False, 'from llama_index.core.bridge.pydantic import BaseModel, Field, validator\n'), ((2284, 2349), 'llama_index.core.bridg... |
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Callable, List, Optional
if TYPE_CHECKING:
from llama_index.core.service_context import ServiceContext
from llama_index.core.base.embeddings.base import BaseEmbedding
from llama_index.core.callbacks.base import BaseCallbackHandler, Callback... | [
"llama_index.core.llms.utils.resolve_llm",
"llama_index.core.utils.get_tokenizer",
"llama_index.core.indices.prompt_helper.PromptHelper.from_llm_metadata",
"llama_index.core.embeddings.utils.resolve_embed_model",
"llama_index.core.node_parser.SentenceSplitter",
"llama_index.core.callbacks.base.CallbackMan... | [((1701, 1717), 'llama_index.core.llms.utils.resolve_llm', 'resolve_llm', (['llm'], {}), '(llm)\n', (1712, 1717), False, 'from llama_index.core.llms.utils import LLMType, resolve_llm\n'), ((2647, 2679), 'llama_index.core.embeddings.utils.resolve_embed_model', 'resolve_embed_model', (['embed_model'], {}), '(embed_model)... |
import asyncio
from llama_index.core.llama_dataset import download_llama_dataset
from llama_index.core.llama_pack import download_llama_pack
from llama_index.core import VectorStoreIndex
async def main():
# DOWNLOAD LLAMADATASET
rag_dataset, documents = download_llama_dataset("CovidQaDataset", "./data")
... | [
"llama_index.core.VectorStoreIndex.from_documents",
"llama_index.core.llama_dataset.download_llama_dataset",
"llama_index.core.llama_pack.download_llama_pack"
] | [((265, 315), 'llama_index.core.llama_dataset.download_llama_dataset', 'download_llama_dataset', (['"""CovidQaDataset"""', '"""./data"""'], {}), "('CovidQaDataset', './data')\n", (287, 315), False, 'from llama_index.core.llama_dataset import download_llama_dataset\n'), ((360, 412), 'llama_index.core.VectorStoreIndex.fr... |
from typing import Any, Callable, Optional, Sequence
from llama_index.core.base.llms.types import (
ChatMessage,
CompletionResponse,
CompletionResponseGen,
LLMMetadata,
)
from llama_index.core.callbacks import CallbackManager
from llama_index.core.llms.callbacks import llm_completion_callback
from llam... | [
"llama_index.core.llms.callbacks.llm_completion_callback",
"llama_index.core.base.llms.types.LLMMetadata",
"llama_index.core.base.llms.types.CompletionResponse"
] | [((1532, 1557), 'llama_index.core.llms.callbacks.llm_completion_callback', 'llm_completion_callback', ([], {}), '()\n', (1555, 1557), False, 'from llama_index.core.llms.callbacks import llm_completion_callback\n'), ((1871, 1896), 'llama_index.core.llms.callbacks.llm_completion_callback', 'llm_completion_callback', ([],... |
from enum import Enum
from typing import Any, AsyncGenerator, Generator, Optional, Union, List
from llama_index.core.bridge.pydantic import BaseModel, Field
from llama_index.core.constants import DEFAULT_CONTEXT_WINDOW, DEFAULT_NUM_OUTPUTS
class MessageRole(str, Enum):
"""Message role."""
SYSTEM = "system"
... | [
"llama_index.core.bridge.pydantic.Field"
] | [((655, 682), 'llama_index.core.bridge.pydantic.Field', 'Field', ([], {'default_factory': 'dict'}), '(default_factory=dict)\n', (660, 682), False, 'from llama_index.core.bridge.pydantic import BaseModel, Field\n'), ((1146, 1172), 'llama_index.core.bridge.pydantic.Field', 'Field', ([], {'default_factory': 'str'}), '(def... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 5