diff --git a/docs/modules/utils/examples/serpapi.ipynb b/docs/modules/utils/examples/serpapi.ipynb index a9b763a2..c77821ca 100644 --- a/docs/modules/utils/examples/serpapi.ipynb +++ b/docs/modules/utils/examples/serpapi.ipynb @@ -51,10 +51,55 @@ "search.run(\"Obama's first name?\")" ] }, + { + "cell_type": "markdown", + "id": "fe3ee213", + "metadata": {}, + "source": [ + "## Custom Parameters\n", + "You can also customize the SerpAPI wrapper with arbitrary parameters. For example, in the below example we will use `bing` instead of `google`." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "deffcc8b", + "metadata": {}, + "outputs": [], + "source": [ + "params = {\n", + " \"engine\": \"bing\",\n", + " \"gl\": \"us\",\n", + " \"hl\": \"en\",\n", + "}\n", + "search = SerpAPIWrapper(params=params)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "2c752d08", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Barack Hussein Obama II is an American politician who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, Obama was the first African-American presi…New content will be added above the current area of focus upon selectionBarack Hussein Obama II is an American politician who served as the 44th president of the United States from 2009 to 2017. A member of the Democratic Party, Obama was the first African-American president of the United States. He previously served as a U.S. senator from Illinois from 2005 to 2008 and as an Illinois state senator from 1997 to 2004, and previously worked as a civil rights lawyer before entering politics.Wikipediabarackobama.com'" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "search.run(\"Obama's first name?\")" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "27f5959a", + "id": "e0a1dc1c", "metadata": {}, "outputs": [], "source": [] diff --git a/langchain/evaluation/qa/eval_chain.py b/langchain/evaluation/qa/eval_chain.py index e712cff7..77fc721b 100644 --- a/langchain/evaluation/qa/eval_chain.py +++ b/langchain/evaluation/qa/eval_chain.py @@ -31,6 +31,12 @@ class QAEvalChain(LLMChain): Returns: QAEvalChain: the loaded QA eval chain. """ + expected_input_vars = {"query", "answer", "result"} + if expected_input_vars != set(prompt.input_variables): + raise ValueError( + f"Input variables should be {expected_input_vars}, " + f"but got {prompt.input_variables}" + ) return cls(llm=llm, prompt=prompt, **kwargs) def evaluate( diff --git a/pyproject.toml b/pyproject.toml index aae6f8aa..fb523239 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langchain" -version = "0.0.62" +version = "0.0.63" description = "Building applications with LLMs through composability" authors = [] license = "MIT"