Error while using WebResearchRetriever from Langchain

I had been attempting to use WebResearchRetriever from Langchain, and I’m getting this error:


ValidationError Traceback (most recent call last)
Cell In[249], line 3
1 vectorstore = Chroma(embedding_function=OpenAIEmbeddings(), persist_directory=“/Users/tst/Documents/chroma_db_ws”)
----> 3 web_research_retriever = WebResearchRetriever.from_llm(
4 vectorstore=vectorstore,
5 llm=llm,
6 search=search,
7 )

File ~/anaconda3/lib/python3.10/site-packages/langchain/retrievers/web_research.py:115, in WebResearchRetriever.from_llm(cls, vectorstore, llm, search, prompt, num_search_results, text_splitter)
100 “”“Initialize from llm using default template.
101
102 Args:
(…)
111 WebResearchRetriever
112 “””
114 if not prompt:
→ 115 QUESTION_PROMPT_SELECTOR = ConditionalPromptSelector(
116 default_prompt=DEFAULT_SEARCH_PROMPT,
117 conditionals=[
118 (lambda llm: isinstance(llm, LlamaCpp), DEFAULT_LLAMA_SEARCH_PROMPT)
119 ],
120 )
121 prompt = QUESTION_PROMPT_SELECTOR.get_prompt(llm)
123 # Use chat model prompt

File ~/anaconda3/lib/python3.10/site-packages/pydantic/main.py:341, in pydantic.main.BaseModel.init()

ValidationError: 2 validation errors for ConditionalPromptSelector
default_prompt
Can’t instantiate abstract class BasePromptTemplate with abstract methods format, format_prompt (type=type_error)
conditionals → 0 → 1
Can’t instantiate abstract class BasePromptTemplate with abstract methods format, format_prompt (type=type_error)

Hello!

It may be helpful to share your code & this does seem like a post more about LangChain than OpenAI

Here is the code

os.environ[“GOOGLE_CSE_ID”] = “cse_id”
os.environ[“GOOGLE_API_KEY”] = “api_key”
search = GoogleSearchAPIWrapper()

llm = ChatOpenAI(temperature=0)
memory = ConversationSummaryBufferMemory(llm=llm, input_key=‘question’, output_key=‘answer’, return_messages=True)

vectorstore = Chroma(embedding_function=OpenAIEmbeddings(), persist_directory=“./chroma_db_ws”)

web_research_retriever = WebResearchRetriever.from_llm(
vectorstore=vectorstore,
llm=llm,
search=search,
)
query = “How to automate the process of web research using a retriever?”
qa_chain = RetrievalQAWithSourcesChain.from_chain_type(llm,retriever=web_research_retriever)
result = qa_chain({“question”: query})