Skip to content

Commit

Permalink
fix: don't remove previous sources and results in a new round
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Aug 18, 2024
1 parent ec00378 commit 5eff338
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions reasonify-headless/reasonify/core/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,20 @@ async def run_jobs_until_end(self):

@dispatch_context
def pre_process(self, c: Context):
if "sources" not in c:
c["sources"] = []
if "results" not in c:
c["results"] = []

self._queue = QueueWrapper[str]()
self._index = 0
self._index = self._last = len(c["sources"])
self._pure_text = False
self.results = c["results"] = list[dict]()
self.results: list[dict] = c["results"]
self.future = ensure_future(self.run_jobs_until_end())

@dispatch_context
def mid_process(self, c: Context, response: list[str]):
c["sources"] = c.extract_json([])
c["sources"][self._last :] = c.extract_json([])

if self._pure_text:
response[-1] = c.result
Expand All @@ -67,7 +72,7 @@ def mid_process(self, c: Context, response: list[str]):
response.append(c.result)
self._pure_text = True
else:
for source in sources[self._index :]:
for source in sources[self._index - self._last :]:
self._queue.put(source)
self._index += 1

Expand Down
2 changes: 1 addition & 1 deletion reasonify-headless/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.0"
__version__ = "0.1.1"
2 changes: 1 addition & 1 deletion src/lib/components/Chat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
{/if}
<div class="absolute right-0 top-0 flex flex-row translate-x-0.25em select-none items-center text-7xl op-5 -translate-y-2/7">
<span class="font-bold font-fira">&lt;/</span>
<span class="font-fancy">{ctx.index ?? 0}</span>
<span class="font-fancy">{ctx.results?.length ?? 0}</span>
<span class="font-bold font-fira">/&gt;</span>
</div>
</div>
Expand Down

0 comments on commit 5eff338

Please sign in to comment.