id stringlengths 14 16 | text stringlengths 36 2.73k | source stringlengths 49 117 |
|---|---|---|
cfb28c6cb47a-3 | ConversationalRetrievalChain with map_reduce#
We can also use different types of combine document chains with the ConversationalRetrievalChain chain.
from langchain.chains import LLMChain
from langchain.chains.question_answering import load_qa_chain
from langchain.chains.conversational_retrieval.prompts import CONDENSE... | https://python.langchain.com/en/latest/integrations/vectara/vectara_chat.html |
cfb28c6cb47a-4 | result = chain({"question": query, "chat_history": chat_history})
result['answer']
' The president did not mention Ketanji Brown Jackson.\nSOURCES: ../../modules/state_of_the_union.txt'
ConversationalRetrievalChain with streaming to stdout#
Output from the chain will be streamed to stdout token by token in this example... | https://python.langchain.com/en/latest/integrations/vectara/vectara_chat.html |
cfb28c6cb47a-5 | chat_history = [(query, result["answer"])]
query = "Did he mention who she suceeded"
result = qa({"question": query, "chat_history": chat_history})
Justice Stephen Breyer.
get_chat_history Function#
You can also specify a get_chat_history function, which can be used to format the chat_history string.
def get_chat_hist... | https://python.langchain.com/en/latest/integrations/vectara/vectara_chat.html |
e86c16f43fec-0 | .ipynb
.pdf
Vectara Text Generation
Contents
Prepare Data
Set Up Vector DB
Set Up LLM Chain with Custom Prompt
Generate Text
Vectara Text Generation#
This notebook is based on chat_vector_db and adapted to Vectara.
Prepare Data#
First, we prepare the data. For this example, we fetch a documentation site that consists... | https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html |
e86c16f43fec-1 | source_chunks = []
splitter = CharacterTextSplitter(separator=" ", chunk_size=1024, chunk_overlap=0)
for source in sources:
for chunk in splitter.split_text(source.page_content):
source_chunks.append(chunk)
Cloning into '.'...
Set Up Vector DB#
Now that we have the documentation content in chunks, let’s put... | https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html |
e86c16f43fec-2 | print(chain.apply(inputs))
generate_blog_post("environment variables") | https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html |
e86c16f43fec-3 | [{'text': '\n\nEnvironment variables are an essential part of any development workflow. They provide a way to store and access information that is specific to the environment in which the code is running. This can be especially useful when working with different versions of a language or framework, or when running code... | https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html |
e86c16f43fec-4 | and any environment variables.\n\nUsing environment variables with the Deno CLI tasks extension is a great way to ensure that your code is running in the correct environment. For example, if you are running a test suite,'}, {'text': '\n\nEnvironment variables are an important part of any programming language, and they ... | https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html |
e86c16f43fec-5 | && echo $VAR && deno eval "console.log(\'Deno: \' + Deno.env.get(\'VAR\'))"\n```\n\nThis would output the following:\n\n```\nhello\nDeno: undefined\n```\n\nAs you can see, the value stored in the shell variable is not available in the spawned process.\n\n'}, {'text': '\n\nWhen it comes to developing applications, envir... | https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html |
e86c16f43fec-6 | is `DENO_DIR`. This environment variable is used to store the directory where Deno will store its files. This includes the Deno executable, the Deno cache, and the Deno configuration files. By setting this environment variable, you can ensure that Deno will always be able to find the files it needs.\n\nFinally, there i... | https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html |
e86c16f43fec-7 | `Deno.env` has getter and setter methods. Here is example usage:\n\n```ts\nDeno.env.set("FIREBASE_API_KEY", "examplekey123");\nDeno.env.set("FIREBASE_AUTH_DOMAIN", "firebasedomain.com");\n\nconsole.log(Deno.env.get("FIREBASE_API_KEY")); // examplekey123\nconsole.log(Deno.env.get("FIREBASE_AUTH_'}] | https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html |
e86c16f43fec-8 | Contents
Prepare Data
Set Up Vector DB
Set Up LLM Chain with Custom Prompt
Generate Text
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html |
2ba070041034-0 | .md
.pdf
Locally Hosted Setup
Contents
Installation
Environment Setup
Locally Hosted Setup#
This page contains instructions for installing and then setting up the environment to use the locally hosted version of tracing.
Installation#
Ensure you have Docker installed (see Get Docker) and that it’s running.
Install th... | https://python.langchain.com/en/latest/tracing/local_installation.html |
2ba070041034-1 | By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/tracing/local_installation.html |
d96b42c983bf-0 | .md
.pdf
Cloud Hosted Setup
Contents
Installation
Environment Setup
Cloud Hosted Setup#
We offer a hosted version of tracing at langchainplus.vercel.app. You can use this to view traces from your run without having to run the server locally.
Note: we are currently only offering this to a limited number of users. The ... | https://python.langchain.com/en/latest/tracing/hosted_installation.html |
d96b42c983bf-1 | os.environ["LANGCHAIN_API_KEY"] = "my_api_key" # Don't commit this to your repo! Better to set it in your terminal.
Contents
Installation
Environment Setup
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/tracing/hosted_installation.html |
896602474e45-0 | .ipynb
.pdf
Tracing Walkthrough
Contents
[Beta] Tracing V2
Tracing Walkthrough#
There are two recommended ways to trace your LangChains:
Setting the LANGCHAIN_TRACING environment variable to “true”.
Using a context manager with tracing_enabled() to trace a particular block of code.
Note if the environment variable is... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
896602474e45-1 | > Entering new AgentExecutor chain...
I need to use a calculator to solve this.
Action: Calculator
Action Input: 2^.123243
Observation: Answer: 1.0891804557407723
Thought: I now know the final answer.
Final Answer: 1.0891804557407723
> Finished chain.
'1.0891804557407723'
# Agent run with tracing using a chat model
ag... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
896602474e45-2 | I need to use a calculator to solve this.
Action: Calculator
Action Input: 5 ^ .123243
Observation: Answer: 1.2193914912400514
Thought:I now know the answer to the question.
Final Answer: 1.2193914912400514
> Finished chain.
# Now, we unset the environment variable and use a context manager.
if "LANGCHAIN_TRACING" in ... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
896602474e45-3 | del os.environ["LANGCHAIN_TRACING"]
questions = [f"What is {i} raised to .123 power?" for i in range(1,4)]
# start a background task
task = asyncio.create_task(agent.arun(questions[0])) # this should not be traced
with tracing_enabled() as session:
assert session
tasks = [agent.arun(q) for q in questions[... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
896602474e45-4 | pip install --upgrade langchain
langchain plus start
Option 2 (Hosted):
After making an account an grabbing a LangChainPlus API Key, set the LANGCHAIN_ENDPOINT and LANGCHAIN_API_KEY environment variables
import os
os.environ["LANGCHAIN_TRACING_V2"] = "true"
# os.environ["LANGCHAIN_ENDPOINT"] = "https://langchainpro-api... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
896602474e45-5 | Contents
[Beta] Tracing V2
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 28, 2023. | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.