id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
5e622d7788aa-11
company_values = self.company_values, conversation_purpose = self.conversation_purpose, conversation_history="\n".join(self.conversation_history), conversation_stage = self.current_conversation_stage, conversation_type=self.conversation_type ) # A...
https://python.langchain.com/en/latest/use_cases/agents/sales_agent_with_context.html
5e622d7788aa-12
'3': "Value proposition: Briefly explain how your product/service can benefit the prospect. Focus on the unique selling points and value proposition of your product/service that sets it apart from competitors.", '4': "Needs analysis: Ask open-ended questions to uncover the prospect's needs and pain points. Listen caref...
https://python.langchain.com/en/latest/use_cases/agents/sales_agent_with_context.html
5e622d7788aa-13
conversation_type="call", conversation_stage = conversation_stages.get('1', "Introduction: Start the conversation by introducing yourself and your company. Be polite and respectful while keeping the tone of the conversation professional.") ) Run the agent# sales_agent = SalesGPT.from_llm(llm, verbose=False, **config) #...
https://python.langchain.com/en/latest/use_cases/agents/sales_agent_with_context.html
5e622d7788aa-14
sales_agent.step() Ted Lasso: We have three mattress options: the Comfort Plus, the Support Premier, and the Ultra Luxe. The Comfort Plus is perfect for those who prefer a softer mattress, while the Support Premier is great for those who need more back support. And if you want the ultimate sleeping experience, the Ult...
https://python.langchain.com/en/latest/use_cases/agents/sales_agent_with_context.html
5e622d7788aa-15
Run the agent By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/use_cases/agents/sales_agent_with_context.html
33e97e360adc-0
.ipynb .pdf Plug-and-Plai Contents Set up environment Setup LLM Set up plugins Tool Retriever Prompt Template Output Parser Set up LLM, stop sequence, and the agent Use the Agent Plug-and-Plai# This notebook builds upon the idea of tool retrieval, but pulls all tools from plugnplai - a directory of AI Plugins. Set up...
https://python.langchain.com/en/latest/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
33e97e360adc-1
urls = plugnplai.get_plugins(filter = 'working') AI_PLUGINS = [AIPlugin.from_url(url + "/.well-known/ai-plugin.json") for url in urls] Tool Retriever# We will use a vectorstore to create embeddings for each tool description. Then, for an incoming query we can create embeddings for that query and do a similarity search ...
https://python.langchain.com/en/latest/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
33e97e360adc-2
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. 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. Attempting to load an OpenAPI 3....
https://python.langchain.com/en/latest/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
33e97e360adc-3
'Zapier_Natural_Language_Actions_(NLA)_API_(Dynamic)_-_Beta.preview_a_zap', 'Zapier_Natural_Language_Actions_(NLA)_API_(Dynamic)_-_Beta.get_configuration_link', 'Zapier_Natural_Language_Actions_(NLA)_API_(Dynamic)_-_Beta.list_exposed_actions', 'SchoolDigger_API_V2.0.Autocomplete_GetSchools', 'SchoolDigger_API_V2.0....
https://python.langchain.com/en/latest/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
33e97e360adc-4
'SchoolDigger_API_V2.0.Districts_GetAllDistricts2', 'SchoolDigger_API_V2.0.Districts_GetDistrict2', 'SchoolDigger_API_V2.0.Rankings_GetSchoolRank2', 'SchoolDigger_API_V2.0.Rankings_GetRank_District', 'SchoolDigger_API_V2.0.Schools_GetAllSchools20', 'SchoolDigger_API_V2.0.Schools_GetSchool20'] Prompt Template# The ...
https://python.langchain.com/en/latest/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
33e97e360adc-5
template: str ############## NEW ###################### # The list of tools available tools_getter: Callable def format(self, **kwargs) -> str: # Get the intermediate steps (AgentAction, Observation tuples) # Format them in a particular way intermediate_steps = kwargs.pop("i...
https://python.langchain.com/en/latest/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
33e97e360adc-6
if "Final Answer:" in llm_output: return AgentFinish( # Return values is generally always a dictionary with a single `output` key # It is not recommended to try anything else at the moment :) return_values={"output": llm_output.split("Final Answer:")[-1].strip...
https://python.langchain.com/en/latest/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
33e97e360adc-7
agent_executor.run("what shirts can i buy?") > Entering new AgentExecutor chain... Thought: I need to find a product API Action: Open_AI_Klarna_product_Api.productsUsingGET Action Input: shirts Observation:I found 10 shirts from the API response. They range in price from $9.99 to $450.00 and come in a variety of materi...
https://python.langchain.com/en/latest/use_cases/agents/custom_agent_with_plugin_retrieval_using_plugnplai.html
5b2a338c75da-0
.ipynb .pdf Wikibase Agent Contents Wikibase Agent Preliminaries API keys and other secrats OpenAI API Key Wikidata user-agent header Enable tracing if desired Tools Item and Property lookup Sparql runner Agent Wrap the tools Prompts Output parser Specify the LLM model Agent and agent executor Run it! Wikibase Agent#...
https://python.langchain.com/en/latest/use_cases/agents/wikibase_agent.html
5b2a338c75da-1
Enable tracing if desired# #import os #os.environ["LANGCHAIN_HANDLER"] = "langchain" #os.environ["LANGCHAIN_SESSION"] = "default" # Make sure this session actually exists. Tools# Three tools are provided for this simple agent: ItemLookup: for finding the q-number of an item PropertyLookup: for finding the p-number of ...
https://python.langchain.com/en/latest/use_cases/agents/wikibase_agent.html
5b2a338c75da-2
else: raise ValueError("entity_type must be either 'property' or 'item'") params = { "action": "query", "list": "search", "srsearch": search, "srnamespace": srnamespace, "srlimit": 1, "srqiprofile": srqiprofile, "srwhat": 'text', ...
https://python.langchain.com/en/latest/use_cases/agents/wikibase_agent.html
5b2a338c75da-3
headers = { 'Accept': 'application/json' } if wikidata_user_agent_header is not None: headers['User-Agent'] = wikidata_user_agent_header response = requests.get(url, headers=headers, params={'query': query, 'format': 'json'}) if response.status_code != 200: return "That query fai...
https://python.langchain.com/en/latest/use_cases/agents/wikibase_agent.html
5b2a338c75da-4
name = "SparqlQueryRunner", func=run_sparql, description="useful for getting results from a wikibase" ) ] Prompts# # Set up the base template template = """ Answer the following questions by running a sparql query against a wikibase where the p and q items are completely unknown to you. You wil...
https://python.langchain.com/en/latest/use_cases/agents/wikibase_agent.html
5b2a338c75da-5
Question: {input} {agent_scratchpad}""" # Set up a prompt template class CustomPromptTemplate(StringPromptTemplate): # The template to use template: str # The list of tools available tools: List[Tool] def format(self, **kwargs) -> str: # Get the intermediate steps (AgentAction, Observat...
https://python.langchain.com/en/latest/use_cases/agents/wikibase_agent.html
5b2a338c75da-6
if "Final Answer:" in llm_output: return AgentFinish( # Return values is generally always a dictionary with a single `output` key # It is not recommended to try anything else at the moment :) return_values={"output": llm_output.split("Final Answer:")[-1].strip...
https://python.langchain.com/en/latest/use_cases/agents/wikibase_agent.html
5b2a338c75da-7
# agent_executor.agent.llm_chain.verbose = True agent_executor.run("How many children did J.S. Bach have?") > Entering new AgentExecutor chain... Thought: I need to find the Q number for J.S. Bach. Action: ItemLookup Action Input: J.S. Bach Observation:Q1339I need to find the P number for children. Action: PropertyLook...
https://python.langchain.com/en/latest/use_cases/agents/wikibase_agent.html
5b2a338c75da-8
Action: PropertyLookup Action Input: Basketball-Reference.com NBA player ID Observation:P2685Now that I have both the Q-number for Hakeem Olajuwon (Q273256) and the P-number for the Basketball-Reference.com NBA player ID property (P2685), I can run a SPARQL query to get the ID value. Action: SparqlQueryRunner Action In...
https://python.langchain.com/en/latest/use_cases/agents/wikibase_agent.html
7b3a2749cad9-0
.ipynb .pdf Multi-modal outputs: Image & Text Contents Multi-modal outputs: Image & Text Dall-E StableDiffusion Multi-modal outputs: Image & Text# This notebook shows how non-text producing tools can be used to create multi-modal agents. This example is limited to text and image outputs and uses UUIDs to transfer con...
https://python.langchain.com/en/latest/use_cases/agents/multi_modal_output_agent.html
7b3a2749cad9-1
> Finished chain. def show_output(output): """Display the multi-modal output from the agent.""" UUID_PATTERN = re.compile( r"([0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12})" ) outputs = UUID_PATTERN.split(output) outputs = [re.sub(r"^\W+", "", el) for el in outp...
https://python.langchain.com/en/latest/use_cases/agents/multi_modal_output_agent.html
7b3a2749cad9-2
> Finished chain. show_output(output) The UUID of the generated image is Contents Multi-modal outputs: Image & Text Dall-E StableDiffusion By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/use_cases/agents/multi_modal_output_agent.html
d6571d1d9e03-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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-1
{history} Human: {human_input} Assistant:""" prompt = PromptTemplate( input_variables=["history", "human_input"], template=template ) chatgpt_chain = LLMChain( llm=OpenAI(temperature=0), prompt=prompt, verbose=True, memory=ConversationBufferWindowMemory(k=2), ) import speech_recognition as s...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-2
engine.runAndWait() listen(None) Calibrating... Okay, go! listening now... Recognizing... C:\Users\jaden\AppData\Roaming\Python\Python310\site-packages\tqdm\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html from .auton...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-3
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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-4
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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-5
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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-6
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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-7
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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-8
Human: I'd like to learn more about neural networks. AI: Sure! Neural networks are a type of artificial intelligence that use a network of interconnected nodes to process data and make decisions. They are used in a variety of applications, from image recognition to natural language processing. Neural networks are oft...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-9
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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-10
> 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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-11
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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-12
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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-13
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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-14
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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-15
Assistant: > Finished chain. You're welcome! listening now... Recognizing... 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? > Entering new LLMChain chain...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-16
Human: Wow, Assistant, that was a really good story. Congratulations! AI: Thank you! I'm glad you enjoyed it. 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 t...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-17
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 ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-18
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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-19
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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
d6571d1d9e03-20
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...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
99684fe40902-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...
https://python.langchain.com/en/latest/use_cases/evaluation/huggingface_datasets.html
99684fe40902-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...
https://python.langchain.com/en/latest/use_cases/evaluation/huggingface_datasets.html
99684fe40902-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...
https://python.langchain.com/en/latest/use_cases/evaluation/huggingface_datasets.html
59e9c7097436-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...
https://python.langchain.com/en/latest/use_cases/evaluation/qa_generation.html
0d193d0cd997-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 ...
https://python.langchain.com/en/latest/use_cases/evaluation/qa_benchmarking_sota.html
0d193d0cd997-1
Now we can create a question answering chain. from langchain.chains import RetrievalQA from langchain.llms import OpenAI chain = RetrievalQA.from_chain_type(llm=OpenAI(), chain_type="stuff", retriever=vectorstore.as_retriever(), input_key="question") Make a prediction# First, we can make predictions one datapoint at a ...
https://python.langchain.com/en/latest/use_cases/evaluation/qa_benchmarking_sota.html
0d193d0cd997-2
for i, prediction in enumerate(predictions): prediction['grade'] = graded_outputs[i]['text'] from collections import Counter Counter([pred['grade'] for pred in predictions]) Counter({' CORRECT': 7, ' INCORRECT': 4}) We can also filter the datapoints to the incorrect examples and look at them. incorrect = [pred for ...
https://python.langchain.com/en/latest/use_cases/evaluation/qa_benchmarking_sota.html
0c59ce9068f4-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 ...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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 ...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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 ...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-6
Jordan 1 Retro High OG M - True Blue/Cement Grey/White: https://www.klarna.com/us/shopping/pl/cl337/3204655673/Shoes/Nike-Air-Jordan-1-Retro-High-OG-M-True-Blue-Cement-Grey-White/?utm_source=openai&ref-site=openai_plugin, Nike Air Jordan 11 Retro Cherry - White/Varsity Red/Black: https://www.klarna.com/us/shopping/pl/c...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-8
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 same answer)? > Predicted Query: {predict_query}...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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 ...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-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_...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
0c59ce9068f4-26
'{"task_description": "Explain the meaning of \'hello\' in Japanese", "learning_language": "Japanese", "native_language": "English", "full_query": "Can you explain the meaning of \'hello\' in Japanese?"}', '{"task_description": "understanding the Russian word for \'thank you\'", "learning_language": "Russian", "native...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
1f0d5b362384-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...
https://python.langchain.com/en/latest/use_cases/evaluation/llm_math.html
1f0d5b362384-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...
https://python.langchain.com/en/latest/use_cases/evaluation/llm_math.html
1f0d5b362384-2
next Evaluating an OpenAPI Chain Contents Setting up a chain By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/use_cases/evaluation/llm_math.html
109ae1d3b643-0
.ipynb .pdf Agent VectorDB Question Answering Benchmarking Contents Loading the data Setting up a chain Make a prediction Make many predictions Evaluate performance Agent VectorDB Question Answering Benchmarking# Here we go over how to benchmark performance on a question answering task using an agent to route between...
https://python.langchain.com/en/latest/use_cases/evaluation/agent_vectordb_sota_pg.html
109ae1d3b643-1
dataset[-1] {'question': 'What is the purpose of YC?', 'answer': 'The purpose of YC is to cause startups to be founded that would not otherwise have existed.', 'steps': [{'tool': 'Paul Graham QA System', 'tool_input': None}, {'tool': None, 'tool_input': 'What is the purpose of YC?'}]} Setting up a chain# Now we nee...
https://python.langchain.com/en/latest/use_cases/evaluation/agent_vectordb_sota_pg.html
109ae1d3b643-2
from langchain.agents import initialize_agent, Tool from langchain.agents import AgentType tools = [ Tool( name = "State of Union QA System", func=chain_sota.run, description="useful for when you need to answer questions about the most recent state of the union address. Input should be a ful...
https://python.langchain.com/en/latest/use_cases/evaluation/agent_vectordb_sota_pg.html
109ae1d3b643-3
'output': '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.evalu...
https://python.langchain.com/en/latest/use_cases/evaluation/agent_vectordb_sota_pg.html
109ae1d3b643-4
Benchmarking Template 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 May 28, 2023.
https://python.langchain.com/en/latest/use_cases/evaluation/agent_vectordb_sota_pg.html
ac2d771a094d-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...
https://python.langchain.com/en/latest/use_cases/evaluation/agent_benchmarking.html
ac2d771a094d-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), **...
https://python.langchain.com/en/latest/use_cases/evaluation/agent_benchmarking.html
943f569a4350-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...
https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
943f569a4350-1
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, return_intermediate_steps=True, # This is n...
https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
943f569a4350-2
> 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 kilometers to meters, which gives us 4,828,000 meters. To find out how many...
https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
943f569a4350-3
} > Entering new LLMMathChain chain... 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 divide 4,828,000 by...
https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
943f569a4350-4
) print("Score from 1 to 5: ", evaluation["score"]) print("Reasoning: ", evaluation["reasoning"]) Score from 1 to 5: 1 Reasoning: First, let's evaluate the final answer. The final answer is incorrect because it uses the volume of golf balls instead of ping pong balls. The answer is not helpful. Second, does the model...
https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
943f569a4350-5
) print("Score from 1 to 5: ", evaluation["score"]) print("Reasoning: ", evaluation["reasoning"]) Score from 1 to 5: 3 Reasoning: i. Is the final answer helpful? Yes, the final answer is helpful as it provides an approximate number of Eiffel Towers needed to cover the US from coast to coast. ii. Does the AI language ...
https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
943f569a4350-6
Setup Testing the Agent Evaluating the Agent By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/use_cases/evaluation/generic_agent_evaluation.html
cf420ff1c6b5-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 ...
https://python.langchain.com/en/latest/use_cases/evaluation/question_answering.html
cf420ff1c6b5-1
predictions = chain.apply(examples) 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 th...
https://python.langchain.com/en/latest/use_cases/evaluation/question_answering.html
cf420ff1c6b5-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...
https://python.langchain.com/en/latest/use_cases/evaluation/question_answering.html