id
stringlengths
14
16
text
stringlengths
31
3.14k
source
stringlengths
58
124
9d4fc9925642-9
"I found several skirts that may interest you. Please take a look at the following products: Avenue Plus Size Denim Stretch Skirt, LoveShackFancy Ruffled Mini Skirt - Antique White, Nike Dri-Fit Club Golf Skirt - Active Pink, Skims Soft Lounge Ruched Long Skirt, French Toast Girl's Front Pleated Skirt with Tabs, Alexia...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-10
# Collect the API queries generated by the chain predicted_queries = [output["intermediate_steps"]["request_args"] for output in chain_outputs] from langchain.prompts import PromptTemplate template = """You are trying to answer the following question by querying an API: > Question: {question} The query you know you sho...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-11
request_eval_results [' The original query is asking for all iPhone models, so the "q" parameter is correct. The "max_price" parameter is also correct, as it is set to null, meaning that no maximum price is set. The predicted query adds two additional parameters, "size" and "min_price". The "size" parameter is not nece...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-12
' The original query is asking for tablets under $400, so the first two parameters are correct. The predicted query also includes the parameters "size" and "min_price", which are not necessary for the original query. The "size" parameter is not relevant to the question, and the "min_price" parameter is redundant since ...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-13
' The original query is asking for shoes, so the predicted query is asking for the same thing. The original query does not specify a size, so the predicted query is not adding any additional information. The original query does not specify a price range, so the predicted query is adding additional information that is n...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-14
' The original query is asking for cameras with a maximum price of 300. The predicted query is asking for cameras with a maximum price of 500. This means that the predicted query is likely to return more results than the original query, which may include cameras that are not within the budget range. Therefore, the pred...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-15
> API result: {api_response} Your response to the user: {answer} Please evaluate the accuracy and utility of your response to the user's original question, conditioned on the information available. Give a letter grade of either an A, B, C, D, or F, along with an explanation of why. End the evaluation with 'Final Grade:...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-16
request_eval_results [' The original query is asking for all iPhone models, so the "q" parameter is correct. The "max_price" parameter is also correct, as it is set to null, meaning that no maximum price is set. The predicted query adds two additional parameters, "size" and "min_price". The "size" parameter is not nece...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-17
' The original query is asking for tablets under $400, so the first two parameters are correct. The predicted query also includes the parameters "size" and "min_price", which are not necessary for the original query. The "size" parameter is not relevant to the question, and the "min_price" parameter is redundant since ...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-18
' The original query is asking for shoes, so the predicted query is asking for the same thing. The original query does not specify a size, so the predicted query is not adding any additional information. The original query does not specify a price range, so the predicted query is adding additional information that is n...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-19
' The original query is asking for cameras with a maximum price of 300. The predicted query is asking for cameras with a maximum price of 500. This means that the predicted query is likely to return more results than the original query, which may include cameras that are not within the budget range. Therefore, the pred...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-20
" The API response provided a list of headphones with their respective prices and attributes. The user asked for the best headphones, so the response should include the best headphones based on the criteria provided. The response provided a list of headphones that are all from the same brand (Apple) and all have the sa...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-21
" The API response provided a list of skirts that could potentially meet the user's needs. The response also included the name, price, and attributes of each skirt. This is a great start, as it provides the user with a variety of options to choose from. However, the response does not provide any images of the skirts, w...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-22
# Print out Score statistics for the evaluation session header = "{:<20}\t{:<10}\t{:<10}\t{:<10}".format("Metric", "Min", "Mean", "Max") print(header) for metric, metric_scores in scores.items(): mean_scores = sum(metric_scores) / len(metric_scores) if len(metric_scores) > 0 else float('nan') row = "{:<20}\t{:<...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-23
Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support. # List the paths in the OpenAPI Spec paths = sorted(spec.paths.keys()) paths ['/v1/public/openai/explain-phrase', '/v1/public/openai/explain-task', '/v1/public/openai/transla...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-24
learning_language?: string, /* The user's native language. Infer this value from the language the user asked their question in. Always use the full name of the language (e.g. Spanish, French). */ native_language?: string, /* A description of any additional context in the user's question that could affect the explanat...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-25
num_to_generate = 10 # How many examples to use for this test set. prompt = PromptTemplate.from_template(template) generation_chain = LLMChain(llm=llm, prompt=prompt) text = generation_chain.run(purpose=purpose, num_to_generate=num_to_generate) # Strip preceding numeric bullets queries = par...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-26
# Show the generated request request_args ['{"task_description": "say \'hello\'", "learning_language": "Spanish", "native_language": "English", "full_query": "Can you explain how to say \'hello\' in Spanish?"}', '{"task_description": "understanding the French word for \'goodbye\'", "learning_language": "French", "nati...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-27
'{"task_description": "Find the Dutch word for \'no\'", "learning_language": "Dutch", "native_language": "English", "full_query": "I\'m looking for the Dutch word for \'no\'."}', '{"task_description": "Explain the meaning of \'hello\' in Japanese", "learning_language": "Japanese", "native_language": "English", "full_q...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-28
## AI Assisted Correction correction_template = """Correct the following API request based on the user's feedback. If the user indicates no changes are needed, output the original without making any changes. REQUEST: {request} User Feedback / requested changes: {user_feedback} Finalized Request: """ prompt = PromptTemp...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-29
Query: I need help understanding the French word for 'goodbye'. Request: {"task_description": "understanding the French word for 'goodbye'", "learning_language": "French", "native_language": "English", "full_query": "I need help understanding the French word for 'goodbye'."} Requested changes: Query: Can you tell me h...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-30
Query: I'm looking for the Dutch word for 'no'. Request: {"task_description": "Find the Dutch word for 'no'", "learning_language": "Dutch", "native_language": "English", "full_query": "I'm looking for the Dutch word for 'no'."} Requested changes: Query: Can you explain the meaning of 'hello' in Japanese? Request: {"ta...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-31
Query: I'm trying to learn the Arabic word for 'please'. Request: {"task_description": "Learn the Arabic word for 'please'", "learning_language": "Arabic", "native_language": "English", "full_query": "I'm trying to learn the Arabic word for 'please'."} Requested changes: Now you can use the ground_truth as shown above...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-32
'{"task_description": "Learn the Italian word for \'please\'", "learning_language": "Italian", "native_language": "English", "full_query": "I\'m trying to learn the Italian word for \'please\'."}', '{"task_description": "Help with pronunciation of \'yes\' in Portuguese", "learning_language": "Portuguese", "native_lang...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
9d4fc9925642-33
'{"task_description": "say goodbye", "learning_language": "Chinese", "native_language": "English", "full_query": "Can you tell me how to say \'goodbye\' in Chinese?"}', '{"task_description": "Learn the Arabic word for \'please\'", "learning_language": "Arabic", "native_language": "English", "full_query": "I\'m trying ...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
8836ee92a0ec-0
.ipynb .pdf Agent Benchmarking: Search + Calculator Contents Loading the data Setting up a chain Make a prediction Make many predictions Evaluate performance Agent Benchmarking: Search + Calculator# Here we go over how to benchmark performance of an agent on tasks where it has access to a calculator and a search tool...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/agent_benchmarking.html
8836ee92a0ec-1
print(dataset[0]['question']) agent.run(dataset[0]['question']) Make many predictions# Now we can make predictions agent.run(dataset[4]['question']) predictions = [] predicted_dataset = [] error_dataset = [] for data in dataset: new_data = {"input": data["question"], "answer": data["answer"]} try: predi...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/agent_benchmarking.html
8836ee92a0ec-2
We can also filter the datapoints to the incorrect examples and look at them. incorrect = [pred for pred in predictions if pred['grade'] == " INCORRECT"] incorrect previous Evaluation next Agent VectorDB Question Answering Benchmarking Contents Loading the data Setting up a chain Make a prediction Make many predict...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/agent_benchmarking.html
d2d8dee29e2d-0
.ipynb .pdf Question Answering Benchmarking: Paul Graham Essay Contents Loading the data Setting up a chain Make a prediction Make many predictions Evaluate performance Question Answering Benchmarking: Paul Graham Essay# Here we go over how to benchmark performance on a question answering task over a Paul Graham essa...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/qa_benchmarking_pg.html
d2d8dee29e2d-1
from langchain.indexes import VectorstoreIndexCreator vectorstore = VectorstoreIndexCreator().from_loaders([loader]).vectorstore Running Chroma using direct local API. Using DuckDB in-memory for database. Data will be transient. Now we can create a question answering chain. from langchain.chains import RetrievalQA from...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/qa_benchmarking_pg.html
d2d8dee29e2d-2
Next, we can use a language model to score them programatically from langchain.evaluation.qa import QAEvalChain llm = OpenAI(temperature=0) eval_chain = QAEvalChain.from_llm(llm) graded_outputs = eval_chain.evaluate(dataset, predictions, question_key="question", prediction_key="result") We can add in the graded output ...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/qa_benchmarking_pg.html
e1f8a56f6cf3-0
.ipynb .pdf LLM Math Contents Setting up a chain LLM Math# Evaluating chains that know how to do math. # Comment this out if you are NOT using tracing import os os.environ["LANGCHAIN_HANDLER"] = "langchain" from langchain.evaluation.loading import load_dataset dataset = load_dataset("llm-math") Downloading and prepar...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/llm_math.html
e1f8a56f6cf3-1
chain = LLMMathChain(llm=llm) predictions = chain.apply(dataset) numeric_output = [float(p['answer'].strip().strip("Answer: ")) for p in predictions] correct = [example['answer'] == numeric_output[i] for i, example in enumerate(dataset)] sum(correct) / len(correct) 1.0 for i, example in enumerate(dataset): print("i...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/llm_math.html
e1f8a56f6cf3-2
input: 209758.857 divided by 2714.31 expected output : 77.27888745205964 prediction: 77.27888745205964 previous Using Hugging Face Datasets next Evaluating an OpenAPI Chain Contents Setting up a chain By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/use_cases/evaluation/llm_math.html
1635a89ef050-0
.ipynb .pdf Question Answering Benchmarking: State of the Union Address Contents Loading the data Setting up a chain Make a prediction Make many predictions Evaluate performance Question Answering Benchmarking: State of the Union Address# Here we go over how to benchmark performance on a question answering task over ...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/qa_benchmarking_sota.html
1635a89ef050-1
from langchain.indexes import VectorstoreIndexCreator vectorstore = VectorstoreIndexCreator().from_loaders([loader]).vectorstore Running Chroma using direct local API. Using DuckDB in-memory for database. Data will be transient. Now we can create a question answering chain. from langchain.chains import RetrievalQA from...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/qa_benchmarking_sota.html
1635a89ef050-2
'result': ' The purpose of the NATO Alliance is to secure peace and stability in Europe after World War 2.'} Next, we can use a language model to score them programatically from langchain.evaluation.qa import QAEvalChain llm = OpenAI(temperature=0) eval_chain = QAEvalChain.from_llm(llm) graded_outputs = eval_chain.eval...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/qa_benchmarking_sota.html
1635a89ef050-3
'grade': ' INCORRECT'} previous Question Answering Benchmarking: Paul Graham Essay next QA Generation Contents Loading the data Setting up a chain Make a prediction Make many predictions Evaluate performance By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/use_cases/evaluation/qa_benchmarking_sota.html
7d714c652d0b-0
.ipynb .pdf Generic Agent Evaluation Contents Setup Testing the Agent Evaluating the Agent Generic Agent Evaluation# Good evaluation is key for quickly iterating on your agent’s prompts and tools. Here we provide an example of how to use the TrajectoryEvalChain to evaluate your agent. Setup# Let’s start by defining o...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
7d714c652d0b-1
), ] memory = ConversationBufferMemory( memory_key="chat_history", return_messages=True, output_key="output" ) llm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo") agent = initialize_agent( tools, llm, agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION, verbose=True, memory=memory, ...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
7d714c652d0b-2
test_outputs_two = agent({"input": query_two}, return_only_outputs=False) > Entering new AgentExecutor chain... { "action": "Calculator", "action_input": "The length of the Eiffel Tower is 324 meters. The distance from coast to coast in the US is approximately 4,828 kilometers. First, we need to convert 4,828 k...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
7d714c652d0b-3
Thought:{ "action": "Calculator", "action_input": "The length of the Eiffel Tower is 324 meters. The distance from coast to coast in the US is approximately 4,828 kilometers. First, we need to convert 4,828 kilometers to meters, which gives us 4,828,000 meters. To find out how many Eiffel Towers we need, we can...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
7d714c652d0b-4
eval_chain = TrajectoryEvalChain.from_llm( llm=ChatOpenAI(temperature=0, model_name="gpt-4"), # Note: This must be a ChatOpenAI model agent_tools=agent.tools, return_reasoning=True, ) Let’s try evaluating the first query. question, steps, answer = test_outputs_one["input"], test_outputs_one["intermediate_st...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
7d714c652d0b-5
Fourth, does the AI language model use too many steps to answer the question? The model used only one step, which is not too many. However, it should have used more steps to provide a correct answer. Fifth, are the appropriate tools used to answer the question? The model should have used the Search tool to find the vol...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
7d714c652d0b-6
No, the AI language model does not use a logical sequence of tools. It directly uses the Calculator tool without first using the Search or Lookup tools to find the necessary information (length of the Eiffel Tower and distance from coast to coast in the US). iii. Does the AI language model use the tools in a helpful wa...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
b8837be3c706-0
.ipynb .pdf QA Generation QA Generation# This notebook shows how to use the QAGenerationChain to come up with question-answer pairs over a specific document. This is important because often times you may not have data to evaluate your question-answer system over, so this is a cheap and lightweight way to generate it! f...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/qa_generation.html
a0e149834054-0
.ipynb .pdf SQL Question Answering Benchmarking: Chinook Contents Loading the data Setting up a chain Make a prediction Make many predictions Evaluate performance SQL Question Answering Benchmarking: Chinook# Here we go over how to benchmark performance on a question answering task over a SQL database. It is highly r...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/sql_qa_benchmarking_chinook.html
a0e149834054-1
Dataset json downloaded and prepared to /Users/harrisonchase/.cache/huggingface/datasets/LangChainDatasets___json/LangChainDatasets--sql-qa-chinook-7528565d2d992b47/0.0.0/0f7e3662623656454fcd2b650f34e886a7db4b9104504885bd462096cc7a9f51. Subsequent calls will reuse this data. dataset[0] {'question': 'How many employees ...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/sql_qa_benchmarking_chinook.html
a0e149834054-2
chain(dataset[0]) {'question': 'How many employees are there?', 'answer': '8', 'result': ' There are 8 employees.'} Make many predictions# Now we can make predictions. Note that we add a try-except because this chain can sometimes error (if SQL is written incorrectly, etc) predictions = [] predicted_dataset = [] erro...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/sql_qa_benchmarking_chinook.html
a0e149834054-3
incorrect[0] {'question': 'How many employees are also customers?', 'answer': 'None', 'result': ' 59 employees are also customers.', 'grade': ' INCORRECT'} previous Question Answering next Installation Contents Loading the data Setting up a chain Make a prediction Make many predictions Evaluate performance By Ha...
/content/https://python.langchain.com/en/latest/use_cases/evaluation/sql_qa_benchmarking_chinook.html
5a826525fb45-0
.ipynb .pdf Voice Assistant Voice Assistant# This chain creates a clone of ChatGPT with a few modifications to make it a voice assistant. It uses the pyttsx3 and speech_recognition libraries to convert text to speech and speech to text respectively. The prompt template is also changed to make it more suitable for voice...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-1
Assistant is aware that human input is being transcribed from audio and as such there may be some errors in the transcription. It will attempt to account for some words being swapped with similar-sounding words or phrases. Assistant will also keep responses concise, because human attention spans are more limited over t...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-2
# other speech recognition models are also available. text = r.recognize_whisper(audio, model='medium.en', show_dict=True, )['text'] except Exception as e: unrecognized_speech_text = f'Sorry, I didn\'t catch that. Exception was: {e}s' text = unrecognized_speec...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-3
Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based ...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-4
Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-li...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-5
Assistant: > Finished chain. That's great to hear! What can I do for you today? listening now... Recognizing... Thank you. > Entering new LLMChain chain... Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answe...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-6
Human: Hello, Assistant. What's going on? AI: Hi there! It's great to hear from you. I'm doing well. How can I help you today? Human: That's cool. Isn't that neat? Yeah, I'm doing great. AI: That's great to hear! What can I do for you today? Human: Thank you. Assistant: > Finished chain. You're welcome! Is there...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-7
Assistant is aware that human input is being transcribed from audio and as such there may be some errors in the transcription. It will attempt to account for some words being swapped with similar-sounding words or phrases. Assistant will also keep responses concise, because human attention spans are more limited over t...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-8
Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based ...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-9
Assistant: > Finished chain. Neural networks are inspired by the way the human brain works. They are composed of interconnected nodes that process data and make decisions, just like neurons in the brain. Neural networks can learn from their mistakes and improve their performance over time, just like humans do. listeni...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-10
Assistant is aware that human input is being transcribed from audio and as such there may be some errors in the transcription. It will attempt to account for some words being swapped with similar-sounding words or phrases. Assistant will also keep responses concise, because human attention spans are more limited over t...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-11
Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-li...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-12
Human: Tell me a fun fact about neural networks. AI: Neural networks are inspired by the way the human brain works. They are composed of interconnected nodes that process data and make decisions, just like neurons in the brain. Neural networks can learn from their mistakes and improve their performance over time, jus...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-13
> Entering new LLMChain chain... Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assis...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-14
Human: Tell me about a brand new discovered bird species. AI: A new species of bird was recently discovered in the Amazon rainforest. The species, called the Spix's Macaw, is a small, blue parrot that is believed to be extinct in the wild. It is the first new species of bird to be discovered in the Amazon in over 100...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-15
Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-li...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-16
Human: Tell me a children's story about the importance of honesty and trust. AI: Once upon a time, there was a young boy named Jack who lived in a small village. Jack was always honest and trustworthy, and his friends and family knew they could always count on him. One day, Jack was walking through the forest when he...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-17
Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-li...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-18
Human: Thank you. AI: You're welcome! Human: Do you know of online brands like Photoshop and Freq that you don't have to download in some sort of way? Do you know of online brands like Photoshop and Freq that you don't have to download in some sort of way? Assistant: > Finished chain. Yes, there are several online ...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-19
Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist. Assistant is aware that human ...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-20
Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-li...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-21
AI: Yes, there are several online brands that offer photo editing and other creative tools without the need to download any software. Adobe Photoshop Express, Pixlr, and Fotor are some of the most popular online photo editing tools. Freq is an online music production platform that allows users to create and share musi...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
5a826525fb45-22
521 break --> 523 buffer = source.stream.read(source.CHUNK) 524 if len(buffer) == 0: break # reached end of the stream 525 frames.append(buffer) File c:\ProgramData\miniconda3\envs\lang\lib\site-packages\speech_recognition\__init__.py:199, in Microphone.MicrophoneStream.read(self, size) 198 def read(se...
/content/https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
41fc07588e8a-0
.ipynb .pdf Question answering over a group chat messages Contents 1. Install required packages 2. Add API keys 2. Create sample data 3. Ingest chat embeddings 4. Ask questions Question answering over a group chat messages# In this tutorial, we are going to use Langchain + Deep Lake with GPT4 to semantically search a...
/content/https://python.langchain.com/en/latest/use_cases/question_answering/semantic-search-over-chat.html
41fc07588e8a-1
You can generate a sample group chat conversation using ChatGPT with this prompt: Generate a group chat conversation with three friends talking about their day, referencing real places and fictional names. Make it funny and as detailed as possible. I’ve already generated such a chat in messages.txt. We can keep it simp...
/content/https://python.langchain.com/en/latest/use_cases/question_answering/semantic-search-over-chat.html
41fc07588e8a-2
retriever.search_kwargs['k'] = 4 qa = RetrievalQA.from_chain_type(llm=OpenAI(), chain_type="stuff", retriever=retriever, return_source_documents=False) # What was the restaurant the group was talking about called? query = input("Enter query:") # The Hungry Lobster ans = qa({"query": query}) print(ans) Contents 1. I...
/content/https://python.langchain.com/en/latest/use_cases/question_answering/semantic-search-over-chat.html
76223b70a2a5-0
.md .pdf Quickstart Guide Contents Installation Environment Setup Building a Language Model Application: LLMs LLMs: Get predictions from a language model Prompt Templates: Manage prompts for LLMs Chains: Combine LLMs and prompts in multi-step workflows Agents: Dynamically Call Chains Based on User Input Memory: Add S...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-1
LangChain provides many modules that can be used to build language model applications. Modules can be combined to create more complex applications, or be used individually for simple applications. LLMs: Get predictions from a language model# The most basic building block of LangChain is calling an LLM on some input. Le...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-2
This is easy to do with LangChain! First lets define the prompt template: from langchain.prompts import PromptTemplate prompt = PromptTemplate( input_variables=["product"], template="What is a good name for a company that makes {product}?", ) Let’s now see how this works! We can call the .format method to forma...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-3
from langchain.chains import LLMChain chain = LLMChain(llm=llm, prompt=prompt) Now we can run that chain only specifying the product! chain.run("colorful socks") # -> '\n\nSocktastic!' There we go! There’s the first chain - an LLM Chain. This is one of the simpler types of chains, but understanding how it works will se...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-4
Agents: For a list of supported agents and their specifications, see here. Tools: For a list of predefined tools and their specifications, see here. For this example, you will also need to install the SerpAPI Python package. pip install google-search-results And set the appropriate environment variables. import os os.e...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-5
Action: Search Action Input: "High temperature in SF yesterday" Observation: San Francisco Temperature Yesterday. Maximum temperature yesterday: 57 °F (at 1:56 pm) Minimum temperature yesterday: 49 °F (at 1:56 am) Average temperature ... Thought: I now have the temperature, so I can use the calculator to raise it to th...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-6
By default, the ConversationChain has a simple type of memory that remembers all previous inputs/outputs and adds them to the context that is passed. Let’s take a look at using this chain (setting verbose=True so we can see the prompt). from langchain import OpenAI, ConversationChain llm = OpenAI(temperature=0) convers...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-7
Building a Language Model Application: Chat Models# Similarly, you can use chat models instead of LLMs. 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 interfa...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-8
] chat(messages) # -> AIMessage(content="J'aime programmer.", additional_kwargs={}) You can go one step further and generate completions for multiple sets of messages using generate. This returns an LLMResult with an additional message parameter: batch_messages = [ [ SystemMessage(content="You are a helpful...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-9
result.llm_output['token_usage'] # -> {'prompt_tokens': 71, 'completion_tokens': 18, 'total_tokens': 89} Chat Prompt Templates# Similar to LLMs, you can make use of templating by using a MessagePromptTemplate. You can build a ChatPromptTemplate from one or more MessagePromptTemplates. You can use ChatPromptTemplate’s f...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-10
# get a chat completion from the formatted messages chat(chat_prompt.format_prompt(input_language="English", output_language="French", text="I love programming.").to_messages()) # -> AIMessage(content="J'aime programmer.", additional_kwargs={}) Chains with Chat Models# The LLMChain discussed in the above section can be...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-11
# -> "J'aime programmer." Agents with Chat Models# Agents can also be used with chat models, you can initialize one using AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION as the agent type. from langchain.agents import load_tools from langchain.agents import initialize_agent from langchain.agents import AgentType from langch...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-12
"action_input": "Olivia Wilde boyfriend" } Observation: Sudeikis and Wilde's relationship ended in November 2020. Wilde was publicly served with court documents regarding child custody while she was presenting Don't Worry Darling at CinemaCon 2022. In January 2021, Wilde began dating singer Harry Styles after meeting d...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-13
prompt = ChatPromptTemplate.from_messages([ SystemMessagePromptTemplate.from_template("The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
76223b70a2a5-14
Prompt Templates: Manage prompts for LLMs Chains: Combine LLMs and prompts in multi-step workflows Agents: Dynamically Call Chains Based on User Input Memory: Add State to Chains and Agents Building a Language Model Application: Chat Models Get Message Completions from a Chat Model Chat Prompt Templates Chains with Cha...
/content/https://python.langchain.com/en/latest/getting_started/getting_started.html
64e1c0801cb5-0
.rst .pdf Memory Memory# Note Conceptual Guide By default, Chains and Agents are stateless, meaning that they treat each incoming query independently (as are the underlying LLMs and chat models). In some applications (chatbots being a GREAT example) it is highly important to remember previous interactions, both at a sh...
/content/https://python.langchain.com/en/latest/modules/memory.html
ccee5bb2a730-0
.rst .pdf Chains Chains# Note Conceptual Guide Using an LLM in isolation is fine for some simple applications, but many more complex ones require chaining LLMs - either with each other or with other experts. LangChain provides a standard interface for Chains, as well as some common implementations of chains for ease of...
/content/https://python.langchain.com/en/latest/modules/chains.html
35de4076c5e9-0
.rst .pdf Indexes Contents Go Deeper Indexes# Note Conceptual Guide Indexes refer to ways to structure documents so that LLMs can best interact with them. This module contains utility functions for working with documents, different types of indexes, and then examples for using those indexes in chains. The most common...
/content/https://python.langchain.com/en/latest/modules/indexes.html
35de4076c5e9-1
Go Deeper# Document Loaders Text Splitters Vectorstores Retrievers previous Structured Output Parser next Getting Started Contents Go Deeper By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Apr 26, 2023.
/content/https://python.langchain.com/en/latest/modules/indexes.html
a95e8f37182a-0
.rst .pdf Agents Contents Go Deeper Agents# Note Conceptual Guide Some applications will require not just a predetermined chain of calls to LLMs/other tools, but potentially an unknown chain that depends on the user’s input. In these types of chains, there is a “agent” which has access to a suite of tools. Depending ...
/content/https://python.langchain.com/en/latest/modules/agents.html
1e2a7caf9bf6-0
.rst .pdf Models Contents Go Deeper Models# Note Conceptual Guide This section of the documentation deals with different types of models that are used in LangChain. On this page we will go over the model types at a high level, but we have individual pages for each model type. The pages contain more detailed “how-to” ...
/content/https://python.langchain.com/en/latest/modules/models.html
a9cacdad1570-0
.rst .pdf Prompts Contents Go Deeper Prompts# Note Conceptual Guide The new way of programming models is through prompts. A “prompt” refers to the input to the model. This input is rarely hard coded, but rather is often constructed from multiple components. A PromptTemplate is responsible for the construction of this...
/content/https://python.langchain.com/en/latest/modules/prompts.html
ab48e5322750-0
.rst .pdf LLMs LLMs# Note Conceptual Guide Large Language Models (LLMs) are a core component of LangChain. LangChain is not a provider of LLMs, but rather provides a standard interface through which you can interact with a variety of LLMs. The following sections of documentation are provided: Getting Started: An overvi...
/content/https://python.langchain.com/en/latest/modules/models/llms.html
3aa44f1b5395-0
.rst .pdf Text Embedding Models Text Embedding Models# Note Conceptual Guide This documentation goes over how to use the Embedding class in LangChain. The Embedding class is a class designed for interfacing with embeddings. There are lots of Embedding providers (OpenAI, Cohere, Hugging Face, etc) - this class is design...
/content/https://python.langchain.com/en/latest/modules/models/text_embedding.html