text
stringlengths
3
1.68M
id
stringlengths
13
169
metadata
dict
__index_level_0__
int64
0
2.21k
"""Init file.""" from llama_index.legacy.llama_pack.base import BaseLlamaPack from llama_index.legacy.llama_pack.download import download_llama_pack __all__ = [ "BaseLlamaPack", "download_llama_pack", ]
llama_index/llama-index-legacy/llama_index/legacy/llama_pack/__init__.py/0
{ "file_path": "llama_index/llama-index-legacy/llama_index/legacy/llama_pack/__init__.py", "repo_id": "llama_index", "token_count": 84 }
1,611
"""List-based data structures."""
llama_index/llama-index-legacy/tests/indices/list/__init__.py/0
{ "file_path": "llama_index/llama-index-legacy/tests/indices/list/__init__.py", "repo_id": "llama_index", "token_count": 9 }
1,631
from llama_index.storage.docstore.mongodb.base import MongoDocumentStore __all__ = ["MongoDocumentStore"]
llama_index/llama-index-integrations/storage/docstore/llama-index-storage-docstore-mongodb/llama_index/storage/docstore/mongodb/__init__.py/0
{ "file_path": "llama_index/llama-index-integrations/storage/docstore/llama-index-storage-docstore-mongodb/llama_index/storage/docstore/mongodb/__init__.py", "repo_id": "llama_index", "token_count": 33 }
1,455
"""Init file."""
llama_index/llama-index-legacy/tests/mock_utils/__init__.py/0
{ "file_path": "llama_index/llama-index-legacy/tests/mock_utils/__init__.py", "repo_id": "llama_index", "token_count": 6 }
1,672
import { logVersion010MigrationWarning } from "../util/entrypoint_deprecation.js"; /* #__PURE__ */ logVersion010MigrationWarning({ oldEntrypointName: "vectorstores/weaviate", newEntrypointName: "", newPackageName: "@langchain/weaviate", }); export * from "@langchain/community/vectorstores/weaviate";
langchainjs/langchain/src/vectorstores/weaviate.ts/0
{ "file_path": "langchainjs/langchain/src/vectorstores/weaviate.ts", "repo_id": "langchainjs", "token_count": 97 }
925
import { FewShotPromptTemplate, PromptTemplate } from "@langchain/core/prompts"; const constitutionalPrompt = `Human: {input_prompt} Model: {output_from_model} Critique Request: {critique_request} Critique: {critique} Revision request: {revision_request} Revision: {revision}`; export const critiqu...
langchainjs/langchain/src/chains/constitutional_ai/constitutional_prompts.ts/0
{ "file_path": "langchainjs/langchain/src/chains/constitutional_ai/constitutional_prompts.ts", "repo_id": "langchainjs", "token_count": 1881 }
879
import { ChatOpenAI } from "@langchain/openai"; import { ConversationChain } from "langchain/chains"; import { MotorheadMemory } from "@langchain/community/memory/motorhead_memory"; // Managed Example (visit https://getmetal.io to get your keys) // const managedMemory = new MotorheadMemory({ // memoryKey: "chat_hist...
langchainjs/examples/src/memory/motorhead.ts/0
{ "file_path": "langchainjs/examples/src/memory/motorhead.ts", "repo_id": "langchainjs", "token_count": 375 }
826
"""SAP HANA Cloud Vector Engine""" from __future__ import annotations import importlib.util import json import re from typing import ( TYPE_CHECKING, Callable, Iterable, List, Optional, Tuple, Type, ) import numpy as np from langchain_core.documents import Document from langchain_core.embe...
langchain/libs/community/langchain_community/vectorstores/hanavector.py/0
{ "file_path": "langchain/libs/community/langchain_community/vectorstores/hanavector.py", "repo_id": "langchain", "token_count": 10192 }
308
<!--- 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 applicable law or ...
transformers/examples/pytorch/image-classification/README.md/0
{ "file_path": "transformers/examples/pytorch/image-classification/README.md", "repo_id": "transformers", "token_count": 2874 }
585
#!/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/research_projects/onnxruntime/text_to_image/train_text_to_image.py/0
{ "file_path": "diffusers/examples/research_projects/onnxruntime/text_to_image/train_text_to_image.py", "repo_id": "diffusers", "token_count": 17009 }
218
"""Init file."""
llama_index/llama-index-core/tests/indices/__init__.py/0
{ "file_path": "llama_index/llama-index-core/tests/indices/__init__.py", "repo_id": "llama_index", "token_count": 6 }
1,206
import re def convert_to_kebab_case(input_string: str) -> str: matches = re.findall( r"/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g", input_string.lower(), ) return "-".join(matches)
llama_index/llama-index-legacy/llama_index/legacy/llm_predictor/vellum/utils.py/0
{ "file_path": "llama_index/llama-index-legacy/llama_index/legacy/llm_predictor/vellum/utils.py", "repo_id": "llama_index", "token_count": 140 }
1,676
import { RaycastAI } from "@langchain/community/llms/raycast"; import { showHUD } from "@raycast/api"; import { initializeAgentExecutorWithOptions } from "langchain/agents"; import { Tool } from "@langchain/core/tools"; const model = new RaycastAI({ rateLimitPerMinute: 10, // It is 10 by default so you can omit thi...
langchainjs/examples/src/models/llm/raycast.ts/0
{ "file_path": "langchainjs/examples/src/models/llm/raycast.ts", "repo_id": "langchainjs", "token_count": 273 }
813
python_sources()
llama_index/llama-index-legacy/llama_index/legacy/finetuning/openai/BUILD/0
{ "file_path": "llama_index/llama-index-legacy/llama_index/legacy/finetuning/openai/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,492
<!--- 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 applicable law or ...
transformers/examples/pytorch/text-classification/README.md/0
{ "file_path": "transformers/examples/pytorch/text-classification/README.md", "repo_id": "transformers", "token_count": 4133 }
564
# Copyright 2024 Long Lian, the GLIGEN 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/LICENSE-2...
diffusers/examples/community/llm_grounded_diffusion.py/0
{ "file_path": "diffusers/examples/community/llm_grounded_diffusion.py", "repo_id": "diffusers", "token_count": 33954 }
198
<jupyter_start><jupyter_text>Guide: Using Vector Store Index with Existing Pinecone Vector Store If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.<jupyter_code>%pip install llama-index-embeddings-openai %pip install llama-index-vector-stores-pinecone !pip install llama-index imp...
llama_index/docs/examples/vector_stores/existing_data/pinecone_existing_data.ipynb/0
{ "file_path": "llama_index/docs/examples/vector_stores/existing_data/pinecone_existing_data.ipynb", "repo_id": "llama_index", "token_count": 1418 }
1,220
from typing import Optional from llama_index.core.base.llms.types import ChatMessage from typing_extensions import NotRequired, TypedDict XINFERENCE_MODEL_SIZES = { "baichuan": 2048, "baichuan-chat": 2048, "wizardlm-v1.0": 2048, "vicuna-v1.3": 2048, "orca": 2048, "chatglm": 2048, "chatglm2...
llama_index/llama-index-integrations/llms/llama-index-llms-xinference/llama_index/llms/xinference/utils.py/0
{ "file_path": "llama_index/llama-index-integrations/llms/llama-index-llms-xinference/llama_index/llms/xinference/utils.py", "repo_id": "llama_index", "token_count": 415 }
1,379
import { ApifyDatasetLoader } from "langchain/document_loaders/web/apify_dataset"; import { HNSWLib } from "@langchain/community/vectorstores/hnswlib"; import { OpenAIEmbeddings, ChatOpenAI } from "@langchain/openai"; import { Document } from "@langchain/core/documents"; import { ChatPromptTemplate } from "@langchain/c...
langchainjs/examples/src/document_loaders/apify_dataset_existing.ts/0
{ "file_path": "langchainjs/examples/src/document_loaders/apify_dataset_existing.ts", "repo_id": "langchainjs", "token_count": 700 }
793
import { VespaRetriever } from "@langchain/community/retrievers/vespa"; export const run = async () => { const url = "https://doc-search.vespa.oath.cloud"; const query_body = { yql: "select content from paragraph where userQuery()", hits: 5, ranking: "documentation", locale: "en-us", }; const c...
langchainjs/examples/src/retrievers/vespa.ts/0
{ "file_path": "langchainjs/examples/src/retrievers/vespa.ts", "repo_id": "langchainjs", "token_count": 197 }
863
from langchain_community.tools.playwright.extract_text import ExtractTextTool __all__ = ["ExtractTextTool"]
langchain/libs/langchain/langchain/tools/playwright/extract_text.py/0
{ "file_path": "langchain/libs/langchain/langchain/tools/playwright/extract_text.py", "repo_id": "langchain", "token_count": 32 }
583
python_tests()
llama_index/llama-index-integrations/embeddings/llama-index-embeddings-elasticsearch/tests/BUILD/0
{ "file_path": "llama_index/llama-index-integrations/embeddings/llama-index-embeddings-elasticsearch/tests/BUILD", "repo_id": "llama_index", "token_count": 5 }
1,237
python_tests()
llama_index/llama-index-integrations/embeddings/llama-index-embeddings-bedrock/tests/BUILD/0
{ "file_path": "llama_index/llama-index-integrations/embeddings/llama-index-embeddings-bedrock/tests/BUILD", "repo_id": "llama_index", "token_count": 5 }
1,235
"""Callback Handler captures all callbacks in a session for future offline playback.""" from __future__ import annotations import pickle import time from typing import Any, TypedDict from langchain.callbacks.base import BaseCallbackHandler # This is intentionally not an enum so that we avoid serializing a # custom...
streamlit-agent/streamlit_agent/callbacks/capturing_callback_handler.py/0
{ "file_path": "streamlit-agent/streamlit_agent/callbacks/capturing_callback_handler.py", "repo_id": "streamlit-agent", "token_count": 2804 }
1,919
# 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 applicabl...
transformers/src/transformers/generation/__init__.py/0
{ "file_path": "transformers/src/transformers/generation/__init__.py", "repo_id": "transformers", "token_count": 4888 }
607
# OpenAPI Generator Plus generator configuration inputPath: openapi.json outputPath: src/generated generator: "@openapi-generator-plus/typescript-fetch-client-generator" # See https://github.com/karlvr/openapi-generator-plus-generators/tree/master/packages/typescript-fetch-node-client#readme for more configuration opti...
chroma/clients/js/config.yml/0
{ "file_path": "chroma/clients/js/config.yml", "repo_id": "chroma", "token_count": 95 }
29
from llama_index.core.llama_pack import BaseLlamaPack from llama_index.packs.zephyr_query_engine import ZephyrQueryEnginePack def test_class(): names_of_base_classes = [b.__name__ for b in ZephyrQueryEnginePack.__mro__] assert BaseLlamaPack.__name__ in names_of_base_classes
llama_index/llama-index-packs/llama-index-packs-zephyr-query-engine/tests/test_packs_zephyr_query_engine.py/0
{ "file_path": "llama_index/llama-index-packs/llama-index-packs-zephyr-query-engine/tests/test_packs_zephyr_query_engine.py", "repo_id": "llama_index", "token_count": 104 }
1,881
import { expect, test } from "@jest/globals"; import { CallbackManager } from "@langchain/core/callbacks/manager"; import { OpenAIChat } from "../legacy.js"; test("Test OpenAI", async () => { const model = new OpenAIChat({ modelName: "gpt-3.5-turbo", maxTokens: 10 }); const res = await model.call("Print hello worl...
langchainjs/libs/langchain-openai/src/tests/legacy.int.test.ts/0
{ "file_path": "langchainjs/libs/langchain-openai/src/tests/legacy.int.test.ts", "repo_id": "langchainjs", "token_count": 1398 }
1,030
python_sources()
llama_index/llama-index-packs/llama-index-packs-sentence-window-retriever/llama_index/packs/sentence_window_retriever/BUILD/0
{ "file_path": "llama_index/llama-index-packs/llama-index-packs-sentence-window-retriever/llama_index/packs/sentence_window_retriever/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,593
// 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/internal/core/src/index/InvertedIndexTantivy.h/0
{ "file_path": "milvus/internal/core/src/index/InvertedIndexTantivy.h", "repo_id": "milvus", "token_count": 1987 }
1,728
"""Finetuning script for RAG models. Adapted from examples.seq2seq.finetune.py""" import argparse import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Any, Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch import...
transformers/examples/research_projects/rag/finetune_rag.py/0
{ "file_path": "transformers/examples/research_projects/rag/finetune_rag.py", "repo_id": "transformers", "token_count": 11834 }
587
# 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_tf_sam.py/0
{ "file_path": "transformers/src/transformers/models/sam/modeling_tf_sam.py", "repo_id": "transformers", "token_count": 33371 }
717
/* eslint-disable no-process-env */ /* eslint-disable @typescript-eslint/no-non-null-assertion */ import { beforeEach, expect, test } from "@jest/globals"; import type { EmbeddingsInterface } from "@langchain/core/embeddings"; import { SyntheticEmbeddings } from "@langchain/core/utils/testing"; import { InMemoryDocstor...
langchainjs/libs/langchain-community/src/vectorstores/tests/googlevertexai.test.ts/0
{ "file_path": "langchainjs/libs/langchain-community/src/vectorstores/tests/googlevertexai.test.ts", "repo_id": "langchainjs", "token_count": 1150 }
983
python_sources()
llama_index/llama-index-legacy/llama_index/legacy/llama_dataset/BUILD/0
{ "file_path": "llama_index/llama-index-legacy/llama_index/legacy/llama_dataset/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,610
//! [WordPiece](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/37842.pdf) //! model. use crate::models::bpe::BPE; use crate::tokenizer::{Model, Result, Token}; use std::{ borrow::Cow, collections::HashMap, fs::File, io::prelude::*, io::{BufRead, BufReader}, path...
tokenizers/tokenizers/src/models/wordpiece/mod.rs/0
{ "file_path": "tokenizers/tokenizers/src/models/wordpiece/mod.rs", "repo_id": "tokenizers", "token_count": 4422 }
477
python_sources()
llama_index/llama-index-core/llama_index/core/storage/chat_store/BUILD/0
{ "file_path": "llama_index/llama-index-core/llama_index/core/storage/chat_store/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,208
import * as url from "node:url"; import * as path from "node:path"; import { test, expect } from "@jest/globals"; import { Document } from "@langchain/core/documents"; import { JSONLoader } from "../fs/json.js"; test("Test JSON loader", async () => { const filePath = path.resolve( path.dirname(url.fileURLToPath(...
langchainjs/langchain/src/document_loaders/tests/json.test.ts/0
{ "file_path": "langchainjs/langchain/src/document_loaders/tests/json.test.ts", "repo_id": "langchainjs", "token_count": 1189 }
894
import { logVersion010MigrationWarning } from "../../util/entrypoint_deprecation.js"; /* #__PURE__ */ logVersion010MigrationWarning({ oldEntrypointName: "callbacks/handlers/initialize", newEntrypointName: "tracers/initialize", newPackageName: "@langchain/core", }); export * from "@langchain/core/tracers/initiali...
langchainjs/langchain/src/callbacks/handlers/initialize.ts/0
{ "file_path": "langchainjs/langchain/src/callbacks/handlers/initialize.ts", "repo_id": "langchainjs", "token_count": 102 }
848
import tempfile import unittest import numpy as np import torch from diffusers import DiffusionPipeline from diffusers.models.attention_processor import Attention, AttnAddedKVProcessor class AttnAddedKVProcessorTests(unittest.TestCase): def get_constructor_arguments(self, only_cross_attention: bool = False): ...
diffusers/tests/models/test_attention_processor.py/0
{ "file_path": "diffusers/tests/models/test_attention_processor.py", "repo_id": "diffusers", "token_count": 1803 }
272
--- sidebar_class_name: hidden --- import CodeBlock from "@theme/CodeBlock"; import GraphDBExample from "@examples/chains/graph_db_neo4j.ts"; import GraphDBReturnDirectExample from "@examples/chains/graph_db_return_direct.ts"; import GraphDBCustomPromptExample from "@examples/chains/graph_db_custom_prompt.ts"; # Neo4...
langchainjs/docs/core_docs/docs/modules/chains/additional/cypher_chain.mdx/0
{ "file_path": "langchainjs/docs/core_docs/docs/modules/chains/additional/cypher_chain.mdx", "repo_id": "langchainjs", "token_count": 372 }
726
<jupyter_start><jupyter_text>Saving PruneBERTThis notebook aims at showcasing how we can leverage standard tools to save (and load) an extremely sparse model fine-pruned with [movement pruning](https://arxiv.org/abs/2005.07683) (or any other unstructured pruning mehtod).In this example, we used BERT (base-uncased, but ...
transformers/examples/research_projects/movement-pruning/Saving_PruneBERT.ipynb/0
{ "file_path": "transformers/examples/research_projects/movement-pruning/Saving_PruneBERT.ipynb", "repo_id": "transformers", "token_count": 5478 }
607
import re from copy import deepcopy from dataclasses import asdict, dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import torch from numpy import exp, pi, sqrt from torchvision.transforms.functional import resize from tqdm.auto import tqdm from transformers import CLIPFeatu...
diffusers/examples/community/mixture_canvas.py/0
{ "file_path": "diffusers/examples/community/mixture_canvas.py", "repo_id": "diffusers", "token_count": 9662 }
187
# LlamaIndex Llms Integration: Cohere
llama_index/llama-index-integrations/llms/llama-index-llms-cohere/README.md/0
{ "file_path": "llama_index/llama-index-integrations/llms/llama-index-llms-cohere/README.md", "repo_id": "llama_index", "token_count": 11 }
1,221
## Training examples Creating a training image set is [described in a different document](https://huggingface.co/docs/datasets/image_process#image-datasets). ### Installing the dependencies Before running the scripts, make sure to install the library's training dependencies: **Important** To make sure you can succ...
diffusers/examples/research_projects/onnxruntime/unconditional_image_generation/README.md/0
{ "file_path": "diffusers/examples/research_projects/onnxruntime/unconditional_image_generation/README.md", "repo_id": "diffusers", "token_count": 500 }
211
"""Util that calls bibtexparser.""" import logging from typing import Any, Dict, List, Mapping from langchain_core.pydantic_v1 import BaseModel, Extra, root_validator logger = logging.getLogger(__name__) OPTIONAL_FIELDS = [ "annotate", "booktitle", "editor", "howpublished", "journal", "keywor...
langchain/libs/community/langchain_community/utilities/bibtex.py/0
{ "file_path": "langchain/libs/community/langchain_community/utilities/bibtex.py", "repo_id": "langchain", "token_count": 1100 }
314
"""Tree-based index.""" from enum import Enum from typing import Any, Dict, Optional, Sequence, Union from llama_index.core.base.base_retriever import BaseRetriever from llama_index.core.base.embeddings.base import BaseEmbedding # from llama_index.core.data_structs.data_structs import IndexGraph from llama_index.cor...
llama_index/llama-index-core/llama_index/core/indices/tree/base.py/0
{ "file_path": "llama_index/llama-index-core/llama_index/core/indices/tree/base.py", "repo_id": "llama_index", "token_count": 3273 }
1,155
from rag_semi_structured.chain import chain __all__ = ["chain"]
langchain/templates/rag-semi-structured/rag_semi_structured/__init__.py/0
{ "file_path": "langchain/templates/rag-semi-structured/rag_semi_structured/__init__.py", "repo_id": "langchain", "token_count": 22 }
671
"""Slack tool utils.""" from __future__ import annotations import logging import os from typing import TYPE_CHECKING if TYPE_CHECKING: from slack_sdk import WebClient logger = logging.getLogger(__name__) def login() -> WebClient: """Authenticate using the Slack API.""" try: from slack_sdk impor...
langchain/libs/community/langchain_community/tools/slack/utils.py/0
{ "file_path": "langchain/libs/community/langchain_community/tools/slack/utils.py", "repo_id": "langchain", "token_count": 485 }
315
from langchain.agents import AgentExecutor, initialize_agent, load_tools from langchain.llms import OpenAI def get_chain() -> AgentExecutor: """Load the agent executor chain.""" llm = OpenAI(temperature=0) tools = load_tools(["llm-math"], llm) return initialize_agent(tools, llm, "zero-shot-react-descr...
langchain-aiplugin/agent/chain.py/0
{ "file_path": "langchain-aiplugin/agent/chain.py", "repo_id": "langchain-aiplugin", "token_count": 110 }
62
import torch from diffusers import KDPM2DiscreteScheduler from diffusers.utils.testing_utils import torch_device from .test_schedulers import SchedulerCommonTest class KDPM2DiscreteSchedulerTest(SchedulerCommonTest): scheduler_classes = (KDPM2DiscreteScheduler,) num_inference_steps = 10 def get_schedul...
diffusers/tests/schedulers/test_scheduler_kdpm2_discrete.py/0
{ "file_path": "diffusers/tests/schedulers/test_scheduler_kdpm2_discrete.py", "repo_id": "diffusers", "token_count": 2792 }
297
from typing import Union, Sequence class Tensor: """ This contains the type hints for the magic methodes of the `candle.Tensor` class. """ def __add__(self, rhs: Union["Tensor", "Scalar"]) -> "Tensor": """ Add a scalar to a tensor or two tensors together. """ pass ...
candle/candle-pyo3/_additional_typing/__init__.py/0
{ "file_path": "candle/candle-pyo3/_additional_typing/__init__.py", "repo_id": "candle", "token_count": 1174 }
65
kind: StressChaos apiVersion: chaos-mesh.org/v1alpha1 metadata: name: test-etcd-memory-stress namespace: chaos-testing spec: selector: namespaces: - chaos-testing labelSelectors: app.kubernetes.io/instance: milvus-chaos app.kubernetes.io/name: etcd mode: all stressors: cpu: ...
milvus/tests/python_client/chaos/chaos_objects/mem_stress/chaos_etcd_mem_stress.yaml/0
{ "file_path": "milvus/tests/python_client/chaos/chaos_objects/mem_stress/chaos_etcd_mem_stress.yaml", "repo_id": "milvus", "token_count": 181 }
1,893
import pytest from langchain_core.documents import Document from langchain_community.retrievers.bm25 import BM25Retriever @pytest.mark.requires("rank_bm25") def test_from_texts() -> None: input_texts = ["I have a pen.", "Do you have a pen?", "I have a bag."] bm25_retriever = BM25Retriever.from_texts(texts=in...
langchain/libs/community/tests/unit_tests/retrievers/test_bm25.py/0
{ "file_path": "langchain/libs/community/tests/unit_tests/retrievers/test_bm25.py", "repo_id": "langchain", "token_count": 651 }
382
python_sources()
llama_index/llama-index-integrations/tools/llama-index-tools-text-to-image/llama_index/tools/text_to_image/BUILD/0
{ "file_path": "llama_index/llama-index-integrations/tools/llama-index-tools-text-to-image/llama_index/tools/text_to_image/BUILD", "repo_id": "llama_index", "token_count": 6 }
1,634
"""Test OCI Generative AI embedding service.""" from unittest.mock import MagicMock import pytest from pytest import MonkeyPatch from langchain_community.embeddings import OCIGenAIEmbeddings class MockResponseDict(dict): def __getattr__(self, val): # type: ignore[no-untyped-def] return self[val] @pyt...
langchain/libs/community/tests/unit_tests/embeddings/test_oci_gen_ai_embedding.py/0
{ "file_path": "langchain/libs/community/tests/unit_tests/embeddings/test_oci_gen_ai_embedding.py", "repo_id": "langchain", "token_count": 715 }
375
python_sources() python_tests( name="tests", )
llama_index/llama-index-core/tests/indices/empty/BUILD/0
{ "file_path": "llama_index/llama-index-core/tests/indices/empty/BUILD", "repo_id": "llama_index", "token_count": 22 }
1,187
NEXT_PUBLIC_API_URL=http://localhost:8000
auto-evaluator/nextjs/.env.local/0
{ "file_path": "auto-evaluator/nextjs/.env.local", "repo_id": "auto-evaluator", "token_count": 15 }
0
""" Conv2d + BN + Act Hacked together by / Copyright 2020 Ross Wightman """ import functools from torch import nn as nn from .create_conv2d import create_conv2d from .create_norm_act import get_norm_act_layer class ConvNormAct(nn.Module): def __init__( self, in_channels, out_...
pytorch-image-models/timm/layers/conv_bn_act.py/0
{ "file_path": "pytorch-image-models/timm/layers/conv_bn_act.py", "repo_id": "pytorch-image-models", "token_count": 1885 }
343
# ClickHouse > [ClickHouse](https://clickhouse.com/) is the fast and resource efficient open-source database for real-time > apps and analytics with full SQL support and a wide range of functions to assist users in writing analytical queries. > It has data structures and distance search functions (like `L2Distance`)...
langchain/docs/docs/integrations/providers/clickhouse.mdx/0
{ "file_path": "langchain/docs/docs/integrations/providers/clickhouse.mdx", "repo_id": "langchain", "token_count": 231 }
136
import { XMLParser } from "fast-xml-parser"; import type { StructuredToolInterface } from "@langchain/core/tools"; import { AIMessage, BaseMessage, SystemMessage, } from "@langchain/core/messages"; import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs"; import { BaseChatModel, BaseChatMode...
langchainjs/langchain/src/experimental/chat_models/anthropic_functions.ts/0
{ "file_path": "langchainjs/langchain/src/experimental/chat_models/anthropic_functions.ts", "repo_id": "langchainjs", "token_count": 2618 }
958
# SE-ResNeXt **SE ResNeXt** is a variant of a [ResNext](https://www.paperswithcode.com/method/resneXt) that employs [squeeze-and-excitation blocks](https://paperswithcode.com/method/squeeze-and-excitation-block) to enable the network to perform dynamic channel-wise feature recalibration. ## How do I use this model on...
pytorch-image-models/hfdocs/source/models/seresnext.mdx/0
{ "file_path": "pytorch-image-models/hfdocs/source/models/seresnext.mdx", "repo_id": "pytorch-image-models", "token_count": 2753 }
376
# coding=utf-8 # Copyright 2022 Apple Inc. and 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/LICENSE-2...
transformers/src/transformers/models/mobilenet_v2/modeling_mobilenet_v2.py/0
{ "file_path": "transformers/src/transformers/models/mobilenet_v2/modeling_mobilenet_v2.py", "repo_id": "transformers", "token_count": 15255 }
633
from langchain_community.chat_models.volcengine_maas import ( VolcEngineMaasChat, convert_dict_to_message, ) __all__ = ["convert_dict_to_message", "VolcEngineMaasChat"]
langchain/libs/langchain/langchain/chat_models/volcengine_maas.py/0
{ "file_path": "langchain/libs/langchain/langchain/chat_models/volcengine_maas.py", "repo_id": "langchain", "token_count": 68 }
476
"""Init file.""" from llama_index.tools.zapier.base import ( ACTION_URL_TMPL, ZapierToolSpec, ) __all__ = ["ACTION_URL_TMPL", "ZapierToolSpec"]
llama_index/llama-index-integrations/tools/llama-index-tools-zapier/llama_index/tools/zapier/__init__.py/0
{ "file_path": "llama_index/llama-index-integrations/tools/llama-index-tools-zapier/llama_index/tools/zapier/__init__.py", "repo_id": "llama_index", "token_count": 65 }
1,541
from pathlib import Path from typing import Any, List, Union import pytest from langchain_core._api.deprecation import ( LangChainPendingDeprecationWarning, ) from langchain_core.messages import ( AIMessage, BaseMessage, HumanMessage, SystemMessage, get_buffer_string, ) from langchain_core.pro...
langchain/libs/core/tests/unit_tests/prompts/test_chat.py/0
{ "file_path": "langchain/libs/core/tests/unit_tests/prompts/test_chat.py", "repo_id": "langchain", "token_count": 8021 }
406
# coding=utf-8 # Copyright 2019 The Google AI Language Team Authors and 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/LICEN...
transformers/src/transformers/models/electra/modeling_tf_electra.py/0
{ "file_path": "transformers/src/transformers/models/electra/modeling_tf_electra.py", "repo_id": "transformers", "token_count": 33552 }
640
from langchain_core.prompt_values import StringPromptValue from langchain_core.prompts import ( BasePromptTemplate, StringPromptTemplate, check_valid_template, get_template_variables, jinja2_formatter, validate_jinja2, ) from langchain_core.prompts.string import _get_jinja2_variables_from_templa...
langchain/libs/langchain/langchain/prompts/base.py/0
{ "file_path": "langchain/libs/langchain/langchain/prompts/base.py", "repo_id": "langchain", "token_count": 221 }
526
from langchain.schema.runnable.configurable import __all__ EXPECTED_ALL = [ "DynamicRunnable", "RunnableConfigurableAlternatives", "RunnableConfigurableFields", "StrEnum", "make_options_spec", ] def test_all_imports() -> None: assert set(__all__) == set(EXPECTED_ALL)
langchain/libs/langchain/tests/unit_tests/schema/runnable/test_configurable.py/0
{ "file_path": "langchain/libs/langchain/tests/unit_tests/schema/runnable/test_configurable.py", "repo_id": "langchain", "token_count": 118 }
670
import { logVersion010MigrationWarning } from "../util/entrypoint_deprecation.js"; /* #__PURE__ */ logVersion010MigrationWarning({ oldEntrypointName: "vectorstores/clickhouse", }); export * from "@langchain/community/vectorstores/clickhouse";
langchainjs/langchain/src/vectorstores/clickhouse.ts/0
{ "file_path": "langchainjs/langchain/src/vectorstores/clickhouse.ts", "repo_id": "langchainjs", "token_count": 72 }
963
// 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/tests/integration/rangesearch/range_search_test.go/0
{ "file_path": "milvus/tests/integration/rangesearch/range_search_test.go", "repo_id": "milvus", "token_count": 3990 }
1,888
// 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/core/src/config/ConfigKnowhere.cpp/0
{ "file_path": "milvus/internal/core/src/config/ConfigKnowhere.cpp", "repo_id": "milvus", "token_count": 1567 }
1,734
from typing import Any, Dict, Iterator, List, Optional from langchain_core.callbacks import ( CallbackManagerForLLMRun, ) from langchain_core.language_models.chat_models import BaseChatModel from langchain_core.messages import AIMessage, AIMessageChunk, BaseMessage from langchain_core.outputs import ChatGeneration...
langchain/libs/community/langchain_community/chat_models/bedrock.py/0
{ "file_path": "langchain/libs/community/langchain_community/chat_models/bedrock.py", "repo_id": "langchain", "token_count": 1934 }
223
export * from "./llms.js"; export * from "./chat_models.js"; export * from "./embeddings.js"; export * from "./types.js"; export * from "./utils/openai-format-fndef.js";
langchainjs/libs/langchain-azure-openai/src/index.ts/0
{ "file_path": "langchainjs/libs/langchain-azure-openai/src/index.ts", "repo_id": "langchainjs", "token_count": 64 }
930
# LlamaIndex Postprocessor Integration: Presidio
llama_index/llama-index-integrations/postprocessor/llama-index-postprocessor-presidio/README.md/0
{ "file_path": "llama_index/llama-index-integrations/postprocessor/llama-index-postprocessor-presidio/README.md", "repo_id": "llama_index", "token_count": 12 }
1,297
# Copyright 2020 The HuggingFace Datasets 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 ...
datasets/metrics/bleu/bleu.py/0
{ "file_path": "datasets/metrics/bleu/bleu.py", "repo_id": "datasets", "token_count": 2140 }
126
interactions: - request: body: '{"input": [[831, 677, 31172, 272, 762, 14087, 68, 17, 64, 25350, 1774, 1897, 51542, 9081, 19272, 1135, 65, 1774, 67, 6069, 712, 2689], [2059, 7341, 527, 264, 1912, 315, 658, 10753, 677, 81, 3581, 7795, 32971, 555, 264, 7558, 321, 351, 61798, 30535, 11, 4330, 311, 82...
langchain/libs/community/tests/integration_tests/vectorstores/cassettes/test_pinecone/TestPinecone.test_from_texts_with_metadatas.yaml/0
{ "file_path": "langchain/libs/community/tests/integration_tests/vectorstores/cassettes/test_pinecone/TestPinecone.test_from_texts_with_metadatas.yaml", "repo_id": "langchain", "token_count": 24616 }
351
import sys from transformers import AutoTokenizer dataset = sys.argv[1] model_name_or_path = sys.argv[2] max_len = int(sys.argv[3]) subword_len_counter = 0 tokenizer = AutoTokenizer.from_pretrained(model_name_or_path) max_len -= tokenizer.num_special_tokens_to_add() with open(dataset, "rt") as f_p: for line i...
transformers/examples/legacy/token-classification/scripts/preprocess.py/0
{ "file_path": "transformers/examples/legacy/token-classification/scripts/preprocess.py", "repo_id": "transformers", "token_count": 452 }
548
import { ChatGoogleGenerativeAI } from "@langchain/google-genai"; import { HarmBlockThreshold, HarmCategory } from "@google/generative-ai"; /* * Before running this, you should make sure you have created a * Google Cloud Project that has `generativelanguage` API enabled. * * You will also need to generate an API k...
langchainjs/examples/src/models/chat/googlegenerativeai.ts/0
{ "file_path": "langchainjs/examples/src/models/chat/googlegenerativeai.ts", "repo_id": "langchainjs", "token_count": 647 }
864
import { z } from "zod"; import { OutputParserException } from "@langchain/core/output_parsers"; import { JsonMarkdownStructuredOutputParser } from "./structured.js"; /** * Defines the input parameters for the RouterOutputParser class. It can * include a default destination and an interpolation depth. */ export typ...
langchainjs/langchain/src/output_parsers/router.ts/0
{ "file_path": "langchainjs/langchain/src/output_parsers/router.ts", "repo_id": "langchainjs", "token_count": 595 }
1,004
from pathlib import Path from typing import List HERE = Path(__file__).parent # PUBLIC API def get_sample_paths() -> List[Path]: """List all fixtures.""" return list(HERE.glob("sample.*"))
opengpts/backend/tests/unit_tests/fixtures/__init__.py/0
{ "file_path": "opengpts/backend/tests/unit_tests/fixtures/__init__.py", "repo_id": "opengpts", "token_count": 69 }
2,056
""" Pytorch Inception-Resnet-V2 implementation Sourced from https://github.com/Cadene/tensorflow-model-zoo.torch (MIT License) which is based upon Google's Tensorflow implementation and pretrained weights (Apache 2.0 License) """ from functools import partial import torch import torch.nn as nn import torch.nn.functiona...
pytorch-image-models/timm/models/inception_resnet_v2.py/0
{ "file_path": "pytorch-image-models/timm/models/inception_resnet_v2.py", "repo_id": "pytorch-image-models", "token_count": 6015 }
403
from langchain_community.document_loaders.odt import UnstructuredODTLoader __all__ = ["UnstructuredODTLoader"]
langchain/libs/langchain/langchain/document_loaders/odt.py/0
{ "file_path": "langchain/libs/langchain/langchain/document_loaders/odt.py", "repo_id": "langchain", "token_count": 35 }
510
import { readFileSync, writeFileSync } from 'fs'; import process from 'process'; const packageJson = JSON.parse(readFileSync('package.json')); let newVersion; if (process.argv.length > 2) { newVersion = process.argv[2]; } else { const versionParts = packageJson.version.split('.'); versionParts[2] = parseIn...
langsmith-sdk/js/scripts/bump-version.js/0
{ "file_path": "langsmith-sdk/js/scripts/bump-version.js", "repo_id": "langsmith-sdk", "token_count": 282 }
1,075
python_requirements( name="reqs", ) python_sources()
llama_index/llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/whole_site/BUILD/0
{ "file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-web/llama_index/readers/web/whole_site/BUILD", "repo_id": "llama_index", "token_count": 24 }
1,435
[tool.ruff] # Never enforce `E501` (line length violations). ignore = ["C901", "E501", "E741", "F402", "F823"] select = ["C", "E", "F", "I", "W"] line-length = 119 # Ignore import violations in all `__init__.py` files. [tool.ruff.per-file-ignores] "__init__.py" = ["E402", "F401", "F403", "F811"] "src/diffusers/utils/d...
diffusers/pyproject.toml/0
{ "file_path": "diffusers/pyproject.toml", "repo_id": "diffusers", "token_count": 270 }
228
"""Custom query engine.""" from abc import abstractmethod from typing import Union from llama_index.core.base.base_query_engine import BaseQueryEngine from llama_index.core.base.response.schema import RESPONSE_TYPE, Response from llama_index.core.bridge.pydantic import BaseModel, Field from llama_index.core.callbacks...
llama_index/llama-index-core/llama_index/core/query_engine/custom.py/0
{ "file_path": "llama_index/llama-index-core/llama_index/core/query_engine/custom.py", "repo_id": "llama_index", "token_count": 1189 }
1,142
{ "details": { "best_of_sequences": null, "finish_reason": "eos_token", "generated_tokens": 30, "prefill": [ { "id": 1, "logprob": null, "text": "<s>" }, { "id": 5235, "logprob": -10.0625, "text": "info" }, { "id": 2...
text-generation-inference/integration-tests/models/__snapshots__/test_grammar_llama/test_flash_llama_grammar_json.json/0
{ "file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_grammar_llama/test_flash_llama_grammar_json.json", "repo_id": "text-generation-inference", "token_count": 3401 }
408
<jupyter_start><jupyter_text>RAG Evaluation using Fixed Sources[](https://colab.research.google.com/github/langchain-ai/langsmith-cookbook/blob/main/testing-examples/using-fixed-sources/using_fixed_sources.ipynb)A simple RAG pipeline requries at least two components: a retriever and a response generator. You can evalua...
langsmith-cookbook/testing-examples/using-fixed-sources/using_fixed_sources.ipynb/0
{ "file_path": "langsmith-cookbook/testing-examples/using-fixed-sources/using_fixed_sources.ipynb", "repo_id": "langsmith-cookbook", "token_count": 2093 }
1,063
import { logVersion010MigrationWarning } from "../../util/entrypoint_deprecation.js"; /* #__PURE__ */ logVersion010MigrationWarning({ oldEntrypointName: "stores/message/firestore", }); export * from "@langchain/community/stores/message/firestore";
langchainjs/langchain/src/stores/message/firestore.ts/0
{ "file_path": "langchainjs/langchain/src/stores/message/firestore.ts", "repo_id": "langchainjs", "token_count": 75 }
1,019
import { ChangeEvent } from "react"; import { withJsonFormsControlProps } from "@jsonforms/react"; import { rankWith, and, schemaMatches, isControl } from "@jsonforms/core"; import { isJsonSchemaExtra } from "../utils/schema"; export const fileBase64Tester = rankWith( 12, and( isControl, schemaMatches((sch...
langserve/langserve/playground/src/components/FileBase64Tester.tsx/0
{ "file_path": "langserve/langserve/playground/src/components/FileBase64Tester.tsx", "repo_id": "langserve", "token_count": 473 }
1,063
# GPT Repository Loader This loader is an adaptation of https://github.com/mpoon/gpt-repository-loader to LlamaHub. Full credit goes to mpoon for coming up with this! ## Usage To use this loader, you need to pass in a path to a local Git repository ```python from llama_index import download_loader GPTRepoReader = ...
llama_index/llama-index-integrations/readers/llama-index-readers-gpt-repo/README.md/0
{ "file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-gpt-repo/README.md", "repo_id": "llama_index", "token_count": 273 }
1,502
import { logVersion010MigrationWarning } from "../util/entrypoint_deprecation.js"; /* #__PURE__ */ logVersion010MigrationWarning({ oldEntrypointName: "chat_models/googlepalm", }); export * from "@langchain/community/chat_models/googlepalm";
langchainjs/langchain/src/chat_models/googlepalm.ts/0
{ "file_path": "langchainjs/langchain/src/chat_models/googlepalm.ts", "repo_id": "langchainjs", "token_count": 76 }
888
// 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 appli...
milvus/pkg/util/hardware/mem_info.go/0
{ "file_path": "milvus/pkg/util/hardware/mem_info.go", "repo_id": "milvus", "token_count": 472 }
1,935
import logging from typing import Optional from llama_index.legacy.callbacks.base import CallbackManager from llama_index.legacy.core.base_query_engine import BaseQueryEngine from llama_index.legacy.core.response.schema import RESPONSE_TYPE, Response from llama_index.legacy.evaluation import BaseEvaluator from llama_i...
llama_index/llama-index-legacy/llama_index/legacy/query_engine/retry_source_query_engine.py/0
{ "file_path": "llama_index/llama-index-legacy/llama_index/legacy/query_engine/retry_source_query_engine.py", "repo_id": "llama_index", "token_count": 1534 }
1,698
"""Test functionality related to prompts.""" from unittest import mock import pytest from langchain_core.prompts.prompt import PromptTemplate from langchain_core.tracers.run_collector import RunCollectorCallbackHandler def test_prompt_valid() -> None: """Test prompts can be constructed.""" template = "This...
langchain/libs/core/tests/unit_tests/prompts/test_prompt.py/0
{ "file_path": "langchain/libs/core/tests/unit_tests/prompts/test_prompt.py", "repo_id": "langchain", "token_count": 4131 }
418
"""Test ChatYuan2 wrapper.""" import pytest from langchain_core.messages import ( AIMessage, HumanMessage, SystemMessage, ) from langchain_community.chat_models.yuan2 import ( ChatYuan2, _convert_dict_to_message, _convert_message_to_dict, ) @pytest.mark.requires("openai") def test_yuan2_mode...
langchain/libs/community/tests/unit_tests/chat_models/test_yuan2.py/0
{ "file_path": "langchain/libs/community/tests/unit_tests/chat_models/test_yuan2.py", "repo_id": "langchain", "token_count": 678 }
365
package dbcore import ( "context" "fmt" "reflect" "github.com/chroma/chroma-coordinator/internal/common" "github.com/chroma/chroma-coordinator/internal/metastore/db/dbmodel" "github.com/chroma/chroma-coordinator/internal/types" "github.com/pingcap/log" "go.uber.org/zap" "gorm.io/driver/postgres" "gorm.io/dr...
chroma/go/coordinator/internal/metastore/db/dbcore/core.go/0
{ "file_path": "chroma/go/coordinator/internal/metastore/db/dbcore/core.go", "repo_id": "chroma", "token_count": 1521 }
50
# Gmail OpenAI Agent Pack Create an OpenAI agent pre-loaded with a tool to interact with Gmail. The tool used is the [Gmail LlamaHub tool](https://llamahub.ai/l/tools-gmail). ## CLI Usage You can download llamapacks directly using `llamaindex-cli`, which comes installed with the `llama-index` python package: ```bas...
llama_index/llama-index-packs/llama-index-packs-gmail-openai-agent/README.md/0
{ "file_path": "llama_index/llama-index-packs/llama-index-packs-gmail-openai-agent/README.md", "repo_id": "llama_index", "token_count": 444 }
1,584
package proxy import ( "context" "fmt" "math" "sort" "strconv" "github.com/cockroachdb/errors" "go.opentelemetry.io/otel" "go.uber.org/zap" "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb" "github.com/milvus-io/milvus-proto/go-api/v2/schemapb" ...
milvus/internal/proxy/task_hybrid_search.go/0
{ "file_path": "milvus/internal/proxy/task_hybrid_search.go", "repo_id": "milvus", "token_count": 7564 }
1,967
import { BaseOutputParser, OutputParserException, } from "@langchain/core/output_parsers"; import type { SerializedFields } from "../load/map_keys.js"; export interface RegExpFields { pattern: string; flags?: string; } /** * Interface for the fields required to create a RegexParser instance. */ export inter...
langchainjs/langchain/src/output_parsers/regex.ts/0
{ "file_path": "langchainjs/langchain/src/output_parsers/regex.ts", "repo_id": "langchainjs", "token_count": 1221 }
898