Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions docs/pipes/llm/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ to perform various information extraction tasks.
| Component | Description |
|----------------------------|-----------------------------------------------------------|
| `eds.llm_markup_extractor` | Extract structured information using LLMs through markup. |
| `eds.llm_span_qualifier` | Predict attributes of spans using LLMs. |

<!-- --8<-- [end:components] -->
8 changes: 8 additions & 0 deletions docs/pipes/llm/llm-span-qualifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# LLM Span Qualifier {: #edsnlp.pipes.llm.llm_span_qualifier.factory.create_component }

::: edsnlp.pipes.llm.llm_span_qualifier.factory.create_component
options:
heading_level: 3
show_bases: false
show_source: false
only_class_level: true
3 changes: 2 additions & 1 deletion edsnlp/pipes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@
from .trainable.embeddings.text_cnn.factory import create_component as text_cnn
from .misc.split import Split as split
from .misc.explode import Explode as explode
from .llm.llm_markup_extractor import LlmMarkupExtractor as llm_markup_extractor
from .llm.llm_markup_extractor.factory import create_component as llm_markup_extractor
from .llm.llm_span_qualifier.factory import create_component as llm_span_qualifier
6 changes: 4 additions & 2 deletions edsnlp/pipes/llm/async_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ def instance(cls) -> "AsyncRequestWorker":
cls._instance = AsyncRequestWorker()
return cls._instance

def submit(self, coro: Coroutine[Any, Any, Any]) -> int:
def submit(
self, coro: Coroutine[Any, Any, Any], timeout: Optional[float] = None
) -> int:
with self._lock:
task_id = self._next_id
self._next_id += 1

async def _wrap():
try:
res = await coro
res = await asyncio.wait_for(coro, timeout=timeout)
exc = None
except BaseException as e: # noqa: BLE001
res = None
Expand Down
1 change: 1 addition & 0 deletions edsnlp/pipes/llm/llm_span_qualifier/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .llm_span_qualifier import LlmSpanQualifier
8 changes: 8 additions & 0 deletions edsnlp/pipes/llm/llm_span_qualifier/factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from edsnlp import registry

from .llm_span_qualifier import LlmSpanQualifier

create_component = registry.factory.register(
"eds.llm_span_qualifier",
assigns=["doc.ents", "doc.spans"],
)(LlmSpanQualifier)
Loading
Loading