Skip to content

Commit

Permalink
fix: can't stop properly because end is accessed before setting
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Nov 9, 2024
1 parent 928f6ed commit ad444c3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions reasonify-headless/reasonify/core/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def _(context: dict):
new_checkpoint(context)


main_loop = Chain(intro, Loop(main := Node(main)))
main_loop = Chain(intro, loop := Loop(main := Node(main)))


@main.callback
Expand Down Expand Up @@ -81,15 +81,19 @@ def mid_process(self, c: Context, response: list[str]):
self._index += 1

@dispatch_context
async def end_process(self, messages: list[Message], end: bool, sources: list):
async def end_process(self):
self._queue.end()
await self.future

if sources:
messages.append(assistant > json(sources))
messages.append(system @ "results" > json(self.results))

if not end:
return # next round
@loop.end_process
@dispatch_context
async def _(messages: list[Message], end: bool, sources: list, results: list[dict]):
if sources:
messages.append(assistant > json(sources))
messages.append(system @ "results" > json(results))

if not end:
return # next round

raise Jump(out_of=main_loop) # already responded or nothing generated
raise Jump(out_of=main_loop) # already responded or nothing generated

1 comment on commit ad444c3

@vercel
Copy link

@vercel vercel bot commented on ad444c3 Nov 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

reasonify – ./

reasonify-promplate.vercel.app
reasonify-git-main-promplate.vercel.app
reasonify.vercel.app

Please sign in to comment.