-
Notifications
You must be signed in to change notification settings - Fork 6
Fix issues that made long runs fail or hang #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 7 commits
3578d3e
811ad47
7480549
3e17f8d
2de7120
06ab8c5
cc39721
64b9642
4e37f04
df5165a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -293,7 +293,16 @@ def builder_for( | |
| return ChatAnthropic( | ||
| model_name=self.model_name, | ||
| max_tokens_to_sample=opts.tokens, | ||
| timeout=None, | ||
| # An explicit None DISABLES the SDK's timeouts (None != not-given), so a | ||
| # socket that dies silently mid-stream hangs the session forever. A float | ||
| # is a per-phase httpx timeout — for a streamed response, the max silence | ||
| # between chunks, not a cap on the whole turn. | ||
| timeout=300.0, | ||
| # Stream every request: a long authoring turn (Opus + thinking on a large | ||
| # prompt) can exceed the SDK's 600s non-streaming ceiling, and a silent | ||
| # 10-minute wait is long enough for NAT/idle killers to drop the socket | ||
| # (surfaces as APIConnectionError mid-run). Streaming keeps bytes flowing. | ||
| streaming=True, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I happen to know this causes the langgraph api to produce streaming results in its own API. Please double check this doesn't utterly break the TUI and console display handlers, i.e. we aren't streaming chunks that our handlers have no idea what to do with, this somehow opts us out of the complete results, etc. |
||
| max_retries=8, | ||
| stop=None, | ||
| betas=betas, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| from dataclasses import dataclass | ||
| import asyncio | ||
| import logging | ||
| import threading | ||
| from abc import ABC, abstractmethod | ||
| import os | ||
|
|
||
|
|
@@ -20,6 +21,7 @@ | |
|
|
||
| from composer.rag.types import ManualRef, BlockChunk, ManualSectionHit | ||
| from composer.rag.text import code_ref_tag | ||
| from composer.rag.models import ENCODE_LOCK | ||
|
|
||
| import sqlite3 | ||
|
|
||
|
|
@@ -96,19 +98,29 @@ async def get_manual_section(self, headers: list[str]) -> str | None: | |
| ... | ||
|
|
||
|
|
||
| # Encodes race when concurrent (see ENCODE_LOCK in composer.rag.models — the lock | ||
| # is shared with the sync DefaultEmbedder so neither path can race the other). | ||
| def _encode_query_locked(self, query: str) -> ndarray: | ||
| with ENCODE_LOCK: | ||
| return cast(ndarray, self.tr.encode_query(query, show_progress_bar=False)) | ||
|
|
||
| def _encode_docs_locked(self, docs: list[str]) -> list[ndarray]: | ||
| with ENCODE_LOCK: | ||
| return cast(list[ndarray], self.tr.encode_document(docs, show_progress_bar=False)) | ||
|
|
||
| async def embed_query( | ||
| self, query: str | ||
| ) -> ndarray: | ||
| return cast(ndarray, await asyncio.to_thread( | ||
| self.tr.encode_query, f"search_query: {query}", show_progress_bar=False | ||
| )) | ||
| return await asyncio.to_thread( | ||
| self._encode_query_locked, f"search_query: {query}" | ||
| ) | ||
|
|
||
| async def embed_docs( | ||
| self, doc: list[BlockChunk] | ||
| ) -> list[ndarray]: | ||
| return cast(list[ndarray], await asyncio.to_thread( | ||
| self.tr.encode_document, [f"search_document: {d.chunk}" for d in doc], show_progress_bar=False | ||
| )) | ||
| return await asyncio.to_thread( | ||
| self._encode_docs_locked, [f"search_document: {d.chunk}" for d in doc] | ||
| ) | ||
|
Comment on lines
-102
to
+123
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should also be applied to the |
||
|
|
||
| type RagConnection = str | AsyncConnectionPool[AsyncConnection[TupleRow]] | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_normalized_token_usageexists tho?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed, thanks.