Spaces:
Sleeping
Sleeping
File size: 559 Bytes
e23acaf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import json
from src.llm.llm_factory import get_llm
class StructureExtractor:
def __init__(self):
self.llm = get_llm()
def extract(self, query):
prompt = f"""
Extract the anatomical structure names that should be highlighted.
Return ONLY valid JSON in this format:
{{
"structures": ["structure1", "structure2"]
}}
Query: {query}
"""
response = self.llm.invoke(prompt)
try:
data = json.loads(response.content)
return data["structures"]
except Exception:
return []
|