text stringlengths 3 1.68M | id stringlengths 13 169 | metadata dict | __index_level_0__ int64 0 2.21k |
|---|---|---|---|
import pytest
from langchain_core.messages import (
AIMessage,
FunctionMessage,
HumanMessage,
SystemMessage,
)
from langchain_community.chat_models.ernie import _convert_message_to_dict
def test__convert_dict_to_message_human() -> None:
message = HumanMessage(content="foo")
result = _convert_... | langchain/libs/community/tests/unit_tests/chat_models/test_ernie.py/0 | {
"file_path": "langchain/libs/community/tests/unit_tests/chat_models/test_ernie.py",
"repo_id": "langchain",
"token_count": 404
} | 383 |
/*
The MIT License
Copyright (c) 2017-2019 EclipseSource Munich
https://github.com/eclipsesource/jsonforms
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, includi... | langserve/langserve/playground/src/components/CustomArrayControlRenderer/TableToolbar.tsx/0 | {
"file_path": "langserve/langserve/playground/src/components/CustomArrayControlRenderer/TableToolbar.tsx",
"repo_id": "langserve",
"token_count": 1178
} | 1,001 |
"""API to deal with file uploads via a runnable.
For now this code assumes that the content is a base64 encoded string.
The details here might change in the future.
For the time being, upload and ingestion are coupled
"""
from __future__ import annotations
import os
from typing import Any, BinaryIO, List, Optional
... | opengpts/backend/app/upload.py/0 | {
"file_path": "opengpts/backend/app/upload.py",
"repo_id": "opengpts",
"token_count": 1468
} | 1,920 |
from rag_gpt_crawler.chain import chain
__all__ = ["chain"]
| langchain/templates/rag-gpt-crawler/rag_gpt_crawler/__init__.py/0 | {
"file_path": "langchain/templates/rag-gpt-crawler/rag_gpt_crawler/__init__.py",
"repo_id": "langchain",
"token_count": 22
} | 699 |
# LlamaIndex Index_Store Integration: Mongo Index Store
| llama_index/llama-index-integrations/storage/index_store/llama-index-storage-index-store-mongodb/README.md/0 | {
"file_path": "llama_index/llama-index-integrations/storage/index_store/llama-index-storage-index-store-mongodb/README.md",
"repo_id": "llama_index",
"token_count": 13
} | 1,418 |
python_sources()
| llama_index/llama-index-integrations/readers/llama-index-readers-memos/llama_index/readers/memos/BUILD/0 | {
"file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-memos/llama_index/readers/memos/BUILD",
"repo_id": "llama_index",
"token_count": 6
} | 1,405 |
import { Tool } from "@langchain/core/tools";
/**
* The DadJokeAPI class is a tool for generating dad jokes based on a
* specific topic. It fetches jokes from an external API and returns a
* random joke from the results. If no jokes are found for the given
* search term, it returns a message indicating that no jok... | langchainjs/libs/langchain-community/src/tools/dadjokeapi.ts/0 | {
"file_path": "langchainjs/libs/langchain-community/src/tools/dadjokeapi.ts",
"repo_id": "langchainjs",
"token_count": 396
} | 995 |
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"declaration": false
},
"exclude": [
"node_modules",
"dist",
"docs",
"**/tests"
]
} | langchainjs/langchain-core/tsconfig.cjs.json/0 | {
"file_path": "langchainjs/langchain-core/tsconfig.cjs.json",
"repo_id": "langchainjs",
"token_count": 89
} | 939 |
from langchain_community.llms.replicate import Replicate
__all__ = ["Replicate"]
| langchain/libs/langchain/langchain/llms/replicate.py/0 | {
"file_path": "langchain/libs/langchain/langchain/llms/replicate.py",
"repo_id": "langchain",
"token_count": 25
} | 517 |
package proxy
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
)
func TestRescorer(t *testing.T) {
t.Run("default scorer", func(t *testing.T) {
rescorers, err := NewReScorer([... | milvus/internal/proxy/reScorer_test.go/0 | {
"file_path": "milvus/internal/proxy/reScorer_test.go",
"repo_id": "milvus",
"token_count": 1630
} | 1,884 |
<jupyter_start><jupyter_code>import openai
openai.api_key = "sk-your-key"
from llama_index.agent import OpenAIAgent
# Import and initialize our tool spec
from llama_index.tools.wolfram_alpha.base import WolframAlphaToolSpec
wolfram_spec = WolframAlphaToolSpec(app_id="your-key")
tools = wolfram_spec.to_tool_list()
# C... | llama_index/llama-index-integrations/tools/llama-index-tools-wolfram-alpha/examples/wolfram_alpha.ipynb/0 | {
"file_path": "llama_index/llama-index-integrations/tools/llama-index-tools-wolfram-alpha/examples/wolfram_alpha.ipynb",
"repo_id": "llama_index",
"token_count": 243
} | 1,465 |
# 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/LICENSE-2.0
#
# Unless r... | diffusers/examples/kandinsky2_2/text_to_image/train_text_to_image_lora_prior.py/0 | {
"file_path": "diffusers/examples/kandinsky2_2/text_to_image/train_text_to_image_lora_prior.py",
"repo_id": "diffusers",
"token_count": 15573
} | 211 |
/**
* Get UCS-2 length of a string
* https://mathiasbynens.be/notes/javascript-encoding
* https://github.com/bestiejs/punycode.js - punycode.ucs2.decode
*/
export function ucs2length(s: string) {
let result = 0;
let length = s.length;
let index = 0;
let charCode: number;
while (index < length) {
resul... | langchainjs/langchain-core/src/utils/@cfworker/json-schema/src/ucs2-length.ts/0 | {
"file_path": "langchainjs/langchain-core/src/utils/@cfworker/json-schema/src/ucs2-length.ts",
"repo_id": "langchainjs",
"token_count": 259
} | 907 |
---
sidebar_position: 3
sidebar_class_name: hidden
---
# [Beta] Memory
Many LLM applications have a conversational interface. An essential component of a conversation is being able
to refer to information introduced earlier in the conversation. At bare minimum, a conversational system
should be able to access some wi... | langchainjs/docs/core_docs/docs/modules/memory/index.mdx/0 | {
"file_path": "langchainjs/docs/core_docs/docs/modules/memory/index.mdx",
"repo_id": "langchainjs",
"token_count": 2638
} | 760 |
python_tests()
| llama_index/llama-index-integrations/readers/llama-index-readers-airbyte-zendesk-support/tests/BUILD/0 | {
"file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-airbyte-zendesk-support/tests/BUILD",
"repo_id": "llama_index",
"token_count": 5
} | 1,286 |
[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 = ["OllamaMultiModal"]
contains_example = false
import_path = "llama_index.multi_modal_llms.o... | llama_index/llama-index-integrations/multi_modal_llms/llama-index-multi-modal-llms-ollama/pyproject.toml/0 | {
"file_path": "llama_index/llama-index-integrations/multi_modal_llms/llama-index-multi-modal-llms-ollama/pyproject.toml",
"repo_id": "llama_index",
"token_count": 662
} | 1,289 |
# Johnsnowlabs
Gain access to the [johnsnowlabs](https://www.johnsnowlabs.com/) ecosystem of enterprise NLP libraries
with over 21.000 enterprise NLP models in over 200 languages with the open source `johnsnowlabs` library.
For all 24.000+ models, see the [John Snow Labs Model Models Hub](https://nlp.johnsnowlabs.com/... | langchain/docs/docs/integrations/providers/johnsnowlabs.mdx/0 | {
"file_path": "langchain/docs/docs/integrations/providers/johnsnowlabs.mdx",
"repo_id": "langchain",
"token_count": 890
} | 136 |
import { expect, test } from "@jest/globals";
import { PromptTemplate } from "../prompt.js";
test("Test using partial", async () => {
const prompt = new PromptTemplate({
template: "{foo}{bar}",
inputVariables: ["foo"],
partialVariables: { bar: "baz" },
});
expect(await prompt.format({ foo: "foo" })).... | langchainjs/langchain-core/src/prompts/tests/prompt.test.ts/0 | {
"file_path": "langchainjs/langchain-core/src/prompts/tests/prompt.test.ts",
"repo_id": "langchainjs",
"token_count": 1054
} | 930 |
// 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/rootcoord/rename_collection_task_test.go/0 | {
"file_path": "milvus/internal/rootcoord/rename_collection_task_test.go",
"repo_id": "milvus",
"token_count": 964
} | 2,004 |
// 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/querycoordv2/checkers/controller_test.go/0 | {
"file_path": "milvus/internal/querycoordv2/checkers/controller_test.go",
"repo_id": "milvus",
"token_count": 2225
} | 1,858 |
python_sources()
| llama_index/llama-index-core/llama_index/core/llama_dataset/BUILD/0 | {
"file_path": "llama_index/llama-index-core/llama_index/core/llama_dataset/BUILD",
"repo_id": "llama_index",
"token_count": 6
} | 1,273 |
from __future__ import annotations
from typing import List, Optional
from langchain_experimental.tot.thought import Thought
class ToTDFSMemory:
"""
Memory for the Tree of Thought (ToT) chain. Implemented as a stack of
thoughts. This allows for a depth first search (DFS) of the ToT.
"""
def __in... | langchain/libs/experimental/langchain_experimental/tot/memory.py/0 | {
"file_path": "langchain/libs/experimental/langchain_experimental/tot/memory.py",
"repo_id": "langchain",
"token_count": 576
} | 425 |
<jupyter_start><jupyter_text>AWS Lambda >[`Amazon AWS Lambda`](https://aws.amazon.com/pm/lambda/) is a serverless computing service provided by `Amazon Web Services` (`AWS`). It helps developers to build and run applications and services without provisioning or managing servers. This serverless architecture enables you... | langchain/docs/docs/integrations/tools/awslambda.ipynb/0 | {
"file_path": "langchain/docs/docs/integrations/tools/awslambda.ipynb",
"repo_id": "langchain",
"token_count": 556
} | 184 |
from typing import Sequence, TypedDict
from langchain_core.messages import BaseMessage
class ChatSession(TypedDict, total=False):
"""Chat Session represents a single
conversation, channel, or other group of messages."""
messages: Sequence[BaseMessage]
"""The LangChain chat messages loaded from the s... | langchain/libs/core/langchain_core/chat_sessions.py/0 | {
"file_path": "langchain/libs/core/langchain_core/chat_sessions.py",
"repo_id": "langchain",
"token_count": 114
} | 421 |
# 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... | transformers/utils/split_model_tests.py/0 | {
"file_path": "transformers/utils/split_model_tests.py",
"repo_id": "transformers",
"token_count": 759
} | 773 |
export * from "@langchain/core/example_selectors";
| langchainjs/langchain/src/prompts/selectors/SemanticSimilarityExampleSelector.ts/0 | {
"file_path": "langchainjs/langchain/src/prompts/selectors/SemanticSimilarityExampleSelector.ts",
"repo_id": "langchainjs",
"token_count": 15
} | 926 |
/* eslint-disable @typescript-eslint/no-explicit-any */
import { jest, test, expect } from "@jest/globals";
import { SearchIndexingBufferedSender } from "@azure/search-documents";
import { FakeEmbeddings } from "@langchain/core/utils/testing";
import {
AzureAISearchQueryType,
AzureAISearchVectorStore,
} from "../az... | langchainjs/libs/langchain-community/src/vectorstores/tests/azure_aisearch.test.ts/0 | {
"file_path": "langchainjs/libs/langchain-community/src/vectorstores/tests/azure_aisearch.test.ts",
"repo_id": "langchainjs",
"token_count": 1933
} | 1,005 |
import { loadEvaluator } from "langchain/evaluation";
import { ChatAnthropic } from "@langchain/anthropic";
const model = new ChatAnthropic({ temperature: 0 });
const chain = await loadEvaluator("labeled_pairwise_string", { llm: model });
const res = await chain.evaluateStringPairs({
prediction: "there are three d... | langchainjs/examples/src/guides/evaluation/comparision_evaluator/pairwise_string_custom_llm.ts/0 | {
"file_path": "langchainjs/examples/src/guides/evaluation/comparision_evaluator/pairwise_string_custom_llm.ts",
"repo_id": "langchainjs",
"token_count": 280
} | 863 |
poetry_requirements(
name="poetry",
)
| llama_index/llama-index-integrations/readers/llama-index-readers-stackoverflow/BUILD/0 | {
"file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-stackoverflow/BUILD",
"repo_id": "llama_index",
"token_count": 18
} | 1,435 |
<!--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 applicable law or agreed... | diffusers/docs/source/ko/using-diffusers/img2img.md/0 | {
"file_path": "diffusers/docs/source/ko/using-diffusers/img2img.md",
"repo_id": "diffusers",
"token_count": 2084
} | 199 |
# LlamaIndex Embeddings Integration: Langchain
| llama_index/llama-index-integrations/embeddings/llama-index-embeddings-langchain/README.md/0 | {
"file_path": "llama_index/llama-index-integrations/embeddings/llama-index-embeddings-langchain/README.md",
"repo_id": "llama_index",
"token_count": 12
} | 1,266 |
from __future__ import annotations
from typing import Any, Callable, Mapping, Optional, Sequence, Union
from langchain_core.pydantic_v1 import Field
from langchain_core.runnables import (
Runnable,
RunnableConfig,
RunnableLambda,
RunnablePassthrough,
RunnableSerializable,
)
from langchain_core.run... | langgraph/langgraph/pregel/read.py/0 | {
"file_path": "langgraph/langgraph/pregel/read.py",
"repo_id": "langgraph",
"token_count": 3343
} | 1,055 |
- sections:
- local: index
title: 🤗 Transformers
- local: quicktour
title: 둘러보기
- local: installation
title: 설치방법
title: 시작하기
- sections:
- local: pipeline_tutorial
title: Pipeline으로 추론하기
- local: autoclass_tutorial
title: AutoClass로 사전 학습된 인스턴스 로드하기
- local: preprocessing
title: ... | transformers/docs/source/ko/_toctree.yml/0 | {
"file_path": "transformers/docs/source/ko/_toctree.yml",
"repo_id": "transformers",
"token_count": 12618
} | 524 |
from typing import Any, Dict, List, Mapping, Optional
import requests
from langchain_core.embeddings import Embeddings
from langchain_core.pydantic_v1 import BaseModel, Extra, root_validator
from langchain_core.utils import get_from_dict_or_env
DEFAULT_MODEL_ID = "sentence-transformers/clip-ViT-B-32"
class DeepInfr... | langchain/libs/community/langchain_community/embeddings/deepinfra.py/0 | {
"file_path": "langchain/libs/community/langchain_community/embeddings/deepinfra.py",
"repo_id": "langchain",
"token_count": 1927
} | 255 |
---
sidebar_class_name: hidden
---
# Retrieval QA
This example showcases question answering over an index.
import RetrievalQAExample from "@examples/chains/retrieval_qa_legacy.ts";
import RetrievalQAExampleCustom from "@examples/chains/retrieval_qa_custom_legacy.ts";
import RetrievalQAExampleCustomPrompt from "@exam... | langchainjs/docs/core_docs/docs/modules/chains/popular/vector_db_qa_legacy.mdx/0 | {
"file_path": "langchainjs/docs/core_docs/docs/modules/chains/popular/vector_db_qa_legacy.mdx",
"repo_id": "langchainjs",
"token_count": 552
} | 729 |
import streamlit as st
from langchain.callbacks.base import BaseCallbackHandler
from langchain.chains import RetrievalQAWithSourcesChain
from langchain.retrievers.web_research import WebResearchRetriever
import os
os.environ["GOOGLE_API_KEY"] = "YOUR_API_KEY" # Get it at https://console.cloud.google.com/apis/api/cust... | web-explorer/web_explorer.py/0 | {
"file_path": "web-explorer/web_explorer.py",
"repo_id": "web-explorer",
"token_count": 1375
} | 2,209 |
from langchain_community.callbacks.tracers.wandb import (
PRINT_WARNINGS,
RunProcessor,
WandbRunArgs,
WandbTracer,
)
__all__ = [
"PRINT_WARNINGS",
"RunProcessor",
"WandbRunArgs",
"WandbTracer",
]
| langchain/libs/langchain/langchain/callbacks/tracers/wandb.py/0 | {
"file_path": "langchain/libs/langchain/langchain/callbacks/tracers/wandb.py",
"repo_id": "langchain",
"token_count": 107
} | 453 |
<jupyter_start><jupyter_text>Docusaurus> [Docusaurus](https://docusaurus.io/) is a static-site generator which provides out-of-the-box documentation features.By utilizing the existing `SitemapLoader`, this loader scans and loads all pages from a given Docusaurus application and returns the main documentation content of... | langchain/docs/docs/integrations/document_loaders/docusaurus.ipynb/0 | {
"file_path": "langchain/docs/docs/integrations/document_loaders/docusaurus.ipynb",
"repo_id": "langchain",
"token_count": 1062
} | 100 |
version: "3"
services:
redis:
container_name: redis-stack
image: redis/redis-stack:latest
ports:
- 6379:6379
| langchainjs/examples/src/indexes/vector_stores/redis/docker-compose.yml/0 | {
"file_path": "langchainjs/examples/src/indexes/vector_stores/redis/docker-compose.yml",
"repo_id": "langchainjs",
"token_count": 59
} | 789 |
"""SingleStore reader."""
from typing import List
from llama_index.core.readers.base import BaseReader
from llama_index.core.schema import Document
from llama_index.readers.database import DatabaseReader
class SingleStoreReader(BaseReader):
"""SingleStore reader.
Args:
scheme (str): Database Scheme... | llama_index/llama-index-integrations/readers/llama-index-readers-singlestore/llama_index/readers/singlestore/base.py/0 | {
"file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-singlestore/llama_index/readers/singlestore/base.py",
"repo_id": "llama_index",
"token_count": 1036
} | 1,522 |
import { MultiPromptChain } from "langchain/chains";
import { OpenAIChat } from "@langchain/openai";
const llm = new OpenAIChat();
const promptNames = ["physics", "math", "history"];
const promptDescriptions = [
"Good for answering questions about physics",
"Good for answering math questions",
"Good for answerin... | langchainjs/examples/src/chains/multi_prompt.ts/0 | {
"file_path": "langchainjs/examples/src/chains/multi_prompt.ts",
"repo_id": "langchainjs",
"token_count": 506
} | 847 |
# 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/dinov2/convert_dinov2_to_hf.py/0 | {
"file_path": "transformers/src/transformers/models/dinov2/convert_dinov2_to_hf.py",
"repo_id": "transformers",
"token_count": 5255
} | 677 |
"""List-based data structures."""
from llama_index.legacy.indices.list.base import GPTListIndex, ListIndex, SummaryIndex
from llama_index.legacy.indices.list.retrievers import (
ListIndexEmbeddingRetriever,
ListIndexLLMRetriever,
ListIndexRetriever,
SummaryIndexEmbeddingRetriever,
SummaryIndexLLMRe... | llama_index/llama-index-legacy/llama_index/legacy/indices/list/__init__.py/0 | {
"file_path": "llama_index/llama-index-legacy/llama_index/legacy/indices/list/__init__.py",
"repo_id": "llama_index",
"token_count": 246
} | 1,662 |
import { writable } from "svelte/store";
export interface TitleUpdate {
convId: string;
title: string;
}
export default writable<TitleUpdate | null>(null);
| chat-ui/src/lib/stores/titleUpdate.ts/0 | {
"file_path": "chat-ui/src/lib/stores/titleUpdate.ts",
"repo_id": "chat-ui",
"token_count": 50
} | 94 |
poetry_requirements(
name="poetry",
)
| llama_index/llama-index-integrations/readers/llama-index-readers-mbox/BUILD/0 | {
"file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-mbox/BUILD",
"repo_id": "llama_index",
"token_count": 18
} | 1,381 |
"""Test PaLM."""
import sys
from typing import Any
from unittest.mock import MagicMock
import pytest
def _mock_palm_completion(model_name: str, prompt: str, **kwargs: Any) -> str:
"""Mock PaLM completion."""
completion = MagicMock()
completion.result = prompt
completion.candidates = [{"prompt": prom... | llama_index/llama-index-legacy/tests/llms/test_palm.py/0 | {
"file_path": "llama_index/llama-index-legacy/tests/llms/test_palm.py",
"repo_id": "llama_index",
"token_count": 511
} | 1,560 |
# Advantage Actor-Critic (A2C) [[advantage-actor-critic]]
## Reducing variance with Actor-Critic methods
The solution to reducing the variance of the Reinforce algorithm and training our agent faster and better is to use a combination of Policy-Based and Value-Based methods: *the Actor-Critic method*.
To understand ... | deep-rl-class/units/en/unit6/advantage-actor-critic.mdx/0 | {
"file_path": "deep-rl-class/units/en/unit6/advantage-actor-critic.mdx",
"repo_id": "deep-rl-class",
"token_count": 1384
} | 169 |
""" Adafactor Optimizer
Lifted from https://github.com/pytorch/fairseq/blob/master/fairseq/optim/adafactor.py
Original header/copyright below.
"""
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source... | pytorch-image-models/timm/optim/adafactor.py/0 | {
"file_path": "pytorch-image-models/timm/optim/adafactor.py",
"repo_id": "pytorch-image-models",
"token_count": 3656
} | 380 |
"""**Chat Models** are a variation on language models.
While Chat Models use language models under the hood, the interface they expose
is a bit different. Rather than expose a "text in, text out" API, they expose
an interface where "chat messages" are the inputs and outputs.
**Class hierarchy:**
.. code-block::
... | langchain/libs/community/langchain_community/chat_models/__init__.py/0 | {
"file_path": "langchain/libs/community/langchain_community/chat_models/__init__.py",
"repo_id": "langchain",
"token_count": 1341
} | 218 |
python_tests()
| llama_index/llama-index-integrations/readers/llama-index-readers-microsoft-onedrive/tests/BUILD/0 | {
"file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-microsoft-onedrive/tests/BUILD",
"repo_id": "llama_index",
"token_count": 5
} | 1,406 |
"""Test EdenAi's image moderation Tool .
In order to run this test, you need to have an EdenAI api key.
You can get it by registering for free at https://app.edenai.run/user/register.
A test key can be found at https://app.edenai.run/admin/account/settings by
clicking on the 'sandbox' toggle.
(calls will be free, and ... | langchain/libs/community/tests/integration_tests/tools/edenai/test_image_explicitcontent.py/0 | {
"file_path": "langchain/libs/community/tests/integration_tests/tools/edenai/test_image_explicitcontent.py",
"repo_id": "langchain",
"token_count": 304
} | 365 |
import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
import { AIMessage, BaseMessage } from "@langchain/core/messages";
import { ChatResult, ChatGeneration } from "@langchain/core/outputs";
import { BaseChatModel } from "@langchain/core/language_models/chat_models";
import { getEnvironmentVaria... | langchainjs/libs/langchain-yandex/src/chat_models.ts/0 | {
"file_path": "langchainjs/libs/langchain-yandex/src/chat_models.ts",
"repo_id": "langchainjs",
"token_count": 1819
} | 987 |
# Metric Card for F1
## Metric Description
The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:
F1 = 2 * (precision * recall) / (precision + recall)
## How to Use
At minimum, this metric requires predictions and references as input
```python
>>> f1_metric = dataset... | datasets/metrics/f1/README.md/0 | {
"file_path": "datasets/metrics/f1/README.md",
"repo_id": "datasets",
"token_count": 1624
} | 139 |
<jupyter_start><jupyter_text>Router Fine-tuningIn this notebook, we experiment with fine-tuning an LLM-powered router. We try a few different approaches, with query + ground-truth "choice" as the training signal.1. Fine-tuning embeddings2. Fine-tuning a cross-encoderOur dataset will be Wikipedia articles of different c... | llama_index/docs/examples/finetuning/router/router_finetune.ipynb/0 | {
"file_path": "llama_index/docs/examples/finetuning/router/router_finetune.ipynb",
"repo_id": "llama_index",
"token_count": 4578
} | 1,107 |
poetry_requirements(
name="poetry",
)
| llama_index/llama-index-integrations/readers/llama-index-readers-remote/BUILD/0 | {
"file_path": "llama_index/llama-index-integrations/readers/llama-index-readers-remote/BUILD",
"repo_id": "llama_index",
"token_count": 18
} | 1,367 |
pub mod models;
pub mod tokenizer;
| tokenizers/bindings/node/src/tasks/mod.rs/0 | {
"file_path": "tokenizers/bindings/node/src/tasks/mod.rs",
"repo_id": "tokenizers",
"token_count": 11
} | 411 |
python_sources()
| llama_index/llama-index-legacy/llama_index/legacy/download/BUILD/0 | {
"file_path": "llama_index/llama-index-legacy/llama_index/legacy/download/BUILD",
"repo_id": "llama_index",
"token_count": 6
} | 1,647 |
python_sources()
| llama_index/benchmarks/agent/BUILD/0 | {
"file_path": "llama_index/benchmarks/agent/BUILD",
"repo_id": "llama_index",
"token_count": 6
} | 1,084 |
python_sources()
| llama_index/llama-index-integrations/callbacks/llama-index-callbacks-openinference/llama_index/callbacks/openinference/BUILD/0 | {
"file_path": "llama_index/llama-index-integrations/callbacks/llama-index-callbacks-openinference/llama_index/callbacks/openinference/BUILD",
"repo_id": "llama_index",
"token_count": 6
} | 1,212 |
"""All integration tests for LLM objects."""
| langchain/libs/community/tests/integration_tests/llms/__init__.py/0 | {
"file_path": "langchain/libs/community/tests/integration_tests/llms/__init__.py",
"repo_id": "langchain",
"token_count": 11
} | 332 |
<jupyter_start><jupyter_text>Construction d'un *tokenizer*, bloc par bloc Installez les bibliothèques 🤗 *Transformers* et 🤗 *Datasets* pour exécuter ce *notebook*.<jupyter_code>!pip install datasets transformers[sentencepiece]
from datasets import load_dataset
dataset = load_dataset("wikitext", name="wikitext-2-raw-... | notebooks/course/fr/chapter6/section8.ipynb/0 | {
"file_path": "notebooks/course/fr/chapter6/section8.ipynb",
"repo_id": "notebooks",
"token_count": 2318
} | 271 |
# Metric Card for SARI
## Metric description
SARI (***s**ystem output **a**gainst **r**eferences and against the **i**nput sentence*) is a metric used for evaluating automatic text simplification systems.
The metric compares the predicted simplified sentences against the reference and the source sentences. It expli... | datasets/metrics/sari/README.md/0 | {
"file_path": "datasets/metrics/sari/README.md",
"repo_id": "datasets",
"token_count": 1355
} | 122 |
import { PromptLayerOpenAI } from "langchain/llms/openai";
export const run = async () => {
const model = new PromptLayerOpenAI({ temperature: 0.9 });
const res = await model.call(
"What would be a good company name a company that makes colorful socks?"
);
console.log({ res });
};
| langchainjs/examples/src/models/llm/llm_promptlayer.ts/0 | {
"file_path": "langchainjs/examples/src/models/llm/llm_promptlayer.ts",
"repo_id": "langchainjs",
"token_count": 88
} | 874 |
import pickle
from typing import Any
from langchain.pydantic_v1 import Field
from langchain.schema.runnable import RunnableConfig
from langchain.schema.runnable.utils import ConfigurableFieldSpec
from langgraph.checkpoint import BaseCheckpointSaver
from langgraph.checkpoint.base import Checkpoint, empty_checkpoint
fro... | opengpts/backend/app/checkpoint.py/0 | {
"file_path": "opengpts/backend/app/checkpoint.py",
"repo_id": "opengpts",
"token_count": 1232
} | 2,054 |
[mypy]
# Empty global config
[mypy-tritonclient.*]
ignore_missing_imports = True
| langchain/libs/partners/nvidia-trt/mypy.ini/0 | {
"file_path": "langchain/libs/partners/nvidia-trt/mypy.ini",
"repo_id": "langchain",
"token_count": 30
} | 673 |
[
{
"title": "Example Usage",
"create_time": 1697499617.697575,
"update_time": 1697499624.514186,
"mapping": {
"91c9fd24-0a12-41b8-b860-8f2cc237e838": {
"id": "91c9fd24-0a12-41b8-b860-8f2cc237e838",
"message": {
"id": "91c9fd24-0a12-41b8-b860-8f2cc237e838",
"a... | langchainjs/langchain/src/document_loaders/tests/example_data/chatgpt/example_conversations.json/0 | {
"file_path": "langchainjs/langchain/src/document_loaders/tests/example_data/chatgpt/example_conversations.json",
"repo_id": "langchainjs",
"token_count": 6608
} | 877 |
from langchain_core.language_models import __all__
EXPECTED_ALL = [
"BaseLanguageModel",
"BaseChatModel",
"SimpleChatModel",
"BaseLLM",
"LLM",
"LanguageModelInput",
"LanguageModelOutput",
"LanguageModelLike",
"get_tokenizer",
"LanguageModelLike",
]
def test_all_imports() -> No... | langchain/libs/core/tests/unit_tests/language_models/test_imports.py/0 | {
"file_path": "langchain/libs/core/tests/unit_tests/language_models/test_imports.py",
"repo_id": "langchain",
"token_count": 148
} | 416 |
<!--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 applicable law or agreed... | diffusers/docs/source/ko/using-diffusers/schedulers.md/0 | {
"file_path": "diffusers/docs/source/ko/using-diffusers/schedulers.md",
"repo_id": "diffusers",
"token_count": 6917
} | 200 |
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2
formats:
- pdf
# Set the version of Python and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.11"
commands:
- mkdir -p $READTHEDOCS_OUTPUT
- c... | langchain/.readthedocs.yaml/0 | {
"file_path": "langchain/.readthedocs.yaml",
"repo_id": "langchain",
"token_count": 241
} | 67 |
# coding=utf-8
# Copyright 2020 Ecole Polytechnique 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/LICENSE-2.0
#
# Unles... | transformers/src/transformers/models/barthez/tokenization_barthez_fast.py/0 | {
"file_path": "transformers/src/transformers/models/barthez/tokenization_barthez_fast.py",
"repo_id": "transformers",
"token_count": 3745
} | 566 |
"""Test OpenAI embeddings."""
from langchain_openai.embeddings.base import OpenAIEmbeddings
def test_langchain_openai_embedding_documents() -> None:
"""Test openai embeddings."""
documents = ["foo bar"]
embedding = OpenAIEmbeddings()
output = embedding.embed_documents(documents)
assert len(output)... | langchain/libs/partners/openai/tests/integration_tests/embeddings/test_base.py/0 | {
"file_path": "langchain/libs/partners/openai/tests/integration_tests/embeddings/test_base.py",
"repo_id": "langchain",
"token_count": 324
} | 676 |
import { test, expect } from "@jest/globals";
import { calculateMaxTokens, getModelContextSize } from "../base.js";
test("properly calculates correct max tokens", async () => {
expect(
await calculateMaxTokens({ prompt: "", modelName: "gpt-3.5-turbo-16k" })
).toBe(16384);
expect(
await calculateMaxTokens... | langchainjs/langchain-core/src/language_models/tests/count_tokens.test.ts/0 | {
"file_path": "langchainjs/langchain-core/src/language_models/tests/count_tokens.test.ts",
"repo_id": "langchainjs",
"token_count": 438
} | 874 |
export * from "./chat_models.js";
export * from "./embeddings.js";
| langchainjs/libs/langchain-mistralai/src/index.ts/0 | {
"file_path": "langchainjs/libs/langchain-mistralai/src/index.ts",
"repo_id": "langchainjs",
"token_count": 24
} | 1,103 |
import { ChatOpenAI, OpenAIEmbeddings } from "@langchain/openai";
import { ConversationalRetrievalQAChain } from "langchain/chains";
import { HNSWLib } from "@langchain/community/vectorstores/hnswlib";
import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
import { BufferMemory } from "langchain/memo... | langchainjs/examples/src/chains/conversational_qa_streaming_legacy.ts/0 | {
"file_path": "langchainjs/examples/src/chains/conversational_qa_streaming_legacy.ts",
"repo_id": "langchainjs",
"token_count": 621
} | 788 |
"""Google Search API Toolkit."""
from langchain_community.tools.google_search.tool import (
GoogleSearchResults,
GoogleSearchRun,
)
__all__ = ["GoogleSearchRun", "GoogleSearchResults"]
| langchain/libs/langchain/langchain/tools/google_search/__init__.py/0 | {
"file_path": "langchain/libs/langchain/langchain/tools/google_search/__init__.py",
"repo_id": "langchain",
"token_count": 60
} | 580 |
import inspect
from typing import List, Optional, Union
import numpy as np
import PIL.Image
import torch
from torch import nn
from torch.nn import functional as F
from torchvision import transforms
from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer
from diffusers import (
Autoe... | diffusers/examples/community/clip_guided_stable_diffusion_img2img.py/0 | {
"file_path": "diffusers/examples/community/clip_guided_stable_diffusion_img2img.py",
"repo_id": "diffusers",
"token_count": 9555
} | 210 |
import math
from dataclasses import dataclass
from typing import Optional, Tuple, Union
import torch
from ..configuration_utils import ConfigMixin, register_to_config
from ..utils import BaseOutput
from ..utils.torch_utils import randn_tensor
from .scheduling_utils import SchedulerMixin
# Copied from diffusers.sche... | diffusers/src/diffusers/schedulers/scheduling_consistency_decoder.py/0 | {
"file_path": "diffusers/src/diffusers/schedulers/scheduling_consistency_decoder.py",
"repo_id": "diffusers",
"token_count": 3036
} | 270 |
# Introducing the Clipped Surrogate Objective Function
## Recap: The Policy Objective Function
Let’s remember what the objective is to optimize in Reinforce:
<img src="https://huggingface.co/datasets/huggingface-deep-rl-course/course-images/resolve/main/en/unit9/lpg.jpg" alt="Reinforce"/>
The idea was that by taking ... | deep-rl-class/units/en/unit8/clipped-surrogate-objective.mdx/0 | {
"file_path": "deep-rl-class/units/en/unit8/clipped-surrogate-objective.mdx",
"repo_id": "deep-rl-class",
"token_count": 1386
} | 166 |
import importlib.util
from typing import cast
import pytest
from llama_index.legacy.readers.loading import load_reader
from llama_index.legacy.readers.notion import NotionPageReader
from llama_index.legacy.readers.string_iterable import StringIterableReader
from llama_index.legacy.readers.web import BeautifulSoupWebRe... | llama_index/llama-index-legacy/tests/readers/test_load_reader.py/0 | {
"file_path": "llama_index/llama-index-legacy/tests/readers/test_load_reader.py",
"repo_id": "llama_index",
"token_count": 449
} | 1,647 |
from typing import Dict, List, Optional, Tuple, Union
from llama_index.legacy.callbacks.base import CallbackManager
from llama_index.legacy.callbacks.schema import CBEventType, EventPayload
from llama_index.legacy.core.base_query_engine import BaseQueryEngine
from llama_index.legacy.core.base_retriever import BaseRetr... | llama_index/llama-index-legacy/llama_index/legacy/retrievers/recursive_retriever.py/0 | {
"file_path": "llama_index/llama-index-legacy/llama_index/legacy/retrievers/recursive_retriever.py",
"repo_id": "llama_index",
"token_count": 3523
} | 1,771 |
maintainers:
- congqixia
- czs007
- wxyucs
- xiaofan-luan
- yanliang567
- jiaoew1991
| milvus/MAINTAINERS/0 | {
"file_path": "milvus/MAINTAINERS",
"repo_id": "milvus",
"token_count": 52
} | 1,699 |
<jupyter_start><jupyter_text>Huawei OBS FileThe following code demonstrates how to load an object from the Huawei OBS (Object Storage Service) as document.<jupyter_code># Install the required package
# pip install esdk-obs-python
from langchain_community.document_loaders.obs_file import OBSFileLoader
endpoint = "your-e... | langchain/docs/docs/integrations/document_loaders/huawei_obs_file.ipynb/0 | {
"file_path": "langchain/docs/docs/integrations/document_loaders/huawei_obs_file.ipynb",
"repo_id": "langchain",
"token_count": 608
} | 104 |
<jupyter_start><jupyter_text>Router Query EngineIn this tutorial, we define a custom router query engine that selects one out of several candidate query engines to execute a query. Setup If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.<jupyter_code>%pip install llama-index-emb... | llama_index/docs/examples/query_engine/RouterQueryEngine.ipynb/0 | {
"file_path": "llama_index/docs/examples/query_engine/RouterQueryEngine.ipynb",
"repo_id": "llama_index",
"token_count": 2061
} | 1,138 |
# 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/controlnet/test_controlnet_img2img.py/0 | {
"file_path": "diffusers/tests/pipelines/controlnet/test_controlnet_img2img.py",
"repo_id": "diffusers",
"token_count": 8246
} | 288 |
from .insert import InsertRunner, BPInsertRunner
from .locust import LocustInsertRunner, LocustSearchRunner, LocustRandomRunner
from .search import SearchRunner, InsertSearchRunner
from .build import BuildRunner, InsertBuildRunner
from .get import InsertGetRunner
from .accuracy import AccuracyRunner
from .accuracy impo... | milvus/tests/benchmark/milvus_benchmark/runners/__init__.py/0 | {
"file_path": "milvus/tests/benchmark/milvus_benchmark/runners/__init__.py",
"repo_id": "milvus",
"token_count": 410
} | 1,926 |
// 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/util/importutilv2/binlog/reader.go/0 | {
"file_path": "milvus/internal/util/importutilv2/binlog/reader.go",
"repo_id": "milvus",
"token_count": 1980
} | 2,020 |
# candle-nn
| candle/candle-nn/README.md/0 | {
"file_path": "candle/candle-nn/README.md",
"repo_id": "candle",
"token_count": 5
} | 60 |
accelerate launch --config_file config.yaml peft_adalora_whisper_large_training.py \
--model_name_or_path "openai/whisper-large-v2" \
--language "Marathi" \
--language_abbr "mr" \
--task "transcribe" \
--dataset_name "mozilla-foundation/common_voice_11_0" \
--push_to_hub \
--preprocessing_nu... | peft/examples/int8_training/run_adalora_whisper_int8.sh/0 | {
"file_path": "peft/examples/int8_training/run_adalora_whisper_int8.sh",
"repo_id": "peft",
"token_count": 509
} | 327 |
""" Res2Net and Res2NeXt
Adapted from Official Pytorch impl at: https://github.com/gasvn/Res2Net/
Paper: `Res2Net: A New Multi-scale Backbone Architecture` - https://arxiv.org/abs/1904.01169
"""
import math
import torch
import torch.nn as nn
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from ._bui... | pytorch-image-models/timm/models/res2net.py/0 | {
"file_path": "pytorch-image-models/timm/models/res2net.py",
"repo_id": "pytorch-image-models",
"token_count": 3659
} | 346 |
import { logVersion010MigrationWarning } from "../util/entrypoint_deprecation.js";
/* #__PURE__ */ logVersion010MigrationWarning({
oldEntrypointName: "embeddings/googlevertexai",
});
export * from "@langchain/community/embeddings/googlevertexai";
| langchainjs/langchain/src/embeddings/googlevertexai.ts/0 | {
"file_path": "langchainjs/langchain/src/embeddings/googlevertexai.ts",
"repo_id": "langchainjs",
"token_count": 78
} | 916 |
<!--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/usage_guides/model_size_estimator.md/0 | {
"file_path": "accelerate/docs/source/usage_guides/model_size_estimator.md",
"repo_id": "accelerate",
"token_count": 2029
} | 6 |
# LlamaIndex Llms Integration: Sagemaker Endpoint
| llama_index/llama-index-integrations/llms/llama-index-llms-sagemaker-endpoint/README.md/0 | {
"file_path": "llama_index/llama-index-integrations/llms/llama-index-llms-sagemaker-endpoint/README.md",
"repo_id": "llama_index",
"token_count": 13
} | 1,280 |
[tool.poetry]
name = "templates"
version = "0.0.0"
description = ""
authors = []
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
# dev, test, lint, typing
langchain = ">=0.0.353,<0.2"
[tool.poetry.group.dev]
optional = true
[tool.poetry.group.dev.dependencies]
poethepoet = "^0.24.1"
pytest-watch =... | langchain/templates/pyproject.toml/0 | {
"file_path": "langchain/templates/pyproject.toml",
"repo_id": "langchain",
"token_count": 535
} | 649 |
# Compile and install milvus cluster
## Environment
```
OS: Ubuntu 20.04
go:1.20
cmake: >=3.18
gcc: 7.5
```
## Install dependencies
Install compile dependencies
```shell
$ sudo apt install -y g++ gcc make libssl-dev zlib1g-dev libboost-regex-dev \
libboost-program-options-dev libboost-system-dev libboost-files... | milvus/scripts/README.md/0 | {
"file_path": "milvus/scripts/README.md",
"repo_id": "milvus",
"token_count": 875
} | 1,983 |
<!--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/tasks/translation.md/0 | {
"file_path": "transformers/docs/source/en/tasks/translation.md",
"repo_id": "transformers",
"token_count": 5199
} | 479 |
"""O365 tool utils."""
from __future__ import annotations
import logging
import os
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from O365 import Account
logger = logging.getLogger(__name__)
def clean_body(body: str) -> str:
"""Clean body of a message or event."""
try:
from bs4 import Bea... | langchain/libs/community/langchain_community/tools/office365/utils.py/0 | {
"file_path": "langchain/libs/community/langchain_community/tools/office365/utils.py",
"repo_id": "langchain",
"token_count": 975
} | 290 |
from langchain_community.tools.pubmed.tool import PubmedQueryRun
__all__ = ["PubmedQueryRun"]
| langchain/libs/langchain/langchain/tools/pubmed/tool.py/0 | {
"file_path": "langchain/libs/langchain/langchain/tools/pubmed/tool.py",
"repo_id": "langchain",
"token_count": 30
} | 584 |
[
{
"details": {
"best_of_sequences": null,
"finish_reason": "length",
"generated_tokens": 10,
"prefill": [
{
"id": 50278,
"logprob": null,
"text": "<|prompter|>"
},
{
"id": 1276,
"logprob": -8.0234375,
"te... | text-generation-inference/integration-tests/models/__snapshots__/test_neox_sharded/test_neox_load.json/0 | {
"file_path": "text-generation-inference/integration-tests/models/__snapshots__/test_neox_sharded/test_neox_load.json",
"repo_id": "text-generation-inference",
"token_count": 9164
} | 398 |
<!--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 agreed... | transformers/docs/source/ja/model_doc/bort.md/0 | {
"file_path": "transformers/docs/source/ja/model_doc/bort.md",
"repo_id": "transformers",
"token_count": 1598
} | 528 |
"""Test DocugamiLoader."""
from pathlib import Path
import pytest
from langchain_community.document_loaders import DocugamiLoader
DOCUGAMI_XML_PATH = Path(__file__).parent / "test_data" / "docugami-example.xml"
@pytest.mark.requires("dgml_utils")
def test_docugami_loader_local() -> None:
"""Test DocugamiLoader... | langchain/libs/community/tests/unit_tests/document_loaders/loaders/vendors/test_docugami.py/0 | {
"file_path": "langchain/libs/community/tests/unit_tests/document_loaders/loaders/vendors/test_docugami.py",
"repo_id": "langchain",
"token_count": 294
} | 385 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.