url stringlengths 30 161 | markdown stringlengths 27 670k | last_modified stringclasses 1
value |
|---|---|---|
https://github.com/langchain-ai/langchain/blob/master/templates/README.md | # LangChain Templates
LangChain Templates are the easiest and fastest way to build a production-ready LLM application.
These templates serve as a set of reference architectures for a wide variety of popular LLM use cases.
They are all in a standard format which make it easy to deploy them with [LangServe](https://gith... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/xml-agent/README.md |
# xml-agent
This package creates an agent that uses XML syntax to communicate its decisions of what actions to take. It uses Anthropic's Claude models for writing XML syntax and can optionally look up things on the internet using DuckDuckGo.
## Environment Setup
Two environment variables need to be set:
- `ANTHROP... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/xml-agent/main.py | from xml_agent.agent import agent_executor
if __name__ == "__main__":
question = "who won the womens world cup in 2023?"
print(agent_executor.invoke({"question": question, "chat_history": []}))
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/xml-agent/xml_agent/__init__.py | from xml_agent.agent import agent_executor
__all__ = ["agent_executor"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/xml-agent/xml_agent/agent.py | from typing import List, Tuple
from langchain.agents import AgentExecutor
from langchain.agents.format_scratchpad import format_xml
from langchain.tools import DuckDuckGoSearchRun
from langchain.tools.render import render_text_description
from langchain_anthropic import ChatAnthropic
from langchain_core.messages impor... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/xml-agent/xml_agent/prompts.py | from langchain_core.agents import AgentAction, AgentFinish
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
template = """You are a helpful assistant. Help the user answer any questions.
You have access to the following tools:
{tools}
In order to use a tool, you can use <tool></tool> and <... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/vertexai-chuck-norris/README.md |
# vertexai-chuck-norris
This template makes jokes about Chuck Norris using Vertex AI PaLM2.
## Environment Setup
First, make sure you have a Google Cloud project with
an active billing account, and have the [gcloud CLI installed](https://cloud.google.com/sdk/docs/install).
Configure [application default credentia... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/vertexai-chuck-norris/vertexai_chuck_norris/chain.py | from langchain_community.chat_models import ChatVertexAI
from langchain_core.prompts import ChatPromptTemplate
_prompt = ChatPromptTemplate.from_template(
"Tell me a joke about Chuck Norris and {text}"
)
_model = ChatVertexAI()
# if you update this, you MUST also update ../pyproject.toml
# with the new `tool.lang... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/summarize-anthropic/README.md |
# summarize-anthropic
This template uses Anthropic's `claude-3-sonnet-20240229` to summarize long documents.
It leverages a large context window of 100k tokens, allowing for summarization of documents over 100 pages.
You can see the summarization prompt in `chain.py`.
## Environment Setup
Set the `ANTHROPIC_API... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/summarize-anthropic/summarize_anthropic.ipynb | {
"cells": [
{
"cell_type": "markdown",
"id": "b4ea3722",
"metadata": {},
"source": [
"## Document Loading\n",
"\n",
"Load a blog post on agents."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f4162356-c370-43d7-b34a-4e6af7a1e4c9",
"metadata": {},
"outputs"... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/summarize-anthropic/summarize_anthropic/__init__.py | from summarize_anthropic.chain import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/summarize-anthropic/summarize_anthropic/chain.py | from langchain import hub
from langchain_anthropic import ChatAnthropic
from langchain_core.output_parsers import StrOutputParser
# Create chain
prompt = hub.pull("hwchase17/anthropic-paper-qa")
model = ChatAnthropic(model="claude-3-sonnet-20240229", max_tokens=4096)
chain = prompt | model | StrOutputParser()
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/stepback-qa-prompting/README.md | # stepback-qa-prompting
This template replicates the "Step-Back" prompting technique that improves performance on complex questions by first asking a "step back" question.
This technique can be combined with regular question-answering applications by doing retrieval on both the original and step-back question.
Read... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/stepback-qa-prompting/main.py | from stepback_qa_prompting.chain import chain
if __name__ == "__main__":
chain.invoke({"question": "was chatgpt around while trump was president?"})
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/stepback-qa-prompting/stepback_qa_prompting/chain.py | from langchain_community.chat_models import ChatOpenAI
from langchain_community.utilities import DuckDuckGoSearchAPIWrapper
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate, FewShotChatMessagePromptTemplate
from langchain_core.runnables import RunnableLambd... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-research-assistant/README.md | # sql-research-assistant
This package does research over a SQL database
## Usage
This package relies on multiple models, which have the following dependencies:
- OpenAI: set the `OPENAI_API_KEY` environment variables
- Ollama: [install and run Ollama](https://python.langchain.com/docs/integrations/chat/ollama)
- ll... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-research-assistant/sql_research_assistant/__init__.py | from sql_research_assistant.chain import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-research-assistant/sql_research_assistant/chain.py | from langchain.pydantic_v1 import BaseModel
from langchain_core.runnables import RunnablePassthrough
from sql_research_assistant.search.web import chain as search_chain
from sql_research_assistant.writer import chain as writer_chain
chain_notypes = (
RunnablePassthrough().assign(research_summary=search_chain) | w... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-research-assistant/sql_research_assistant/writer.py | from langchain_community.chat_models import ChatOpenAI
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import ConfigurableField
WRITER_SYSTEM_PROMPT = "You are an AI critical thinker research assistant. Your sole purpose is t... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-research-assistant/sql_research_assistant/search/sql.py | from pathlib import Path
from langchain.memory import ConversationBufferMemory
from langchain.pydantic_v1 import BaseModel
from langchain_community.chat_models import ChatOllama, ChatOpenAI
from langchain_community.utilities import SQLDatabase
from langchain_core.output_parsers import StrOutputParser
from langchain_co... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-research-assistant/sql_research_assistant/search/web.py | import json
from typing import Any
import requests
from bs4 import BeautifulSoup
from langchain_community.chat_models import ChatOpenAI
from langchain_community.utilities import DuckDuckGoSearchAPIWrapper
from langchain_core.messages import SystemMessage
from langchain_core.output_parsers import StrOutputParser
from l... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-pgvector/README.md | # sql-pgvector
This template enables user to use `pgvector` for combining postgreSQL with semantic search / RAG.
It uses [PGVector](https://github.com/pgvector/pgvector) extension as shown in the [RAG empowered SQL cookbook](https://github.com/langchain-ai/langchain/blob/master/cookbook/retrieval_in_sql.ipynb)
## E... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-pgvector/sql_pgvector/__init__.py | from sql_pgvector.chain import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-pgvector/sql_pgvector/chain.py | import os
import re
from langchain.sql_database import SQLDatabase
from langchain_community.chat_models import ChatOpenAI
from langchain_community.embeddings import OpenAIEmbeddings
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.pydan... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-pgvector/sql_pgvector/prompt_templates.py | postgresql_template = (
"You are a Postgres expert. Given an input question, first create a "
"syntactically correct Postgres query to run, then look at the results "
"of the query and return the answer to the input question.\n"
"Unless the user specifies in the question a specific number of "
"exam... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-ollama/README.md | # sql-ollama
This template enables a user to interact with a SQL database using natural language.
It uses [Zephyr-7b](https://huggingface.co/HuggingFaceH4/zephyr-7b-alpha) via [Ollama](https://ollama.ai/library/zephyr) to run inference locally on a Mac laptop.
## Environment Setup
Before using this template, you n... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-ollama/sql-ollama.ipynb | {
"cells": [
{
"cell_type": "markdown",
"id": "d55f5fd9-21eb-433d-9259-0a588d9197c0",
"metadata": {},
"source": [
"## Run Template\n",
"\n",
"In `server.py`, set -\n",
"```\n",
"add_routes(app, chain, path=\"/sql_ollama\")\n",
"```\n",
"\n",
"This template includes an exam... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-ollama/sql_ollama/__init__.py | from sql_ollama.chain import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-ollama/sql_ollama/chain.py | from pathlib import Path
from langchain.memory import ConversationBufferMemory
from langchain_community.chat_models import ChatOllama
from langchain_community.utilities import SQLDatabase
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholde... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-llamacpp/README.md |
# sql-llamacpp
This template enables a user to interact with a SQL database using natural language.
It uses [Mistral-7b](https://mistral.ai/news/announcing-mistral-7b/) via [llama.cpp](https://github.com/ggerganov/llama.cpp) to run inference locally on a Mac laptop.
## Environment Setup
To set up the environment,... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-llamacpp/sql-llamacpp.ipynb | {
"cells": [
{
"cell_type": "markdown",
"id": "a0314df0-da99-4086-a96f-b14df05b3362",
"metadata": {},
"source": [
"## Run Template\n",
"\n",
"In `server.py`, set -\n",
"```\n",
"add_routes(app, chain, path=\"/sql_llamacpp\")\n",
"```\n",
"\n",
"This template includes an ex... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-llamacpp/sql_llamacpp/__init__.py | from sql_llamacpp.chain import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-llamacpp/sql_llamacpp/chain.py | # Get LLM
import os
from pathlib import Path
import requests
from langchain.memory import ConversationBufferMemory
from langchain_community.llms import LlamaCpp
from langchain_community.utilities import SQLDatabase
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptT... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-llama2/README.md |
# sql-llama2
This template enables a user to interact with a SQL database using natural language.
It uses LLamA2-13b hosted by [Replicate](https://python.langchain.com/docs/integrations/llms/replicate), but can be adapted to any API that supports LLaMA2 including [Fireworks](https://python.langchain.com/docs/integr... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-llama2/sql_llama2.ipynb | {
"cells": [
{
"cell_type": "markdown",
"id": "22f3f9f9-80ee-4da1-ba12-105a0ce74203",
"metadata": {},
"source": [
"## Run Template\n",
"\n",
"In `server.py`, set -\n",
"```\n",
"add_routes(app, chain, path=\"/sql_llama2\")\n",
"```\n",
"\n",
"This template includes an exam... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-llama2/sql_llama2/__init__.py | from sql_llama2.chain import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/sql-llama2/sql_llama2/chain.py | from pathlib import Path
from langchain_community.llms import Replicate
from langchain_community.utilities import SQLDatabase
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.pydantic_v1 import BaseModel
from langchain_core.runnables im... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/solo-performance-prompting-agent/README.md | # solo-performance-prompting-agent
This template creates an agent that transforms a single LLM into a cognitive synergist by engaging in multi-turn self-collaboration with multiple personas.
A cognitive synergist refers to an intelligent agent that collaborates with multiple minds, combining their individual strength... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/solo-performance-prompting-agent/solo_performance_prompting_agent/agent.py | from langchain.agents import AgentExecutor
from langchain.agents.format_scratchpad import format_xml
from langchain.tools import DuckDuckGoSearchRun
from langchain.tools.render import render_text_description
from langchain_community.llms import OpenAI
from langchain_core.pydantic_v1 import BaseModel
from solo_performa... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/solo-performance-prompting-agent/solo_performance_prompting_agent/parser.py | from langchain_core.agents import AgentAction, AgentFinish
def parse_output(message: str):
FINAL_ANSWER_ACTION = "<final_answer>"
includes_answer = FINAL_ANSWER_ACTION in message
if includes_answer:
answer = message.split(FINAL_ANSWER_ACTION)[1].strip()
if "</final_answer>" in answer:
... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/solo-performance-prompting-agent/solo_performance_prompting_agent/prompts.py | from langchain_core.prompts import ChatPromptTemplate
template = """When faced with a task, begin by identifying the participants who will contribute to solving the task. Then, initiate a multi-round collaboration process until a final solution is reached. The participants will
give critical comments a... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/skeleton-of-thought/README.md | # skeleton-of-thought
Implements "Skeleton of Thought" from [this](https://sites.google.com/view/sot-llm) paper.
This technique makes it possible to generate longer generations more quickly by first generating a skeleton, then generating each point of the outline.
## Environment Setup
Set the `OPENAI_API_KEY` envir... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/skeleton-of-thought/skeleton_of_thought/__init__.py | from skeleton_of_thought.chain import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/skeleton-of-thought/skeleton_of_thought/chain.py | from langchain_community.chat_models import ChatOpenAI
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.pydantic_v1 import BaseModel
from langchain_core.runnables import RunnablePassthrough
skeleton_generator_template = """[User:] You’r... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/shopping-assistant/README.md | # shopping-assistant
This template creates a shopping assistant that helps users find products that they are looking for.
This template will use `Ionic` to search for products.
## Environment Setup
This template will use `OpenAI` by default.
Be sure that `OPENAI_API_KEY` is set in your environment.
## Usage
To us... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/shopping-assistant/shopping_assistant/agent.py | from typing import List, Tuple
from ionic_langchain.tool import IonicTool
from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_core.messages import AIMessage, SystemMessage
from langchain_core.prompts import (
ChatPromptTemplate,
HumanMessagePromptTemplate,
MessagesPlacehold... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/self-query-supabase/README.md |
# self-query-supabase
This templates allows natural language structured quering of Supabase.
[Supabase](https://supabase.com/docs) is an open-source alternative to Firebase, built on top of [PostgreSQL](https://en.wikipedia.org/wiki/PostgreSQL).
It uses [pgvector](https://github.com/pgvector/pgvector) to store em... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/self-query-supabase/self_query_supabase/chain.py | import os
from langchain.chains.query_constructor.base import AttributeInfo
from langchain.retrievers.self_query.base import SelfQueryRetriever
from langchain_community.embeddings import OpenAIEmbeddings
from langchain_community.llms.openai import OpenAI
from langchain_community.vectorstores.supabase import SupabaseVe... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/self-query-qdrant/README.md |
# self-query-qdrant
This template performs [self-querying](https://python.langchain.com/docs/modules/data_connection/retrievers/self_query/)
using Qdrant and OpenAI. By default, it uses an artificial dataset of 10 documents, but you can replace it with your own dataset.
## Environment Setup
Set the `OPENAI_API_KEY... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/self-query-qdrant/self_query_qdrant/__init__.py | from self_query_qdrant.chain import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/self-query-qdrant/self_query_qdrant/chain.py | import os
from typing import List, Optional
from langchain.chains.query_constructor.schema import AttributeInfo
from langchain.retrievers import SelfQueryRetriever
from langchain_community.llms import BaseLLM
from langchain_community.vectorstores.qdrant import Qdrant
from langchain_core.documents import Document
from ... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/self-query-qdrant/self_query_qdrant/defaults.py | from langchain.chains.query_constructor.schema import AttributeInfo
from langchain_core.documents import Document
# Qdrant collection name
DEFAULT_COLLECTION_NAME = "restaurants"
# Here is a description of the dataset and metadata attributes. Metadata attributes will
# be used to filter the results of the query beyon... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/self-query-qdrant/self_query_qdrant/helper.py | from string import Formatter
from typing import List
from langchain_core.documents import Document
document_template = """
PASSAGE: {page_content}
METADATA: {metadata}
"""
def combine_documents(documents: List[Document]) -> str:
"""
Combine a list of documents into a single string that might be passed furth... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/self-query-qdrant/self_query_qdrant/prompts.py | from langchain_core.prompts import PromptTemplate
llm_context_prompt_template = """
Answer the user query using provided passages. Each passage has metadata given as
a nested JSON object you can also use. When answering, cite source name of the passages
you are answering from below the answer in a unique bullet poin... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/robocorp-action-server/README.md | # Langchain - Robocorp Action Server
This template enables using [Robocorp Action Server](https://github.com/robocorp/robocorp) served actions as tools for an Agent.
## Usage
To use this package, you should first have the LangChain CLI installed:
```shell
pip install -U langchain-cli
```
To create a new LangChain ... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/robocorp-action-server/robocorp_action_server/__init__.py | from robocorp_action_server.agent import agent_executor
__all__ = ["agent_executor"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/robocorp-action-server/robocorp_action_server/agent.py | from langchain.agents import AgentExecutor, OpenAIFunctionsAgent
from langchain_core.messages import SystemMessage
from langchain_core.pydantic_v1 import BaseModel
from langchain_openai import ChatOpenAI
from langchain_robocorp import ActionServerToolkit
# Initialize LLM chat model
llm = ChatOpenAI(model="gpt-4", temp... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rewrite-retrieve-read/README.md |
# rewrite_retrieve_read
This template implemenets a method for query transformation (re-writing) in the paper [Query Rewriting for Retrieval-Augmented Large Language Models](https://arxiv.org/pdf/2305.14283.pdf) to optimize for RAG.
## Environment Setup
Set the `OPENAI_API_KEY` environment variable to access the O... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rewrite-retrieve-read/main.py | from rewrite_retrieve_read.chain import chain
if __name__ == "__main__":
chain.invoke("man that sam bankman fried trial was crazy! what is langchain?")
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rewrite-retrieve-read/rewrite_retrieve_read/chain.py | from langchain_community.chat_models import ChatOpenAI
from langchain_community.utilities import DuckDuckGoSearchAPIWrapper
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.pydantic_v1 import BaseModel
from langchain_core.runnables impor... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/retrieval-agent/README.md | # retrieval-agent
This package uses Azure OpenAI to do retrieval using an agent architecture.
By default, this does retrieval over Arxiv.
## Environment Setup
Since we are using Azure OpenAI, we will need to set the following environment variables:
```shell
export AZURE_OPENAI_ENDPOINT=...
export AZURE_OPENAI_API_V... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/retrieval-agent/retrieval_agent/__init__.py | from retrieval_agent.chain import agent_executor
__all__ = ["agent_executor"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/retrieval-agent/retrieval_agent/chain.py | import os
from typing import List, Tuple
from langchain.agents import AgentExecutor
from langchain.agents.format_scratchpad import format_to_openai_function_messages
from langchain.agents.output_parsers import OpenAIFunctionsAgentOutputParser
from langchain.callbacks.manager import CallbackManagerForRetrieverRun
from ... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/retrieval-agent-fireworks/README.md | # retrieval-agent-fireworks
This package uses open source models hosted on FireworksAI to do retrieval using an agent architecture. By default, this does retrieval over Arxiv.
We will use `Mixtral8x7b-instruct-v0.1`, which is shown in this blog to yield reasonable
results with function calling even though it is not f... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/retrieval-agent-fireworks/retrieval_agent_fireworks/__init__.py | from retrieval_agent_fireworks.chain import agent_executor
__all__ = ["agent_executor"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/retrieval-agent-fireworks/retrieval_agent_fireworks/chain.py | from typing import List
from langchain import hub
from langchain.agents import AgentExecutor
from langchain.agents.format_scratchpad import format_log_to_str
from langchain.agents.output_parsers import ReActJsonSingleInputOutputParser
from langchain.callbacks.manager import CallbackManagerForRetrieverRun
from langchai... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/research-assistant/README.md | # research-assistant
This template implements a version of
[GPT Researcher](https://github.com/assafelovic/gpt-researcher) that you can use
as a starting point for a research agent.
## Environment Setup
The default template relies on ChatOpenAI and DuckDuckGo, so you will need the
following environment variable:
... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/research-assistant/research_assistant/__init__.py | from research_assistant.chain import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/research-assistant/research_assistant/chain.py | from langchain_core.pydantic_v1 import BaseModel
from langchain_core.runnables import RunnablePassthrough
from research_assistant.search.web import chain as search_chain
from research_assistant.writer import chain as writer_chain
chain_notypes = (
RunnablePassthrough().assign(research_summary=search_chain) | writ... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/research-assistant/research_assistant/writer.py | from langchain_community.chat_models import ChatOpenAI
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import ConfigurableField
WRITER_SYSTEM_PROMPT = "You are an AI critical thinker research assistant. Your sole purpose is t... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/research-assistant/research_assistant/search/web.py | import json
from typing import Any
import requests
from bs4 import BeautifulSoup
from langchain.retrievers.tavily_search_api import TavilySearchAPIRetriever
from langchain_community.chat_models import ChatOpenAI
from langchain_community.utilities import DuckDuckGoSearchAPIWrapper
from langchain_core.messages import Sy... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-weaviate/README.md |
# rag-weaviate
This template performs RAG with Weaviate.
## Environment Setup
Set the `OPENAI_API_KEY` environment variable to access the OpenAI models.
Also, ensure the following environment variables are set:
* `WEAVIATE_ENVIRONMENT`
* `WEAVIATE_API_KEY`
## Usage
To use this package, you should first have the ... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-weaviate/rag_weaviate.ipynb | {
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "8692a430",
"metadata": {},
"source": [
"# Run Template\n",
"\n",
"In `server.py`, set -\n",
"```\n",
"add_routes(app, chain_ext, path=\"/rag-weaviate\")\n",
"```"
]
},
{
"cell_type": "code",
"executi... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-weaviate/rag_weaviate/__init__.py | from rag_weaviate.chain import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-weaviate/rag_weaviate/chain.py | import os
from langchain_community.chat_models import ChatOpenAI
from langchain_community.document_loaders import WebBaseLoader
from langchain_community.embeddings import OpenAIEmbeddings
from langchain_community.vectorstores import Weaviate
from langchain_core.output_parsers import StrOutputParser
from langchain_core... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-vectara/README.md |
# rag-vectara
This template performs RAG with vectara.
## Environment Setup
Also, ensure the following environment variables are set:
* `VECTARA_CUSTOMER_ID`
* `VECTARA_CORPUS_ID`
* `VECTARA_API_KEY`
## Usage
To use this package, you should first have the LangChain CLI installed:
```shell
pip install -U langchai... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-vectara/rag_vectara.ipynb | {
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "8692a430",
"metadata": {},
"source": [
"# Run Template\n",
"\n",
"In `server.py`, set -\n",
"```\n",
"add_routes(app, chain_ext, path=\"/rag-vectara\")\n",
"```"
]
},
{
"cell_type": "code",
"executio... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-vectara/rag_vectara/__init__.py | from rag_vectara.chain import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-vectara/rag_vectara/chain.py | import os
from langchain_community.vectorstores import Vectara
from langchain_community.vectorstores.vectara import SummaryConfig, VectaraQueryConfig
from langchain_core.pydantic_v1 import BaseModel
if os.environ.get("VECTARA_CUSTOMER_ID", None) is None:
raise Exception("Missing `VECTARA_CUSTOMER_ID` environment ... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-vectara-multiquery/README.md |
# rag-vectara-multiquery
This template performs multiquery RAG with vectara.
## Environment Setup
Set the `OPENAI_API_KEY` environment variable to access the OpenAI models for the multi-query processing.
Also, ensure the following environment variables are set:
* `VECTARA_CUSTOMER_ID`
* `VECTARA_CORPUS_ID`
* `VECT... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-vectara-multiquery/rag_vectara_multiquery.ipynb | {
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "8692a430",
"metadata": {},
"source": [
"# Run Template\n",
"\n",
"In `server.py`, set -\n",
"```\n",
"add_routes(app, chain_ext, path=\"/rag-vectara-multiquery\")\n",
"```"
]
},
{
"cell_type": "code",
... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-vectara-multiquery/rag_vectara_multiquery/__init__.py | from rag_vectara_multiquery.chain import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-vectara-multiquery/rag_vectara_multiquery/chain.py | import os
from langchain.retrievers.multi_query import MultiQueryRetriever
from langchain_community.vectorstores import Vectara
from langchain_community.vectorstores.vectara import SummaryConfig, VectaraQueryConfig
from langchain_core.output_parsers import StrOutputParser
from langchain_core.pydantic_v1 import BaseMod... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-timescale-hybrid-search-time/README.md | # 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)
- ... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-timescale-hybrid-search-time/rag_timescale_hybrid_search_time/__init__.py | from rag_timescale_hybrid_search_time import chain
__all__ = ["chain"]
| Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-timescale-hybrid-search-time/rag_timescale_hybrid_search_time/chain.py | # ruff: noqa: E501
import os
from datetime import timedelta
from langchain.chains.query_constructor.base import AttributeInfo
from langchain.retrievers.self_query.base import SelfQueryRetriever
from langchain_community.chat_models import ChatOpenAI
from langchain_community.embeddings.openai import OpenAIEmbeddings
fr... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-timescale-hybrid-search-time/rag_timescale_hybrid_search_time/load_sample_dataset.py | import os
import tempfile
from datetime import datetime, timedelta
import requests
from langchain_community.document_loaders import JSONLoader
from langchain_community.embeddings.openai import OpenAIEmbeddings
from langchain_community.vectorstores.timescalevector import TimescaleVector
from langchain_text_splitters.ch... | Wed, 26 Jun 2024 13:15:51 GMT |
https://github.com/langchain-ai/langchain/blob/master/templates/rag-timescale-conversation/README.md |
# rag-timescale-conversation
This template is used for [conversational](https://python.langchain.com/docs/expression_language/cookbook/retrieval#conversational-retrieval-chain) [retrieval](https://python.langchain.com/docs/use_cases/question_answering/), which is one of the most popular LLM use-cases.
It passes both... | Wed, 26 Jun 2024 13:15:51 GMT |
End of preview. Expand in Data Studio
Root URLs scrapped in this dataset:
https://js.langchain.com/v0.2/
https://python.langchain.com/v0.2/
https://github.com/langchain-ai/langchain/tree/master/libs
https://github.com/langchain-ai/langchain/tree/master/cookbook
https://github.com/langchain-ai/langchain/tree/master/templates
https://github.com/langchain-ai/langchain/tree/master/docs/docs/how_to
- Downloads last month
- 21