Skip to content

Commit

Permalink
Add join chain of thought and fix scroll (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 authored Jul 8, 2024
1 parent a2e74f5 commit f3e5609
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions lumen/ai/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,15 +566,16 @@ async def answer(self, messages: list | str):
return None

with self.interface.add_step(title="Checking if join is required") as step:
join_required = (await self.llm.invoke(
join = (await self.llm.invoke(
messages,
system="Determine whether a table join is required to answer the user's query.",
response_model=JoinRequired,
allow_partial=False,
)).join_required
step.success_title = 'Query requires join' if join_required else 'No join required'
))
step.stream(join.chain_of_thought)
step.success_title = 'Query requires join' if join.join_required else 'No join required'

if join_required:
if join.join_required:
available_tables = source.get_tables()
with self.interface.add_step(title="Determining tables required for join") as step:
tables = (await self.llm.invoke(
Expand All @@ -583,7 +584,7 @@ async def answer(self, messages: list | str):
response_model=TableJoins,
allow_partial=False,
)).tables
step.stream(f'Join requires following tables: {tables}')
step.stream(f'\nJoin requires following tables: {tables}')
step.success_title = 'Found tables required for join'
else:
tables = [table]
Expand Down
2 changes: 1 addition & 1 deletion lumen/ai/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def download_notebook():

if interface is None:
interface = ChatInterface(
callback=self._chat_invoke, load_buffer=5,
callback=self._chat_invoke, load_buffer=10,
)
else:
interface.callback = self._chat_invoke
Expand Down

0 comments on commit f3e5609

Please sign in to comment.