Skip to content

Commit

Permalink
cr
Browse files Browse the repository at this point in the history
  • Loading branch information
hwchase17 committed Dec 18, 2023
1 parent df85654 commit 7ef7607
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/docs/expression_language/how_to/generators.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?"})
)
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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']}")
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
RunnablePassthrough,
)
from langchain.utilities import DuckDuckGoSearchAPIWrapper

from sql_research_assistant.search.sql import sql_answer_chain

RESULTS_PER_QUESTION = 3
Expand Down Expand Up @@ -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}"),
Expand Down

0 comments on commit 7ef7607

Please sign in to comment.