Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rag/bin/rag-web.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@
const parts=buf.split('\\n\\n'); buf=parts.pop();
for(const p of parts){
const line=p.split('\\n').find(l=>l.startsWith('data:')); if(!line) continue;
const ev=JSON.parse(line.slice(5));
const data=line.slice(5).trim(); if(!data||data==='[DONE]') continue;
const ev=JSON.parse(data);
if(ev.token){text+=ev.token; body.innerHTML=render(text);
ad.scrollIntoView({block:'end'})}
if(ev.error){body.innerHTML+='<div class="err">'+esc(ev.error)+'</div>'}
Expand Down
6 changes: 6 additions & 0 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ def test_page_asks_for_a_key_and_sends_it(web):
assert "res.status===401" in body


def test_page_skips_the_done_sentinel(web):
"""The [DONE] line is not JSON; the page must skip it, not parse it."""
body = get(web.url + "/").read().decode()
assert "data==='[DONE]'" in body


def test_models_endpoint_names_the_rag_model(web):
body = json.load(get(web.url + "/v1/models"))
assert body["data"][0]["id"] == "cpts-notes-rag"
Expand Down
Loading