Skip to content

Commit ffa86f7

Browse files
committed
Update dependencies list in and correct comment syntax in
1 parent eef2a29 commit ffa86f7

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

evaluation/evals.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
# dependencies = [
55
# "pandas==2.2.3",
66
# "lighteval==0.10.0",
7-
# "openai==1.83.0"
7+
# "openai==1.83.0",
8+
# "spacy==3.8.7",
9+
# "pip"
10+
#
811
# ]
912
# ///
1013

server/api/services/llm_services.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@
99

1010
import openai
1111

12+
1213
class BaseModelHandler(ABC):
1314
@abstractmethod
1415
def handle_request(
1516
self, query: str, context: str
1617
) -> tuple[str, dict[str, int], dict[str, float], float]:
1718
pass
1819

20+
1921
# LLM Pricing Calculator: https://www.llm-prices.com/
2022
# TODO: Add support for more models and their pricing
2123

2224
# Anthropic Model Pricing: https://docs.anthropic.com/en/docs/about-claude/pricing#model-pricing
2325

26+
2427
class GPT4OMiniHandler(BaseModelHandler):
2528
MODEL = "gpt-4o-mini"
2629
# TODO: Get the latest model pricing from OpenAI's API or documentation
@@ -44,10 +47,7 @@ def handle_request(
4447
start_time = time.time()
4548
# TODO: Add error handling for API requests and invalid responses
4649
response = self.client.responses.create(
47-
model=self.MODEL,
48-
instructions=query,
49-
input=context,
50-
temperature=0.0
50+
model=self.MODEL, instructions=query, input=context, temperature=0.0
5151
)
5252
duration = time.time() - start_time
5353

@@ -67,7 +67,7 @@ class GPT41NanoHandler(BaseModelHandler):
6767

6868
# GPT 4.1 Prompting Guide: https://cookbook.openai.com/examples/gpt4-1_prompting_guide
6969

70-
# Long context performance can degrade as more items are required to be retrieved,
70+
# Long context performance can degrade as more items are required to be retrieved,
7171
# or perform complex reasoning that requires knowledge of the state of the entire context
7272

7373
#
@@ -82,7 +82,7 @@ class GPT41NanoHandler(BaseModelHandler):
8282
8383
# Instructions
8484
85-
- Identify decision points for bipolar medications #TODO: "pharmacological and procedurl interventions"
85+
- Identify decision points for bipolar medications
8686
8787
- For each decision point you find, return a JSON object using the following format:
8888
@@ -92,15 +92,11 @@ class GPT41NanoHandler(BaseModelHandler):
9292
"medications": ["<medication 1>", "<medication 2>", ...],
9393
"reason": "<short explanation for why this criterion applies>",
9494
"sources": ["<ID-X>"]
95-
"hierarchy": Primary: Contraindictions for allergies
96-
"override" Exclude for allergy
9795
}
9896
9997
10098
- Only extract bipolar medication decision points that are explicitly stated or strongly implied in the context and never rely on your own knowledge
10199
102-
- TODO: Test against medication indication file
103-
104100
# Output Format
105101
106102
- Return the extracted bipolar medication decision points as a JSON array and if no decision points are found in the context return an empty array
@@ -145,15 +141,11 @@ def handle_request(
145141
if not query:
146142
query = self.INSTRUCTIONS
147143

148-
149144
start_time = time.time()
150145
# TODO: Add error handling for API requests and invalid responses
151146

152147
response = self.client.responses.create(
153-
model=self.MODEL,
154-
instructions=query,
155-
input=context,
156-
temperature=0.0
148+
model=self.MODEL, instructions=query, input=context, temperature=0.0
157149
)
158150
duration = time.time() - start_time
159151

@@ -166,10 +158,8 @@ def handle_request(
166158

167159

168160
class ModelFactory:
169-
170-
#TODO: Define structured fields to extract from unstructured input data
171-
#https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses&example=structured-data#examples
172-
161+
# TODO: Define structured fields to extract from unstructured input data
162+
# https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses&example=structured-data#examples
173163

174164
HANDLERS = {
175165
"GPT_4O_MINI": GPT4OMiniHandler,

0 commit comments

Comments
 (0)