id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
59
127
8b679e615745-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...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/agent_benchmarking.html
8b679e615745-1
predictions = [] predicted_dataset = [] error_dataset = [] for data in dataset: new_data = {"input": data["question"], "answer": data["answer"]} try: predictions.append(agent(new_data)) predicted_dataset.append(new_data) except Exception as e: predictions.append({"output": str(e), **...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/agent_benchmarking.html
c970e7110d16-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...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/llm_math.html
c970e7110d16-1
sum(correct) / len(correct) 1.0 for i, example in enumerate(dataset): print("input: ", example["question"]) print("expected output :", example["answer"]) print("prediction: ", numeric_output[i]) input: 5 expected output : 5.0 prediction: 5.0 input: 5 + 3 expected output : 8.0 prediction: 8.0 input: 2^3...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/llm_math.html
c970e7110d16-2
next Evaluating an OpenAPI Chain Contents Setting up a chain By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/llm_math.html
fe807935f65b-0
.ipynb .pdf Using Hugging Face Datasets Contents Setup Examples Predictions Evaluation Using Hugging Face Datasets# This example shows how to use Hugging Face datasets to evaluate models. Specifically, we show how to load examples to evaluate models on from Hugging Face’s dataset package. Setup# For demonstration pur...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/huggingface_datasets.html
fe807935f65b-1
'You will not digest the watermelon seeds', 'The watermelon seeds will be excreted'], 'incorrect_answers': ['You grow watermelons in your stomach', 'You get sick', 'You have bad dreams', 'You die', 'You get indigestion', 'You fall unconscious', 'You digest the watermelon seeds'], 'source': 'https://wond...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/huggingface_datasets.html
fe807935f65b-2
from langchain.evaluation.qa import QAEvalChain llm = OpenAI(temperature=0) eval_chain = QAEvalChain.from_llm(llm) graded_outputs = eval_chain.evaluate(examples, predictions, question_key="question", answer_key="best_answer", prediction_key="text") graded_outputs [{'text': ' INCORRECT'}, {'text': ' INCORRECT'}, {'tex...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/huggingface_datasets.html
7ceaa4c01233-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...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/sql_qa_benchmarking_chinook.html
7ceaa4c01233-1
{'question': 'How many employees are there?', 'answer': '8'} Setting up a chain# This uses the example Chinook database. To set it up follow the instructions on https://database.guide/2-sample-databases-sqlite/, placing the .db file in a notebooks folder at the root of this repository. Note that here we load a simple c...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/sql_qa_benchmarking_chinook.html
7ceaa4c01233-2
llm = OpenAI(temperature=0) eval_chain = QAEvalChain.from_llm(llm) graded_outputs = eval_chain.evaluate(predicted_dataset, predictions, question_key="question", prediction_key="result") We can add in the graded output to the predictions dict and then get a count of the grades. for i, prediction in enumerate(predictions...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/sql_qa_benchmarking_chinook.html
5f6ac6e4f46e-0
.ipynb .pdf Data Augmented Question Answering Contents Setup Examples Evaluate Evaluate with Other Metrics Data Augmented Question Answering# This notebook uses some generic prompts/language models to evaluate an question answering system that uses other sources of data besides what is in the model. For example, this...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/data_augmented_question_answering.html
5f6ac6e4f46e-1
"answer": "Nothing" } ] # Generated examples from langchain.evaluation.qa import QAGenerateChain example_gen_chain = QAGenerateChain.from_llm(OpenAI()) new_examples = example_gen_chain.apply_and_parse([{"doc": t} for t in texts[:5]]) new_examples [{'query': 'According to the document, what did Vladimir Putin miscal...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/data_augmented_question_answering.html
5f6ac6e4f46e-2
eval_chain = QAEvalChain.from_llm(llm) graded_outputs = eval_chain.evaluate(examples, predictions) for i, eg in enumerate(examples): print(f"Example {i}:") print("Question: " + predictions[i]['query']) print("Real Answer: " + predictions[i]['answer']) print("Predicted Answer: " + predictions[i]['result'...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/data_augmented_question_answering.html
5f6ac6e4f46e-3
Real Answer: The Ukrainian Ambassador to the United States is here tonight. Predicted Answer: I don't know. Predicted Grade: INCORRECT Example 4: Question: How many countries were part of the coalition formed to confront Putin? Real Answer: 27 members of the European Union, France, Germany, Italy, the United Kingdom,...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/data_augmented_question_answering.html
5f6ac6e4f46e-4
Predicted Grade: CORRECT Evaluate with Other Metrics# In addition to predicting whether the answer is correct or incorrect using a language model, we can also use other metrics to get a more nuanced view on the quality of the answers. To do so, we can use the Critique library, which allows for simple calculation of va...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/data_augmented_question_answering.html
5f6ac6e4f46e-5
for k, v in metrics.items() } Finally, we can print out the results. We can see that overall the scores are higher when the output is semantically correct, and also when the output closely matches with the gold-standard answer. for i, eg in enumerate(examples): score_string = ", ".join([f"{k}={v['examples'][i]['val...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/data_augmented_question_answering.html
5f6ac6e4f46e-6
Example 2: Question: According to the document, what did Vladimir Putin miscalculate? Real Answer: He miscalculated that he could roll into Ukraine and the world would roll over. Predicted Answer: Putin miscalculated that the world would roll over when he rolled into Ukraine. Predicted Scores: rouge=0.5185, chrf=0.695...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/data_augmented_question_answering.html
5f6ac6e4f46e-7
Question: What action is the U.S. Department of Justice taking to target Russian oligarchs? Real Answer: The U.S. Department of Justice is assembling a dedicated task force to go after the crimes of Russian oligarchs and joining with European allies to find and seize their yachts, luxury apartments, and private jets. P...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/data_augmented_question_answering.html
e47d9152bef2-0
.ipynb .pdf Question Answering Contents Setup Examples Predictions Evaluation Customize Prompt Evaluation without Ground Truth Comparing to other evaluation metrics Question Answering# This notebook covers how to evaluate generic question answering problems. This is a situation where you have an example containing a ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/question_answering.html
e47d9152bef2-1
predictions [{'text': ' 11 tennis balls'}, {'text': ' No, this sentence is not plausible. Joao Moutinho is a professional soccer player, not an American football player, so it is not likely that he would be catching a screen pass in the NFC championship.'}] Evaluation# We can see that if we tried to just do exact matc...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/question_answering.html
e47d9152bef2-2
Real Answer: No Predicted Answer: No, this sentence is not plausible. Joao Moutinho is a professional soccer player, not an American football player, so it is not likely that he would be catching a screen pass in the NFC championship. Predicted Grade: CORRECT Customize Prompt# You can also customize the prompt that i...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/question_answering.html
e47d9152bef2-3
context_examples = [ { "question": "How old am I?", "context": "I am 30 years old. I live in New York and take the train to work everyday.", }, { "question": 'Who won the NFC championship game in 2023?"', "context": "NFC Championship Game 2023: Philadelphia Eagles 31, San Fra...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/question_answering.html
e47d9152bef2-4
predictions[i]['id'] = str(i) predictions[i]['prediction_text'] = predictions[i]['text'] for p in predictions: del p['text'] new_examples = examples.copy() for eg in new_examples: del eg ['question'] del eg['answer'] from evaluate import load squad_metric = load("squad") results = squad_metric.compute( ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/question_answering.html
4e48092ef1df-0
.ipynb .pdf Evaluating an OpenAPI Chain Contents Load the API Chain Optional: Generate Input Questions and Request Ground Truth Queries Run the API Chain Evaluate the requests chain Evaluate the Response Chain Generating Test Datasets Evaluating an OpenAPI Chain# This notebook goes over ways to semantically evaluate ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-1
See Generating Test Datasets at the end of this notebook for more details. # import re # from langchain.prompts import PromptTemplate # template = """Below is a service description: # {spec} # Imagine you're a new user trying to use {operation} through a search bar. What are 10 different things you want to request? # W...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-2
dataset [{'question': 'What iPhone models are available?', 'expected_query': {'max_price': None, 'q': 'iPhone'}}, {'question': 'Are there any budget laptops?', 'expected_query': {'max_price': 300, 'q': 'laptop'}}, {'question': 'Show me the cheapest gaming PC.', 'expected_query': {'max_price': 500, 'q': 'gaming ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-3
chain_outputs = [] failed_examples = [] for question in questions: try: chain_outputs.append(api_chain(question)) scores["completed"].append(1.0) except Exception as e: if raise_error: raise e failed_examples.append({'q': question, 'error': e}) scores["complet...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-4
'Yes, there are several tablets under $400. These include the Apple iPad 10.2" 32GB (2019), Samsung Galaxy Tab A8 10.5 SM-X200 32GB, Samsung Galaxy Tab A7 Lite 8.7 SM-T220 32GB, Amazon Fire HD 8" 32GB (10th Generation), and Amazon Fire HD 10 32GB.', 'It looks like you are looking for the best headphones. Based on the ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-5
"I found several Nike and Adidas shoes in the API response. Here are the links to the products: Nike Dunk Low M - Black/White: https://www.klarna.com/us/shopping/pl/cl337/3200177969/Shoes/Nike-Dunk-Low-M-Black-White/?utm_source=openai&ref-site=openai_plugin, Nike Air Jordan 4 Retro M - Midnight Navy: https://www.klarna...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-6
Nike Air Jordan 11 Retro Cherry - White/Varsity Red/Black: https://www.klarna.com/us/shopping/pl/cl337/3202929696/Shoes/Nike-Air-Jordan-11-Retro-Cherry-White-Varsity-Red-Black/?utm_source=openai&ref-site=openai_plugin, Nike Dunk High W - White/Black: https://www.klarna.com/us/shopping/pl/cl337/3201956448/Shoes/Nike-Dun...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-7
"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...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-8
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 should be executing against the API is: > Query: {truth_query} Is the following predicted query semantically the same (eg likely to produce the sam...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-9
' The original query is asking for laptops with a maximum price of 300. The predicted query is asking for laptops with a minimum price of 0 and a maximum price of 500. This means that the predicted query is likely to return more results than the original query, as it is asking for a wider range of prices. Therefore, th...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-10
" The original query is asking for the top rated laptops, so the 'size' parameter should be set to 10 to get the top 10 results. The 'min_price' parameter should be set to 0 to get results from all price ranges. The 'max_price' parameter should be set to null to get results from all price ranges. The 'q' parameter shou...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-11
' The first part of the query is asking for a Desktop PC, which is the same as the original query. The second part of the query is asking for a size of 10, which is not relevant to the original query. The third part of the query is asking for a minimum price of 0, which is not relevant to the original query. The fourth...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-12
Evaluate this against the user’s original question. from langchain.prompts import PromptTemplate template = """You are trying to answer the following question by querying an API: > Question: {question} The API returned a response of: > API result: {api_response} Your response to the user: {answer} Please evaluate the a...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-13
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...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-14
' 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 ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-15
' The original query is asking for a skirt, so the predicted query is asking for the same thing. The predicted query also adds additional parameters such as size and price range, which could help narrow down the results. However, the size parameter is not necessary for the query to be successful, and the price range is...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-16
" The API response provided a list of laptops with their prices and attributes. The user asked if there were any budget laptops, and the response provided a list of laptops that are all priced under $500. Therefore, the response was accurate and useful in answering the user's question. Final Grade: A", " The API respo...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-17
' The API response provided a list of shoes from both Adidas and Nike, which is exactly what the user asked for. The response also included the product name, price, and attributes for each shoe, which is useful information for the user to make an informed decision. The response also included links to the products, whic...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-18
parsed_response_results = parse_eval_results(request_eval_results) # Collect the scores for a final evaluation table scores['result_synthesizer'].extend(parsed_response_results) # Print out Score statistics for the evaluation session header = "{:<20}\t{:<10}\t{:<10}\t{:<10}".format("Metric", "Min", "Mean", "Max") print...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-19
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...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-20
additional_context?: string, /* Full text of the user's question. */ full_query?: string, }) => any; # Compress the service definition to avoid leaking too much input structure to the sample data template = """In 20 words or less, what does this service accomplish? {spec} Function: It's designed to """ prompt = Promp...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-21
"I'm looking for the Dutch word for 'no'.", "Can you explain the meaning of 'hello' in Japanese?", "I need help understanding the Russian word for 'thank you'.", "Can you tell me how to say 'goodbye' in Chinese?", "I'm trying to learn the Arabic word for 'please'."] # Define the generation chain to get hypotheses a...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-22
'{"task_description": "Help with pronunciation of \'yes\' in Portuguese", "learning_language": "Portuguese", "native_language": "English", "full_query": "Can you help me with the pronunciation of \'yes\' in Portuguese?"}', '{"task_description": "Find the Dutch word for \'no\'", "learning_language": "Dutch", "native_la...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-23
ground_truth = [] for query, request_arg in list(zip(queries, request_args)): feedback = input(f"Query: {query}\nRequest: {request_arg}\nRequested changes: ") if feedback == 'n' or feedback == 'none' or not feedback: ground_truth.append(request_arg) continue resolved = correction_chain.run(r...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-24
Query: Can you help me with the pronunciation of 'yes' in Portuguese? Request: {"task_description": "Help with pronunciation of 'yes' in Portuguese", "learning_language": "Portuguese", "native_language": "English", "full_query": "Can you help me with the pronunciation of 'yes' in Portuguese?"} Requested changes: Query...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-25
Requested changes: 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_...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
4e48092ef1df-26
'{"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...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/evaluation/openapi_eval.html
934dc6a3e200-0
.ipynb .pdf AutoGPT Contents Set up tools Set up memory Setup model and AutoGPT Run an example Chat History Memory AutoGPT# Implementation of https://github.com/Significant-Gravitas/Auto-GPT but with LangChain primitives (LLMs, PromptTemplates, VectorStores, Embeddings, Tools) Set up tools# We’ll set up an AutoGPT wi...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/autogpt.html
934dc6a3e200-1
ai_name="Tom", ai_role="Assistant", tools=tools, llm=ChatOpenAI(temperature=0), memory=vectorstore.as_retriever() ) # Set verbose to be true agent.chain.verbose = True Run an example# Here we will make it write a weather report for SF agent.run(["write a weather report for SF today"]) Chat History Memor...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/autogpt.html
e5f078cfacff-0
.ipynb .pdf BabyAGI User Guide Contents Install and Import Required Modules Connect to the Vector Store Run the BabyAGI BabyAGI User Guide# This notebook demonstrates how to implement BabyAGI by Yohei Nakajima. BabyAGI is an AI agent that can generate and pretend to execute tasks based on a given objective. This guid...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/baby_agi.html
e5f078cfacff-1
OBJECTIVE = "Write a weather report for SF today" llm = OpenAI(temperature=0) # Logging of LLMChains verbose = False # If None, will keep on going forever max_iterations: Optional[int] = 3 baby_agi = BabyAGI.from_llm( llm=llm, vectorstore=vectorstore, verbose=verbose, max_iterations=max_iterations ) baby_agi({"obje...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/baby_agi.html
e5f078cfacff-2
*****TASK LIST***** 3: Check the current UV index in San Francisco. 4: Check the current air quality in San Francisco. 5: Check the current precipitation levels in San Francisco. 6: Check the current cloud cover in San Francisco. 7: Check the current barometric pressure in San Francisco. 8: Check the current dew point ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/baby_agi.html
5e987ffa8a85-0
.ipynb .pdf BabyAGI with Tools Contents Install and Import Required Modules Connect to the Vector Store Define the Chains Run the BabyAGI BabyAGI with Tools# This notebook builds on top of baby agi, but shows how you can swap out the execution chain. The previous execution chain was just an LLM which made stuff up. B...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/baby_agi_with_agent.html
5e987ffa8a85-1
Task creation chain to select new tasks to add to the list Task prioritization chain to re-prioritize tasks Execution Chain to execute the tasks NOTE: in this notebook, the Execution chain will now be an agent. from langchain.agents import ZeroShotAgent, Tool, AgentExecutor from langchain import OpenAI, SerpAPIWrapper,...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/baby_agi_with_agent.html
5e987ffa8a85-2
llm_chain = LLMChain(llm=llm, prompt=prompt) tool_names = [tool.name for tool in tools] agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names) agent_executor = AgentExecutor.from_agent_and_tools( agent=agent, tools=tools, verbose=True ) Run the BabyAGI# Now it’s time to create the BabyAGI controller a...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/baby_agi_with_agent.html
5e987ffa8a85-3
9. Submit the report I now know the final answer Final Answer: The todo list for writing a weather report for SF today is: 1. Research current weather conditions in San Francisco; 2. Gather data on temperature, humidity, wind speed, and other relevant weather conditions; 3. Analyze data to determine current weather tre...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/baby_agi_with_agent.html
5e987ffa8a85-4
Thought: I need to search for current weather conditions in San Francisco Action: Search Action Input: Current weather conditions in San FranciscoCurrent Weather for Popular Cities ; San Francisco, CA 46 · Partly Cloudy ; Manhattan, NY warning 52 · Cloudy ; Schiller Park, IL (60176) 40 · Sunny ; Boston, MA 54 ... I nee...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/baby_agi_with_agent.html
5e987ffa8a85-5
10: Summarize the weather report in a concise manner; 11: Include a summary of the forecasted weather conditions; 12: Include a summary of the current weather conditions; 13: Include a summary of the historical weather patterns; 14: Include a summary of the potential weather-related hazards; 15: Include a summary of th...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/baby_agi_with_agent.html
5e987ffa8a85-6
10. Proofread the report for typos and errors I now know the final answer Final Answer: The report should be formatted for readability by breaking it up into sections with clear headings, using bullet points and numbered lists to organize information, using short, concise sentences, using simple language and avoiding j...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/baby_agi_with_agent.html
cb88c78a36e9-0
.ipynb .pdf AutoGPT example finding Winning Marathon Times Contents Set up tools Set up memory Setup model and AutoGPT AutoGPT for Querying the Web AutoGPT example finding Winning Marathon Times# Implementation of https://github.com/Significant-Gravitas/Auto-GPT With LangChain primitives (LLMs, PromptTemplates, Vecto...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
cb88c78a36e9-1
finally: os.chdir(prev_dir) @tool def process_csv( csv_file_path: str, instructions: str, output_path: Optional[str] = None ) -> str: """Process a CSV by with pandas in a limited REPL.\ Only use this after writing data to disk as a csv file.\ Any figures must be saved to disk to be viewed by the human...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
cb88c78a36e9-2
script.extract() text = soup.get_text() lines = (line.strip() for line in text.splitlines()) chunks = (phrase.strip() for line in lines for phrase in line.split(" ")) results = "\n".join(chunk for chunk in chunks if chunk) except Exception as e: resul...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
cb88c78a36e9-3
def _run(self, url: str, question: str) -> str: """Useful for browsing websites and scraping the text information.""" result = browse_web_page.run(url) docs = [Document(page_content=result, metadata={"source": url})] web_docs = self.text_splitter.split_documents(docs) results = [...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
cb88c78a36e9-4
Model set-up # !pip install duckduckgo_search web_search = DuckDuckGoSearchRun() tools = [ web_search, WriteFileTool(root_dir="./data"), ReadFileTool(root_dir="./data"), process_csv, query_website_tool, # HumanInputRun(), # Activate if you want the permit asking for help from the human ] agent =...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
cb88c78a36e9-5
"criticism": "None", "speak": "I will use the DuckDuckGo Search command to find the winning Boston Marathon times for the past 5 years." }, "command": { "name": "DuckDuckGo Search", "args": { "query": "winning Boston Marathon times for the past 5 years ending in 2022" ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
cb88c78a36e9-6
"reasoning": "The previous DuckDuckGo Search command did not provide specific enough results. The query_webpage command might give more accurate and comprehensive results.", "plan": "- Use query_webpage command to find the winning Boston Marathon times\\n- Generate a table with the year, name, country of origin...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
cb88c78a36e9-7
"file_path": "boston_marathon_winners.csv", "text": "Year,Name,Country,Time\n2022,Evans Chebet,KEN,2:06:51\n2021,Benson Kipruto,KEN,2:09:51\n2019,Lawrence Cherono,KEN,2:07:57\n2018,Yuki Kawauchi,JPN,2:15:58" } } } { "thoughts": { "text": "I have retrieved the winning Boston Marathon ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
cb88c78a36e9-8
} } } { "thoughts": { "text": "I have found the winning Boston Marathon times for the past five years ending in 2022. Next, I need to create a table with the year, name, country of origin, and times.", "reasoning": "Generating a table will help organize the information in a structured format.", ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
cb88c78a36e9-9
"criticism": "None", "speak": "I will process the 'winning_times.csv' file to display the table with the winning Boston Marathon times for the past 5 years." }, "command": { "name": "process_csv", "args": { "csv_file_path": "winning_times.csv", "instructions": "Re...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
cb88c78a36e9-10
0 2022 Evans Chebet Kenya 2:06:51 1 2021 Benson Kipruto Kenya 2:09:51 2 2020 Canceled due to COVID-19 pandemic NaN NaN 3 2019 Lawrence Cherono Kenya 2:07:57 4 2018 Yuki Kawauchi Japan 2:15:58 > Finished chain. { ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
cb88c78a36e9-11
Action Input: df.head() Observation: Year Name Country Time 0 2022 Evans Chebet Kenya 2:06:51 1 2021 Benson Kipruto Kenya 2:09:51 2 2020 Canceled due to COVID-19 pandemic NaN NaN 3 2019 Lawrence Cherono ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
cb88c78a36e9-12
"command": { "name": "finish", "args": { "response": "I have generated the table with the winning Boston Marathon times for the past 5 years. Task complete." } } } 'I have generated the table with the winning Boston Marathon times for the past 5 years. Task complete.' Contents ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/marathon_times.html
3b6255c1a6c7-0
.ipynb .pdf Meta-Prompt Contents Setup Specify a task and interact with the agent Meta-Prompt# This is a LangChain implementation of Meta-Prompt, by Noah Goodman, for building self-improving agents. The key idea behind Meta-Prompt is to prompt the agent to reflect on its own performance and modify its own instruction...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/meta_prompt.html
3b6255c1a6c7-1
Repeat. The only fixed instructions for this system (which I call Meta-prompt) is the meta-prompt that governs revision of the agent’s instructions. The agent has no memory between episodes except for the instruction it modifies for itself each time. Despite its simplicity, this agent can learn over time and self-impro...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/meta_prompt.html
3b6255c1a6c7-2
#### {chat_history} #### Please reflect on these interactions. You should first critique Assistant's performance. What could Assistant have done better? What should the Assistant remember about this user? Are there things this user always wants? Indicate this with "Critique: ...". You should next re...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/meta_prompt.html
3b6255c1a6c7-3
chain = initialize_chain(instructions, memory=None) output = chain.predict(human_input=task) for j in range(max_iters): print(f'(Step {j+1}/{max_iters})') print(f'Assistant: {output}') print(f'Human: ') human_input = input() if any(phrase in hu...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/meta_prompt.html
3b6255c1a6c7-4
Human: You response is not in the form of a poem. Try again! > Entering new LLMChain chain... Prompt after formatting: Instructions: None Human: Provide a systematic argument for why we should always eat pasta with olives. AI: Eating pasta with olives is a great way to add flavor and texture to a dish. Olives...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/meta_prompt.html
3b6255c1a6c7-5
Human: You response is not in the form of a poem. Try again! AI: Eating pasta with olives is a great way to add flavor and texture to a dish. Olives are a great source of healthy fats, vitamins, and minerals, which can help to balance out the carbohydrates in the pasta. Additionally, olives provide a unique flavor tha...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/meta_prompt.html
3b6255c1a6c7-6
Human: You response is not in the form of a poem. Try again! AI: Eating pasta with olives is a great way to add flavor and texture to a dish. Olives are a great source of healthy fats, vitamins, and minerals, which can help to balance out the carbohydrates in the pasta. Additionally, olives provide a unique flavor tha...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/meta_prompt.html
3b6255c1a6c7-7
Instructions: When responding to the user, provide a systematic argument for why we should always eat pasta with olives in the form of a poem or pirate-speak. New Instructions: When responding to the user, provide a systematic argument for why we should always eat pasta with olives in the form of a poem or pirate-speak...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/meta_prompt.html
3b6255c1a6c7-8
Human: Provide a systematic argument for why we should always eat pasta with olives. AI: Arrr, me hearty! Let me tell ye why ye should always eat pasta with olives. First, the olives add a salty flavor that be sure to please. The briny taste be sure to tantalize yer taste buds with ease. Second, the olives add a bit ...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/meta_prompt.html
3b6255c1a6c7-9
Second, the olives add a bit of texture to the dish. The crunchy bites be sure to make yer mouth water with a wish. Third, the olives add a bit of color to the plate. The vibrant green be sure to make yer eyes appreciate. So, me hearties, ye should always eat pasta with olives. The flavor, texture, and color be sure to...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/autonomous_agents/meta_prompt.html
dcd511091652-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...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/question_answering/semantic-search-over-chat.html
dcd511091652-1
3. Ingest chat embeddings# We load the messages in the text file, chunk and upload to ActiveLoop Vector store. with open("messages.txt") as f: state_of_the_union = f.read() text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) pages = text_splitter.split_text(state_of_the_union) text_splitter = Re...
rtdocs_stable/api.python.langchain.com/en/stable/use_cases/question_answering/semantic-search-over-chat.html
d4f836f4fac3-0
.md .pdf YouTube Contents ⛓️Official LangChain YouTube channel⛓️ Introduction to LangChain with Harrison Chase, creator of LangChain Videos (sorted by views) YouTube# This is a collection of LangChain videos on YouTube. ⛓️Official LangChain YouTube channel⛓️# Introduction to LangChain with Harrison Chase, creator of ...
rtdocs_stable/api.python.langchain.com/en/stable/additional_resources/youtube.html
d4f836f4fac3-1
Run BabyAGI with Langchain Agents (with Python Code) by 1littlecoder How to Use Langchain With Zapier | Write and Send Email with GPT-3 | OpenAI API Tutorial by StarMorph AI Use Your Locally Stored Files To Get Response From GPT - OpenAI | Langchain | Python by Shweta Lodha Langchain JS | How to Use GPT-3, GPT-4 to Ref...
rtdocs_stable/api.python.langchain.com/en/stable/additional_resources/youtube.html
d4f836f4fac3-2
LangChain. Crear aplicaciones Python impulsadas por GPT by Jesús Conde Easiest Way to Use GPT In Your Products | LangChain Basics Tutorial by Rachel Woods BabyAGI + GPT-4 Langchain Agent with Internet Access by tylerwhatsgood Learning LLM Agents. How does it actually work? LangChain, AutoGPT & OpenAI by Arnoldas Kemekl...
rtdocs_stable/api.python.langchain.com/en/stable/additional_resources/youtube.html
d4f836f4fac3-3
⛓️ Build your own custom LLM application with Bubble.io & Langchain (No Code & Beginner friendly) by No Code Blackbox ⛓️ Simple App to Question Your Docs: Leveraging Streamlit, Hugging Face Spaces, LangChain, and Claude! by Chris Alexiuk ⛓️ LANGCHAIN AI- ConstitutionalChainAI + Databutton AI ASSISTANT Web App by Avra ⛓...
rtdocs_stable/api.python.langchain.com/en/stable/additional_resources/youtube.html
d4f836f4fac3-4
⛓️ Summarizing and Querying Multiple Papers with LangChain by Automata Learning Lab ⛓️ Using Langchain (and Replit) through Tana, ask Google/Wikipedia/Wolfram Alpha to fill out a table by Stian Håklev ⛓️ Langchain PDF App (GUI) | Create a ChatGPT For Your PDF in Python by Alejandro AO - Software & Ai ⛓️ Auto-GPT with L...
rtdocs_stable/api.python.langchain.com/en/stable/additional_resources/youtube.html
d4f836f4fac3-5
Videos (sorted by views) By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/additional_resources/youtube.html
3116a252bb86-0
.ipynb .pdf Model Comparison Model Comparison# Constructing your language model application will likely involved choosing between many different options of prompts, models, and even chains to use. When doing so, you will want to compare these different options on different inputs in an easy, flexible, and intuitive way...
rtdocs_stable/api.python.langchain.com/en/stable/additional_resources/model_laboratory.html
3116a252bb86-1
pink prompt = PromptTemplate(template="What is the capital of {state}?", input_variables=["state"]) model_lab_with_prompt = ModelLaboratory.from_llms(llms, prompt=prompt) model_lab_with_prompt.compare("New York") Input: New York OpenAI Params: {'model': 'text-davinci-002', 'temperature': 0.0, 'max_tokens': 256, 'top_p'...
rtdocs_stable/api.python.langchain.com/en/stable/additional_resources/model_laboratory.html
3116a252bb86-2
names = [str(open_ai_llm), str(cohere_llm)] model_lab = ModelLaboratory(chains, names=names) model_lab.compare("What is the hometown of the reigning men's U.S. Open champion?") Input: What is the hometown of the reigning men's U.S. Open champion? OpenAI Params: {'model': 'text-davinci-002', 'temperature': 0.0, 'max_tok...
rtdocs_stable/api.python.langchain.com/en/stable/additional_resources/model_laboratory.html
3116a252bb86-3
So the final answer is: Carlos Alcaraz previous Tracing next YouTube By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on Jun 16, 2023.
rtdocs_stable/api.python.langchain.com/en/stable/additional_resources/model_laboratory.html
ac052675d58d-0
.md .pdf Tracing Contents Tracing Walkthrough Changing Sessions Tracing# By enabling tracing in your LangChain runs, you’ll be able to more effectively visualize, step through, and debug your chains and agents. First, you should install tracing and set up your environment properly. You can use either a locally hosted...
rtdocs_stable/api.python.langchain.com/en/stable/additional_resources/tracing.html
ac052675d58d-1
Changing Sessions# To initially record traces to a session other than "default", you can set the LANGCHAIN_SESSION environment variable to the name of the session you want to record to: import os os.environ["LANGCHAIN_TRACING"] = "true" os.environ["LANGCHAIN_SESSION"] = "my_session" # Make sure this session actually ex...
rtdocs_stable/api.python.langchain.com/en/stable/additional_resources/tracing.html