diff --git a/docs/docs/expression_language/how_to/generators.ipynb b/docs/docs/expression_language/how_to/generators.ipynb index 627be2248c251..c9635c8aacd86 100644 --- a/docs/docs/expression_language/how_to/generators.ipynb +++ b/docs/docs/expression_language/how_to/generators.ipynb @@ -176,7 +176,7 @@ "\n", "\n", "async def asplit_into_list(\n", - " input: AsyncIterator[str]\n", + " input: AsyncIterator[str],\n", ") -> AsyncIterator[List[str]]: # async def\n", " buffer = \"\"\n", " async for (\n", diff --git a/templates/sql-research-assistant/sql_research_assistant/chain.py b/templates/sql-research-assistant/sql_research_assistant/chain.py index 844942c0aa86f..43984719a3d89 100644 --- a/templates/sql-research-assistant/sql_research_assistant/chain.py +++ b/templates/sql-research-assistant/sql_research_assistant/chain.py @@ -17,6 +17,6 @@ class InputType(BaseModel): if __name__ == "__main__": - print(chain.invoke({ - "question": "who is typically older: point guards or centers?" - })) + print( + chain.invoke({"question": "who is typically older: point guards or centers?"}) + ) diff --git a/templates/sql-research-assistant/sql_research_assistant/search/sql.py b/templates/sql-research-assistant/sql_research_assistant/search/sql.py index bf4ea53e2cac8..c67afa884e846 100644 --- a/templates/sql-research-assistant/sql_research_assistant/search/sql.py +++ b/templates/sql-research-assistant/sql_research_assistant/search/sql.py @@ -56,7 +56,6 @@ def run_query(query): ) - # Chain to answer template = """Based on the table schema below, question, sql query, and sql response, write a natural language response: {schema} @@ -82,15 +81,13 @@ class InputType(BaseModel): sql_answer_chain = ( - RunnablePassthrough.assign(query=sql_chain).with_types( - input_type=InputType - ) + RunnablePassthrough.assign(query=sql_chain).with_types(input_type=InputType) | RunnablePassthrough.assign( schema=get_schema, response=lambda x: db.run(x["query"]), - ) | RunnablePassthrough.assign( - answer=prompt_response - | ChatOpenAI() - | StrOutputParser() - ) | (lambda x: f"Question: {x['question']}\n\nAnswer: {x['answer']}") + ) + | RunnablePassthrough.assign( + answer=prompt_response | ChatOpenAI() | StrOutputParser() + ) + | (lambda x: f"Question: {x['question']}\n\nAnswer: {x['answer']}") ) diff --git a/templates/sql-research-assistant/sql_research_assistant/search/web.py b/templates/sql-research-assistant/sql_research_assistant/search/web.py index fb7bbe701c04b..afd69c26fba99 100644 --- a/templates/sql-research-assistant/sql_research_assistant/search/web.py +++ b/templates/sql-research-assistant/sql_research_assistant/search/web.py @@ -16,6 +16,7 @@ RunnablePassthrough, ) from langchain.utilities import DuckDuckGoSearchAPIWrapper + from sql_research_assistant.search.sql import sql_answer_chain RESULTS_PER_QUESTION = 3 @@ -50,8 +51,6 @@ def web_search(query: str, num_results: int): return [r["link"] for r in results] - - SEARCH_PROMPT = ChatPromptTemplate.from_messages( [ ("system", "{agent_prompt}"),