text
stringlengths
3
1.68M
id
stringlengths
13
169
metadata
dict
__index_level_0__
int64
0
2.21k
"""Prompt for the router chain in the multi-prompt chain.""" MULTI_PROMPT_ROUTER_TEMPLATE = """\ Given a raw text input to a language model select the model prompt best suited for \ the input. You will be given the names of the available prompts and a description of \ what the prompt is best suited for. You may also r...
langchain/libs/langchain/langchain/chains/router/multi_prompt_prompt.py/0
{ "file_path": "langchain/libs/langchain/langchain/chains/router/multi_prompt_prompt.py", "repo_id": "langchain", "token_count": 323 }
490
# Copyright 2021 The HuggingFace Team. All rights reserved. # # 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 applicabl...
transformers/tests/models/clip/test_processor_clip.py/0
{ "file_path": "transformers/tests/models/clip/test_processor_clip.py", "repo_id": "transformers", "token_count": 3365 }
774
# Copyright 2020 The HuggingFace Team. All rights reserved. # # 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 applicabl...
transformers/src/transformers/models/mt5/__init__.py/0
{ "file_path": "transformers/src/transformers/models/mt5/__init__.py", "repo_id": "transformers", "token_count": 1418 }
638
"""Test chat model integration.""" from langchain_nvidia_ai_endpoints.chat_models import ChatNVIDIA def test_integration_initialization() -> None: """Test chat model initialization.""" ChatNVIDIA( model="llama2_13b", nvidia_api_key="nvapi-...", temperature=0.5, top_p=0.9, ...
langchain/libs/partners/nvidia-ai-endpoints/tests/unit_tests/test_chat_models.py/0
{ "file_path": "langchain/libs/partners/nvidia-ai-endpoints/tests/unit_tests/test_chat_models.py", "repo_id": "langchain", "token_count": 172 }
631
#[macro_use] mod types; mod collection; mod embedding_record; mod metadata; mod operation; mod scalar_encoding; mod segment; mod segment_scope; // Re-export the types module, so that we can use it as a single import in other modules. pub use collection::*; pub use embedding_record::*; pub use metadata::*; pub use oper...
chroma/rust/worker/src/types/mod.rs/0
{ "file_path": "chroma/rust/worker/src/types/mod.rs", "repo_id": "chroma", "token_count": 138 }
65
import { logVersion010MigrationWarning } from "../util/entrypoint_deprecation.js"; /* #__PURE__ */ logVersion010MigrationWarning({ oldEntrypointName: "vectorstores/vectara", }); export * from "@langchain/community/vectorstores/vectara";
langchainjs/langchain/src/vectorstores/vectara.ts/0
{ "file_path": "langchainjs/langchain/src/vectorstores/vectara.ts", "repo_id": "langchainjs", "token_count": 74 }
953
import { HNSWLib } from "@langchain/community/vectorstores/hnswlib"; import { OpenAIEmbeddings } from "@langchain/openai"; const vectorStore = await HNSWLib.fromTexts( ["Hello world", "Bye bye", "hello nice world"], [{ id: 2 }, { id: 1 }, { id: 3 }], new OpenAIEmbeddings() ); const result = await vectorStore.si...
langchainjs/examples/src/indexes/vector_stores/hnswlib_filter.ts/0
{ "file_path": "langchainjs/examples/src/indexes/vector_stores/hnswlib_filter.ts", "repo_id": "langchainjs", "token_count": 160 }
785
"""Loading datasets and evaluators.""" from typing import Any, Dict, List, Optional, Sequence, Type, Union from langchain_community.chat_models.openai import ChatOpenAI from langchain_core.language_models import BaseLanguageModel from langchain.chains.base import Chain from langchain.evaluation.agents.trajectory_eval...
langchain/libs/langchain/langchain/evaluation/loading.py/0
{ "file_path": "langchain/libs/langchain/langchain/evaluation/loading.py", "repo_id": "langchain", "token_count": 2609 }
551
import candle from typing import Dict, Tuple, Any from candle import Tensor, QTensor, utils, nn from candle.nn import Module, ModuleList def masked_fill(on_false: Tensor, mask: Tensor, on_true: Tensor): shape = mask.shape on_true = candle.tensor(on_true).broadcast_as(shape) return mask.where_cond(on_true,...
candle/candle-pyo3/py_src/candle/models/llama.py/0
{ "file_path": "candle/candle-pyo3/py_src/candle/models/llama.py", "repo_id": "candle", "token_count": 2981 }
66
python_sources()
llama_index/llama-index-core/llama_index/core/langchain_helpers/agents/BUILD/0
{ "file_path": "llama_index/llama-index-core/llama_index/core/langchain_helpers/agents/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,272
import base64 from email.message import EmailMessage from typing import List, Optional, Type from langchain_core.callbacks import CallbackManagerForToolRun from langchain_core.pydantic_v1 import BaseModel, Field from langchain_community.tools.gmail.base import GmailBaseTool class CreateDraftSchema(BaseModel): "...
langchain/libs/community/langchain_community/tools/gmail/create_draft.py/0
{ "file_path": "langchain/libs/community/langchain_community/tools/gmail/create_draft.py", "repo_id": "langchain", "token_count": 1104 }
308
import { PaddingDirection, WordPiece, punctuationPreTokenizer, sequencePreTokenizer, whitespacePreTokenizer, Encoding, EncodeOptions, Tokenizer, } from '../../' import { InputSequence } from '../../types' const MOCKS_DIR = __dirname + '/__mocks__' describe('Can modify pretokenizers on the fly', () => ...
tokenizers/bindings/node/lib/bindings/encoding.test.ts/0
{ "file_path": "tokenizers/bindings/node/lib/bindings/encoding.test.ts", "repo_id": "tokenizers", "token_count": 3021 }
432
"""Test indices/utils.py.""" from llama_index.legacy.indices.utils import expand_tokens_with_subtokens def test_expand_tokens_with_subtokens() -> None: """Test expand tokens.""" tokens = {"foo bar", "baz", "hello hello world bye"} keywords = expand_tokens_with_subtokens(tokens) assert keywords == { ...
llama_index/llama-index-legacy/tests/indices/test_utils.py/0
{ "file_path": "llama_index/llama-index-legacy/tests/indices/test_utils.py", "repo_id": "llama_index", "token_count": 219 }
1,664
# (Optional) the Policy Gradient Theorem In this optional section where we're **going to study how we differentiate the objective function that we will use to approximate the policy gradient**. Let's first recap our different formulas: 1. The Objective function <img src="https://huggingface.co/datasets/huggingface-...
deep-rl-class/units/en/unit4/pg-theorem.mdx/0
{ "file_path": "deep-rl-class/units/en/unit4/pg-theorem.mdx", "repo_id": "deep-rl-class", "token_count": 1814 }
160
from __future__ import annotations import logging import uuid from typing import ( Any, Iterable, List, Optional, Tuple, ) import numpy as np from langchain_core.documents import Document from langchain_core.embeddings import Embeddings from langchain_core.utils import get_from_env from langchain_...
langchain/libs/community/langchain_community/vectorstores/dashvector.py/0
{ "file_path": "langchain/libs/community/langchain_community/vectorstores/dashvector.py", "repo_id": "langchain", "token_count": 5693 }
335
"""Test prompt functionality."""
langchain/libs/langchain/tests/unit_tests/prompts/__init__.py/0
{ "file_path": "langchain/libs/langchain/tests/unit_tests/prompts/__init__.py", "repo_id": "langchain", "token_count": 7 }
664
from typing import TYPE_CHECKING from langchain_community.document_loaders.parsers.language.tree_sitter_segmenter import ( # noqa: E501 TreeSitterSegmenter, ) if TYPE_CHECKING: from tree_sitter import Language CHUNK_QUERY = """ [ (function_definition) @subroutine ] """.strip() class PerlS...
langchain/libs/community/langchain_community/document_loaders/parsers/language/perl.py/0
{ "file_path": "langchain/libs/community/langchain_community/document_loaders/parsers/language/perl.py", "repo_id": "langchain", "token_count": 263 }
244
# langchain-pinecone This package contains the LangChain integration with Pinecone. ## Installation ```bash pip install -U langchain-pinecone ``` And you should configure credentials by setting the following environment variables: - `PINECONE_API_KEY` - `PINECONE_INDEX_NAME` - `PINECONE_ENVIRONMENT` ## Usage The...
langchain/libs/partners/pinecone/README.md/0
{ "file_path": "langchain/libs/partners/pinecone/README.md", "repo_id": "langchain", "token_count": 167 }
679
python_sources()
llama_index/llama-index-integrations/readers/llama-index-readers-wordlift/llama_index/readers/wordlift/BUILD/0
{ "file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-wordlift/llama_index/readers/wordlift/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,437
# ControlNet training example for Stable Diffusion XL (SDXL) The `train_controlnet_sdxl.py` script shows how to implement the ControlNet training procedure and adapt it for [Stable Diffusion XL](https://huggingface.co/papers/2307.01952). ## Running locally with PyTorch ### Installing the dependencies Before running...
diffusers/examples/controlnet/README_sdxl.md/0
{ "file_path": "diffusers/examples/controlnet/README_sdxl.md", "repo_id": "diffusers", "token_count": 1519 }
205
#!/bin/bash # Licensed to the LF AI & Data foundation under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not...
milvus/tests/scripts/ci_e2e.sh/0
{ "file_path": "milvus/tests/scripts/ci_e2e.sh", "repo_id": "milvus", "token_count": 1336 }
2,011
[build-system] build-backend = "poetry.core.masonry.api" requires = ["poetry-core"] [tool.codespell] check-filenames = true check-hidden = true skip = "*.csv,*.html,*.json,*.jsonl,*.pdf,*.txt,*.ipynb" [tool.llamahub] classes = ["DatabaseReader"] contains_example = false import_path = "llama_index.readers.database" [...
llama_index/llama-index-integrations/readers/llama-index-readers-database/pyproject.toml/0
{ "file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-database/pyproject.toml", "repo_id": "llama_index", "token_count": 660 }
1,356
# coding=utf-8 # Copyright 2023 The Meta AI Authors and The HuggingFace Team. All rights reserved. # # 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/LICEN...
transformers/src/transformers/models/sam/modeling_sam.py/0
{ "file_path": "transformers/src/transformers/models/sam/modeling_sam.py", "repo_id": "transformers", "token_count": 27304 }
726
#!/usr/bin/env python # coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # 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/L...
transformers/src/transformers/tools/image_question_answering.py/0
{ "file_path": "transformers/src/transformers/tools/image_question_answering.py", "repo_id": "transformers", "token_count": 646 }
767
# Copyright 2020 The HuggingFace Team. All rights reserved. # # 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 applicabl...
transformers/src/transformers/models/rembert/__init__.py/0
{ "file_path": "transformers/src/transformers/models/rembert/__init__.py", "repo_id": "transformers", "token_count": 1913 }
723
from llama_index.core.base.embeddings.base import BaseEmbedding from llama_index.embeddings.sagemaker_endpoint import SageMakerEmbedding def test_text_inference_embedding_class(): names_of_base_classes = [b.__name__ for b in SageMakerEmbedding.__mro__] assert BaseEmbedding.__name__ in names_of_base_classes
llama_index/llama-index-integrations/embeddings/llama-index-embeddings-sagemaker-endpoint/tests/test_embeddings_sagemaker_endpoint.py/0
{ "file_path": "llama_index/llama-index-integrations/embeddings/llama-index-embeddings-sagemaker-endpoint/tests/test_embeddings_sagemaker_endpoint.py", "repo_id": "llama_index", "token_count": 112 }
1,256
// Copyright (C) 2019-2020 Zilliz. All rights reserved. // // 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 l...
milvus/pkg/util/metricsinfo/utils_test.go/0
{ "file_path": "milvus/pkg/util/metricsinfo/utils_test.go", "repo_id": "milvus", "token_count": 440 }
1,847
from llama_index.legacy.core.base_retriever import BaseRetriever from llama_index.legacy.core.image_retriever import BaseImageRetriever from llama_index.legacy.indices.empty.retrievers import EmptyIndexRetriever from llama_index.legacy.indices.keyword_table.retrievers import ( KeywordTableSimpleRetriever, ) from ll...
llama_index/llama-index-legacy/llama_index/legacy/retrievers/__init__.py/0
{ "file_path": "llama_index/llama-index-legacy/llama_index/legacy/retrievers/__init__.py", "repo_id": "llama_index", "token_count": 1101 }
1,614
import bz2 import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from ._filelock import FileLock from .logging import get_logger ...
datasets/src/datasets/utils/extract.py/0
{ "file_path": "datasets/src/datasets/utils/extract.py", "repo_id": "datasets", "token_count": 6410 }
140
python_tests()
llama_index/llama-index-packs/llama-index-packs-rag-fusion-query-pipeline/tests/BUILD/0
{ "file_path": "llama_index/llama-index-packs/llama-index-packs-rag-fusion-query-pipeline/tests/BUILD", "repo_id": "llama_index", "token_count": 5 }
1,810
#include "common.h" template<typename T> __device__ int set_insert(T *set, int set_size, T value) { int slot = value % set_size; int start_slot = slot; while (true) { T prev = atomicCAS(&set[slot], EMPTY_VALUE, value); if (prev == EMPTY_VALUE || prev == value) { return slot; } slot = (slot...
transformers/src/transformers/kernels/yoso/common_cuda_device.h/0
{ "file_path": "transformers/src/transformers/kernels/yoso/common_cuda_device.h", "repo_id": "transformers", "token_count": 892 }
613
"""Light weight unit test that attempts to import UpstashRedisStore. """ import pytest @pytest.mark.requires("upstash_redis") def test_import_storage() -> None: from langchain_community.storage.upstash_redis import UpstashRedisStore # noqa
langchain/libs/community/tests/unit_tests/storage/test_upstash_redis.py/0
{ "file_path": "langchain/libs/community/tests/unit_tests/storage/test_upstash_redis.py", "repo_id": "langchain", "token_count": 80 }
405
use crate::{Result, Tensor}; #[macro_export] macro_rules! test_device { // TODO: Switch to generating the two last arguments automatically once concat_idents is // stable. https://github.com/rust-lang/rust/issues/29599 ($fn_name: ident, $test_cpu: ident, $test_cuda: ident, $test_metal: ident) => { ...
candle/candle-core/src/test_utils.rs/0
{ "file_path": "candle/candle-core/src/test_utils.rs", "repo_id": "candle", "token_count": 923 }
42
import pytest from llama_index.core.storage.kvstore.simple_kvstore import SimpleKVStore @pytest.fixture() def simple_kvstore() -> SimpleKVStore: return SimpleKVStore()
llama_index/llama-index-core/tests/storage/conftest.py/0
{ "file_path": "llama_index/llama-index-core/tests/storage/conftest.py", "repo_id": "llama_index", "token_count": 62 }
1,277
# Copyright 2021 The HuggingFace Team. All rights reserved. # # 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 applicabl...
accelerate/setup.py/0
{ "file_path": "accelerate/setup.py", "repo_id": "accelerate", "token_count": 1631 }
9
from llama_index.extractors.entity.base import EntityExtractor __all__ = ["EntityExtractor"]
llama_index/llama-index-integrations/extractors/llama-index-extractors-entity/llama_index/extractors/entity/__init__.py/0
{ "file_path": "llama_index/llama-index-integrations/extractors/llama-index-extractors-entity/llama_index/extractors/entity/__init__.py", "repo_id": "llama_index", "token_count": 29 }
1,328
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor. # # 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....
datasets/metrics/competition_math/competition_math.py/0
{ "file_path": "datasets/metrics/competition_math/competition_math.py", "repo_id": "datasets", "token_count": 1181 }
138
# rag-codellama-fireworks This template performs RAG on a codebase. It uses codellama-34b hosted by Fireworks' [LLM inference API](https://blog.fireworks.ai/accelerating-code-completion-with-fireworks-fast-llm-inference-f4e8b5ec534a). ## Environment Setup Set the `FIREWORKS_API_KEY` environment variable to acces...
langchain/templates/rag-codellama-fireworks/README.md/0
{ "file_path": "langchain/templates/rag-codellama-fireworks/README.md", "repo_id": "langchain", "token_count": 707 }
727
# flake8: noqa from langchain.prompts.prompt import PromptTemplate template = ( """ # Generate Python3 Code to solve problems # Q: On the nightstand, there is a red pencil, a purple mug, a burgundy keychain, a fuchsia teddy bear, a black plate, and a blue stress ball. What color is the stress ball? # Put objects i...
langchain/libs/experimental/langchain_experimental/pal_chain/colored_object_prompt.py/0
{ "file_path": "langchain/libs/experimental/langchain_experimental/pal_chain/colored_object_prompt.py", "repo_id": "langchain", "token_count": 863 }
464
python_sources()
llama_index/llama-index-packs/llama-index-packs-gmail-openai-agent/llama_index/packs/gmail_openai_agent/BUILD/0
{ "file_path": "llama_index/llama-index-packs/llama-index-packs-gmail-openai-agent/llama_index/packs/gmail_openai_agent/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,569
<jupyter_start><jupyter_text>SQL Router Query EngineIn this tutorial, we define a custom router query engine that can route to either a SQL database or a vector database. Setup If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.<jupyter_code>%pip install llama-index-readers-wikip...
llama_index/docs/examples/query_engine/SQLRouterQueryEngine.ipynb/0
{ "file_path": "llama_index/docs/examples/query_engine/SQLRouterQueryEngine.ipynb", "repo_id": "llama_index", "token_count": 2398 }
1,123
# coding=utf-8 # Copyright 2024 HuggingFace Inc. # # 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 ag...
diffusers/tests/models/unets/test_models_unet_motion.py/0
{ "file_path": "diffusers/tests/models/unets/test_models_unet_motion.py", "repo_id": "diffusers", "token_count": 4946 }
258
import importlib import os import tempfile import types from contextlib import nullcontext as does_not_raise from multiprocessing import Process from pathlib import Path from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from...
datasets/tests/test_builder.py/0
{ "file_path": "datasets/tests/test_builder.py", "repo_id": "datasets", "token_count": 26439 }
159
"""Unit tests for document transformers.""" from langchain_community.document_transformers.embeddings_redundant_filter import ( _filter_similar_embeddings, ) from langchain.utils.math import cosine_similarity def test__filter_similar_embeddings() -> None: threshold = 0.79 embedded_docs = [[1.0, 2.0], [1....
langchain/libs/langchain/tests/unit_tests/test_document_transformers.py/0
{ "file_path": "langchain/libs/langchain/tests/unit_tests/test_document_transformers.py", "repo_id": "langchain", "token_count": 236 }
611
import pytest @pytest.fixture(scope="module") def flash_starcoder_gptq_handle(launcher): with launcher("Narsil/starcoder-gptq", num_shard=2, quantize="gptq") as handle: yield handle @pytest.fixture(scope="module") async def flash_starcoder_gptq(flash_starcoder_gptq_handle): await flash_starcoder_gpt...
text-generation-inference/integration-tests/models/test_flash_starcoder_gptq.py/0
{ "file_path": "text-generation-inference/integration-tests/models/test_flash_starcoder_gptq.py", "repo_id": "text-generation-inference", "token_count": 734 }
407
python_sources()
llama_index/llama-index-integrations/readers/llama-index-readers-pdb/llama_index/readers/pdb/BUILD/0
{ "file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-pdb/llama_index/readers/pdb/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,538
import { AgentExecutor } from "langchain/agents"; import { XMLAgentOutputParser } from "langchain/agents/xml/output_parser"; import { renderTextDescription } from "langchain/tools/render"; import { formatLogToMessage } from "langchain/agents/format_scratchpad/log_to_message"; import { Tool } from "@langchain/core/tools...
langchainjs/examples/src/agents/xml_runnable.ts/0
{ "file_path": "langchainjs/examples/src/agents/xml_runnable.ts", "repo_id": "langchainjs", "token_count": 1075 }
841
//! Popular tokenizer models. pub mod bpe; pub mod unigram; pub mod wordlevel; pub mod wordpiece; use std::collections::HashMap; use std::path::{Path, PathBuf}; use serde::{Deserialize, Serialize, Serializer}; use crate::models::bpe::{BpeTrainer, BPE}; use crate::models::unigram::{Unigram, UnigramTrainer}; use crat...
tokenizers/tokenizers/src/models/mod.rs/0
{ "file_path": "tokenizers/tokenizers/src/models/mod.rs", "repo_id": "tokenizers", "token_count": 3660 }
430
pub mod bpe; pub mod byte_fallback; pub mod ctc; pub mod fuse; pub mod sequence; pub mod strip; pub mod wordpiece; // Re-export these as decoders pub use super::pre_tokenizers::byte_level; pub use super::pre_tokenizers::metaspace; use serde::{Deserialize, Serialize}; use crate::decoders::bpe::BPEDecoder; use crate::...
tokenizers/tokenizers/src/decoders/mod.rs/0
{ "file_path": "tokenizers/tokenizers/src/decoders/mod.rs", "repo_id": "tokenizers", "token_count": 1434 }
434
<jupyter_start><jupyter_text>Préparer des données (PyTorch) Installez les bibliothèques 🤗 *Transformers* et 🤗 *Datasets* pour exécuter ce *notebook*.<jupyter_code>!pip install datasets transformers[sentencepiece] import torch from transformers import AdamW, AutoTokenizer, AutoModelForSequenceClassification # Comme ...
notebooks/course/fr/chapter3/section2_pt.ipynb/0
{ "file_path": "notebooks/course/fr/chapter3/section2_pt.ipynb", "repo_id": "notebooks", "token_count": 784 }
289
import logging from typing import Any, Dict, List, Optional import requests from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM from langchain_core.pydantic_v1 import Field, root_validator from langchain_core.utils import get_from_dict_or_env logger = logg...
langchain/libs/community/langchain_community/llms/oci_data_science_model_deployment_endpoint.py/0
{ "file_path": "langchain/libs/community/langchain_community/llms/oci_data_science_model_deployment_endpoint.py", "repo_id": "langchain", "token_count": 5173 }
270
import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Type from openai.resources import Completions from tenacity import ( before_sleep_log, retry, retry_if_exception_type, stop_after_attempt, wait_exponential, ) from llama_index.legacy.bridge.pydantic import BaseModel f...
llama_index/llama-index-legacy/llama_index/legacy/llms/litellm_utils.py/0
{ "file_path": "llama_index/llama-index-legacy/llama_index/legacy/llms/litellm_utils.py", "repo_id": "llama_index", "token_count": 2496 }
1,734
from abc import ABC, abstractmethod from enum import Enum from typing import ( Any, AsyncGenerator, Dict, Generator, Generic, List, Protocol, Type, TypeVar, Union, runtime_checkable, ) from llama_index.core.base.llms.types import ChatMessage, MessageRole from llama_index.cor...
llama_index/llama-index-core/llama_index/core/types.py/0
{ "file_path": "llama_index/llama-index-core/llama_index/core/types.py", "repo_id": "llama_index", "token_count": 905 }
1,304
import { logVersion010MigrationWarning } from "../../util/entrypoint_deprecation.js"; /* #__PURE__ */ logVersion010MigrationWarning({ oldEntrypointName: "stores/message/xata", }); export * from "@langchain/community/stores/message/xata";
langchainjs/langchain/src/stores/message/xata.ts/0
{ "file_path": "langchainjs/langchain/src/stores/message/xata.ts", "repo_id": "langchainjs", "token_count": 75 }
992
python_sources()
llama_index/llama-index-integrations/storage/kvstore/llama-index-storage-kvstore-mongodb/llama_index/storage/kvstore/mongodb/BUILD/0
{ "file_path": "llama_index/llama-index-integrations/storage/kvstore/llama-index-storage-kvstore-mongodb/llama_index/storage/kvstore/mongodb/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,467
use candle::{DType, Device, IndexOp, Result, Tensor}; use candle_nn::{batch_norm, conv2d, conv2d_no_bias, Func, Module, VarBuilder}; use std::collections::BTreeMap; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; #[derive(Debug)] struct Block { block_type: String, parameters: BTreeMa...
candle/candle-examples/examples/yolo-v3/darknet.rs/0
{ "file_path": "candle/candle-examples/examples/yolo-v3/darknet.rs", "repo_id": "candle", "token_count": 5403 }
46
<!--Copyright 2022 The HuggingFace Team. All rights reserved. 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...
transformers/docs/source/it/pipeline_tutorial.md/0
{ "file_path": "transformers/docs/source/it/pipeline_tutorial.md", "repo_id": "transformers", "token_count": 2390 }
521
import datetime import uuid from enum import Enum from typing import Any import pytest from langchain.schema.messages import ( HumanMessage, HumanMessageChunk, SystemMessage, ) from langchain.schema.output import ChatGeneration try: from pydantic.v1 import BaseModel except ImportError: from pydant...
langserve/tests/unit_tests/test_serialization.py/0
{ "file_path": "langserve/tests/unit_tests/test_serialization.py", "repo_id": "langserve", "token_count": 2691 }
1,016
# Notion Tool This tool loads and updates documents from Notion. The user specifies an API token to initialize the NotionToolSpec. ## Usage This tool has more extensive example usage documented in a Jupyter notebook [here](https://github.com/emptycrown/llama-hub/tree/main/llama_hub/tools/notebooks/notion.ipynb) Her...
llama_index/llama-index-integrations/tools/llama-index-tools-notion/README.md/0
{ "file_path": "llama_index/llama-index-integrations/tools/llama-index-tools-notion/README.md", "repo_id": "llama_index", "token_count": 294 }
1,487
--- hide_table_of_contents: true sidebar_position: 6 --- # Summarization A common use case is wanting to summarize long documents. This naturally runs into the context window limitations. Unlike in question-answering, you can't just do some semantic search hacks to only select the chunks of text most relevant to the ...
langchainjs/docs/core_docs/docs/use_cases/summarization.mdx/0
{ "file_path": "langchainjs/docs/core_docs/docs/use_cases/summarization.mdx", "repo_id": "langchainjs", "token_count": 313 }
770
import os from collections import deque import torch from torch.utils.data import Dataset # ------------ # Data loading # ------------ class CNNDMDataset(Dataset): """Abstracts the dataset used to train seq2seq models. The class will process the documents that are located in the specified folder. The ...
transformers/examples/research_projects/bertabs/utils_summarization.py/0
{ "file_path": "transformers/examples/research_projects/bertabs/utils_summarization.py", "repo_id": "transformers", "token_count": 2180 }
556
package registry import ( "context" "sync" "go.uber.org/atomic" qnClient "github.com/milvus-io/milvus/internal/distributed/querynode/client" "github.com/milvus-io/milvus/internal/types" "github.com/milvus-io/milvus/internal/util/wrappers" "github.com/milvus-io/milvus/pkg/util/typeutil" ) var ( once sync.Onc...
milvus/internal/registry/in_mem_resolver.go/0
{ "file_path": "milvus/internal/registry/in_mem_resolver.go", "repo_id": "milvus", "token_count": 457 }
2,053
<jupyter_start><jupyter_text>Nvidia TensorRT-LLM TensorRT-LLM provides users with an easy-to-use Python API to define Large Language Models (LLMs) and build TensorRT engines that contain state-of-the-art optimizations to perform inference efficiently on NVIDIA GPUs.[TensorRT-LLM Github](https://github.com/NVIDIA/Tensor...
llama_index/docs/examples/llm/nvidia_tensorrt.ipynb/0
{ "file_path": "llama_index/docs/examples/llm/nvidia_tensorrt.ipynb", "repo_id": "llama_index", "token_count": 753 }
1,068
python_sources()
llama_index/llama-index-integrations/readers/llama-index-readers-earnings-call-transcript/llama_index/readers/earnings_call_transcript/BUILD/0
{ "file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-earnings-call-transcript/llama_index/readers/earnings_call_transcript/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,309
// Licensed to the LF AI & Data foundation under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use th...
milvus/internal/datacoord/index_builder.go/0
{ "file_path": "milvus/internal/datacoord/index_builder.go", "repo_id": "milvus", "token_count": 7725 }
1,765
package paramtable import ( "testing" "github.com/stretchr/testify/assert" "github.com/milvus-io/milvus/pkg/config" ) func TestRoleConfig_Init(t *testing.T) { params := ComponentParam{} params.Init(NewBaseTable(SkipRemote(true))) cfg := &params.RoleCfg assert.Equal(t, cfg.Enabled.GetAsBool(), false) assert....
milvus/pkg/util/paramtable/role_param_test.go/0
{ "file_path": "milvus/pkg/util/paramtable/role_param_test.go", "repo_id": "milvus", "token_count": 677 }
2,119
# RAG with Timescale Vector using hybrid search This template shows how to use timescale-vector with the self-query retriver to perform hybrid search on similarity and time. This is useful any time your data has a strong time-based component. Some examples of such data are: - News articles (politics, business, etc) - ...
langchain/templates/rag-timescale-hybrid-search-time/README.md/0
{ "file_path": "langchain/templates/rag-timescale-hybrid-search-time/README.md", "repo_id": "langchain", "token_count": 1479 }
701
python_tests( interpreter_constraints=["==3.9.*", "==3.10.*"], )
llama_index/llama-index-packs/llama-index-packs-agent-search-retriever/tests/BUILD/0
{ "file_path": "llama_index/llama-index-packs/llama-index-packs-agent-search-retriever/tests/BUILD", "repo_id": "llama_index", "token_count": 29 }
1,768
<jupyter_start><jupyter_text>NomicNomic currently offers two products:- Atlas: their Visual Data Engine- GPT4All: their Open Source Edge Language Model EcosystemThe Nomic integration exists in its own [partner package](https://pypi.org/project/langchain-nomic/). You can install it with:<jupyter_code>%pip install -qU la...
langchain/docs/docs/integrations/providers/nomic.ipynb/0
{ "file_path": "langchain/docs/docs/integrations/providers/nomic.ipynb", "repo_id": "langchain", "token_count": 180 }
151
from langchain_community.tools.google_jobs.tool import GoogleJobsQueryRun __all__ = ["GoogleJobsQueryRun"]
langchain/libs/langchain/langchain/tools/google_jobs/tool.py/0
{ "file_path": "langchain/libs/langchain/langchain/tools/google_jobs/tool.py", "repo_id": "langchain", "token_count": 33 }
577
import { execSync } from 'child_process'; import fs from 'fs'; import { fileURLToPath } from 'url'; import path from 'path'; // Convert the URL to a file path const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); // Adjust the path to your package.json as necessary const packa...
langsmith-sdk/js/scripts/check-npm-version.js/0
{ "file_path": "langsmith-sdk/js/scripts/check-npm-version.js", "repo_id": "langsmith-sdk", "token_count": 358 }
1,065
<jupyter_start><jupyter_text>How to scale LLM workloads to 20B+ with multi-node clusters on Amazon SageMaker using Hugging Face and PyTorch FSDPIn this tutorial, we will fine-tune the new [GPT-NeoXT-Chat-Base-20B](https://huggingface.co/togethercomputer/GPT-NeoXT-Chat-Base-20B) on the [ELI5](https://huggingface.co/data...
notebooks/sagemaker/25_pytorch_fsdp_model_parallelism/sagemaker-notebook.ipynb/0
{ "file_path": "notebooks/sagemaker/25_pytorch_fsdp_model_parallelism/sagemaker-notebook.ipynb", "repo_id": "notebooks", "token_count": 3866 }
291
# coding=utf-8 # Copyright 2024 HuggingFace Inc. # # 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 ag...
diffusers/tests/pipelines/kandinsky/test_kandinsky_prior.py/0
{ "file_path": "diffusers/tests/pipelines/kandinsky/test_kandinsky_prior.py", "repo_id": "diffusers", "token_count": 3239 }
270
# TruLens This page covers how to use [TruLens](https://trulens.org) to evaluate and track LLM apps built on langchain. ## What is TruLens? TruLens is an [open-source](https://github.com/truera/trulens) package that provides instrumentation and evaluation tools for large language model (LLM) based applications. ## ...
langchain/docs/docs/integrations/providers/trulens.mdx/0
{ "file_path": "langchain/docs/docs/integrations/providers/trulens.mdx", "repo_id": "langchain", "token_count": 637 }
155
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # 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...
transformers/src/transformers/models/fuyu/processing_fuyu.py/0
{ "file_path": "transformers/src/transformers/models/fuyu/processing_fuyu.py", "repo_id": "transformers", "token_count": 13839 }
668
{ "modelname": "FlaxNewENCDEC", "uppercase_modelname": "FLAX_NEW_ENC_DEC", "lowercase_modelname": "flax_new_enc_dec_template", "camelcase_modelname": "FlaxNewEncDec", "authors": "The HuggingFace Team", "checkpoint_identifier": "new-flax-enc-dec-base", "tokenizer_type": "Based on BART", "generate_tensorf...
transformers/templates/adding_a_new_model/tests/flax-seq-2-seq-bart-tokenizer.json/0
{ "file_path": "transformers/templates/adding_a_new_model/tests/flax-seq-2-seq-bart-tokenizer.json", "repo_id": "transformers", "token_count": 161 }
722
<!--Copyright 2022 The HuggingFace Team. All rights reserved. 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...
accelerate/docs/source/basic_tutorials/notebook.md/0
{ "file_path": "accelerate/docs/source/basic_tutorials/notebook.md", "repo_id": "accelerate", "token_count": 5538 }
2
"""Base class for Amadeus tools.""" from __future__ import annotations from typing import TYPE_CHECKING from langchain_core.pydantic_v1 import Field from langchain_core.tools import BaseTool from langchain_community.tools.amadeus.utils import authenticate if TYPE_CHECKING: from amadeus import Client class Ama...
langchain/libs/community/langchain_community/tools/amadeus/base.py/0
{ "file_path": "langchain/libs/community/langchain_community/tools/amadeus/base.py", "repo_id": "langchain", "token_count": 133 }
295
# LlamaIndex Vector_Stores Integration: Opensearch
llama_index/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/README.md/0
{ "file_path": "llama_index/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/README.md", "repo_id": "llama_index", "token_count": 14 }
1,529
export { RemoteRetriever, type RemoteRetrieverParams, type RemoteRetrieverAuth, type RemoteRetrieverValues, } from "./base.js";
langchainjs/libs/langchain-community/src/retrievers/remote/index.ts/0
{ "file_path": "langchainjs/libs/langchain-community/src/retrievers/remote/index.ts", "repo_id": "langchainjs", "token_count": 47 }
1,007
// Code generated by mockery v2.32.4. DO NOT EDIT. package mocks import ( context "context" mmap "golang.org/x/exp/mmap" mock "github.com/stretchr/testify/mock" storage "github.com/milvus-io/milvus/internal/storage" time "time" ) // ChunkManager is an autogenerated mock type for the ChunkManager type type C...
milvus/internal/mocks/mock_chunk_manager.go/0
{ "file_path": "milvus/internal/mocks/mock_chunk_manager.go", "repo_id": "milvus", "token_count": 10009 }
1,812
// Licensed to the LF AI & Data foundation under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use th...
milvus/pkg/util/typeutil/time.go/0
{ "file_path": "milvus/pkg/util/typeutil/time.go", "repo_id": "milvus", "token_count": 435 }
1,982
from langchain.chains import ConversationChain from langchain.memory import ConversationBufferMemory from langchain_community.chat_message_histories import StreamlitChatMessageHistory from langchain_core.runnables import RunnableConfig from langchain_core.tracers import LangChainTracer from langchain_core.tracers.run_c...
streamlit-agent/streamlit_agent/simple_feedback.py/0
{ "file_path": "streamlit-agent/streamlit_agent/simple_feedback.py", "repo_id": "streamlit-agent", "token_count": 1181 }
2,146
<!--Copyright 2022 The HuggingFace Team. All rights reserved. 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...
transformers/docs/source/en/main_classes/text_generation.md/0
{ "file_path": "transformers/docs/source/en/main_classes/text_generation.md", "repo_id": "transformers", "token_count": 625 }
449
<!--Copyright 2023 The HuggingFace Team. All rights reserved. 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...
transformers/docs/source/zh/transformers_agents.md/0
{ "file_path": "transformers/docs/source/zh/transformers_agents.md", "repo_id": "transformers", "token_count": 8118 }
536
# LlamaIndex Indices Integration: Llama-Cloud
llama_index/llama-index-integrations/indices/llama-index-indices-managed-llama-cloud/README.md/0
{ "file_path": "llama_index/llama-index-integrations/indices/llama-index-indices-managed-llama-cloud/README.md", "repo_id": "llama_index", "token_count": 13 }
1,383
python_sources()
llama_index/llama-index-core/llama_index/core/llama_pack/BUILD/0
{ "file_path": "llama_index/llama-index-core/llama_index/core/llama_pack/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,199
language: generic dist: bionic matrix: include: - env: CXX=g++-10 CC=gcc-10 addons: apt: packages: - g++-10 sources: - sourceline: 'ppa:ubuntu-toolchain-r/test' - env: CXX=g++-9 CC=gcc-9 addons: apt: packages: - ...
milvus/internal/core/thirdparty/NamedType/.travis.yml/0
{ "file_path": "milvus/internal/core/thirdparty/NamedType/.travis.yml", "repo_id": "milvus", "token_count": 1419 }
1,778
from typing import Any, List, Tuple from unittest.mock import patch from llama_index.core.graph_stores import SimpleGraphStore from llama_index.core.embeddings import BaseEmbedding from llama_index.core.indices.knowledge_graph.base import KnowledgeGraphIndex from llama_index.core.indices.knowledge_graph.retrievers imp...
llama_index/llama-index-core/tests/indices/knowledge_graph/test_retrievers.py/0
{ "file_path": "llama_index/llama-index-core/tests/indices/knowledge_graph/test_retrievers.py", "repo_id": "llama_index", "token_count": 2855 }
1,312
use super::*; use half::{bf16, f16}; use metal::{Buffer, Device, MTLResourceOptions}; fn read_to_vec<T: Clone>(buffer: &Buffer, n: usize) -> Vec<T> { let ptr = buffer.contents() as *const T; assert!(!ptr.is_null()); let slice = unsafe { std::slice::from_raw_parts(ptr, n) }; slice.to_vec() } fn new_buf...
candle/candle-metal-kernels/src/tests.rs/0
{ "file_path": "candle/candle-metal-kernels/src/tests.rs", "repo_id": "candle", "token_count": 15812 }
58
#[cfg(feature = "progressbar")] pub(crate) use indicatif::{ProgressBar, ProgressStyle}; #[cfg(not(feature = "progressbar"))] mod progressbar { use std::borrow::Cow; pub struct ProgressBar; impl ProgressBar { pub fn new(_length: u64) -> Self { Self {} } pub fn set_length...
tokenizers/tokenizers/src/utils/progress.rs/0
{ "file_path": "tokenizers/tokenizers/src/utils/progress.rs", "repo_id": "tokenizers", "token_count": 403 }
442
--- sidebar_label: Together AI --- # Together AI The `TogetherAIEmbeddings` class uses the Together AI API to generate embeddings for a given text. ## Setup In order to use the Together API you'll need an API key. You can sign up for a Together account and create an API key [here](https://www.api.together.ai/). Yo...
langchainjs/docs/core_docs/docs/integrations/text_embedding/togetherai.mdx/0
{ "file_path": "langchainjs/docs/core_docs/docs/integrations/text_embedding/togetherai.mdx", "repo_id": "langchainjs", "token_count": 242 }
790
# Copyright 2024 The HuggingFace Team. All rights reserved. # # 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 applicabl...
diffusers/src/diffusers/pipelines/animatediff/pipeline_animatediff.py/0
{ "file_path": "diffusers/src/diffusers/pipelines/animatediff/pipeline_animatediff.py", "repo_id": "diffusers", "token_count": 23366 }
234
from typing import Any, Dict, List, Optional from llama_index.core.readers.base import BaseReader from llama_index.core.schema import Document class MetalReader(BaseReader): """Metal reader. Args: api_key (str): Metal API key. client_id (str): Metal client ID. index_id (str): Metal i...
llama_index/llama-index-integrations/readers/llama-index-readers-metal/llama_index/readers/metal/base.py/0
{ "file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-metal/llama_index/readers/metal/base.py", "repo_id": "llama_index", "token_count": 1006 }
1,384
""" Class-Attention in Image Transformers (CaiT) Paper: 'Going deeper with Image Transformers' - https://arxiv.org/abs/2103.17239 Original code and weights from https://github.com/facebookresearch/deit, copyright below Modifications and additions for timm hacked together by / Copyright 2021, Ross Wightman """ # Copy...
pytorch-image-models/timm/models/cait.py/0
{ "file_path": "pytorch-image-models/timm/models/cait.py", "repo_id": "pytorch-image-models", "token_count": 9133 }
399
from typing import List import requests from llama_index.core.readers.base import BaseReader from llama_index.core.schema import Document class MainContentExtractorReader(BaseReader): """MainContentExtractor web page reader. Reads pages from the web. Args: text_format (str, optional): The forma...
llama_index/llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/main_content_extractor/base.py/0
{ "file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/main_content_extractor/base.py", "repo_id": "llama_index", "token_count": 516 }
1,467
python_sources()
llama_index/llama-index-integrations/storage/kvstore/llama-index-storage-kvstore-redis/llama_index/storage/kvstore/redis/BUILD/0
{ "file_path": "llama_index/llama-index-integrations/storage/kvstore/llama-index-storage-kvstore-redis/llama_index/storage/kvstore/redis/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,469
# Remote Page/File Loader This loader makes it easy to extract the text from the links available in a webpage URL, and extract the links presents in the page. It's based on `RemoteReader` (reading single page), that is based on `SimpleDirectoryReader` (parsing the document if file is a pdf, etc). It is an all-in-one t...
llama_index/llama-index-integrations/readers/llama-index-readers-remote-depth/README.md/0
{ "file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-remote-depth/README.md", "repo_id": "llama_index", "token_count": 424 }
1,412
[tool.poetry] name = "neo4j-semantic-layer" version = "0.1.0" description = "Build a semantic layer to allow an agent to interact with a graph database in consistent and robust way." authors = [ "Tomaz Bratanic <tomaz.bratanic@neo4j.com>", ] readme = "README.md" [tool.poetry.dependencies] python = ">=3.8.1,<4.0" l...
langchain/templates/neo4j-semantic-layer/pyproject.toml/0
{ "file_path": "langchain/templates/neo4j-semantic-layer/pyproject.toml", "repo_id": "langchain", "token_count": 322 }
700
#!/usr/bin/env python # coding=utf-8 # Copyright 2024 The HuggingFace Inc. team. All rights reserved. # # 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/LI...
diffusers/examples/advanced_diffusion_training/train_dreambooth_lora_sdxl_advanced.py/0
{ "file_path": "diffusers/examples/advanced_diffusion_training/train_dreambooth_lora_sdxl_advanced.py", "repo_id": "diffusers", "token_count": 43852 }
209