Skip to content

Commit

Permalink
fix issues pointed by linter and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed Dec 10, 2024
1 parent 8b7726a commit 060956d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/anamnesisai/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

# prompt template for getting the given FHIR resource from the given
# conversation between m.d. and patient.
PROMPT_TEMPLATE = """
You are a FHIR Resource generating expert. Given a conversion
between doctor and patient, first create a syntactically correct
Expand All @@ -24,15 +26,18 @@
Conversation:
```
{query}
{context}
```
""".strip()

# prompt template for checking possible FHIR resources present in the given
# conversation
PROMPT_TEMPLATE_POSSIBLE_RESOURCES = """
please read the following conversation between patient and md doctor:
please read the conversation between patient and md doctor in the given
context:
```
{query}
{context}
```
In the conversation, `D:` means it is from the Doctor, and `P:` means
Expand Down
6 changes: 4 additions & 2 deletions src/anamnesisai/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def check_possible_fhir_resources(
output_max_length=10384, # note: calc this number
structured_output=FHIRResourceFoundModel,
)
result = gen.generate(query=text, context=[])
# the query is already present in the prompt template
result = gen.generate(query="", context=[text])
except Exception as e:
logging.debug(str(e))
return FHIRResourceFoundModel()
Expand Down Expand Up @@ -82,7 +83,8 @@ def extract_fhir(text: str, api_key: str) -> dict[str, Resource]:
output_max_length=10384, # note: calc this number
structured_output=fhir_class,
)
result = gen.generate(query=text, context=[])
# the query is already present in the prompt template
result = gen.generate(query="", context=[text])
except Exception as e:
logging.warning(str(e))
continue
Expand Down

0 comments on commit 060956d

Please sign in to comment.