Skip to content

Commit c1ee593

Browse files
committed
fix: expect dict config
1 parent 1b10301 commit c1ee593

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

app/evaluation.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ def __init__(self, mode='gpt', llama_version='3_1_8B', temperature=0.01, max_new
2121

2222
self.response_num_required = 0 #initialise it with 0
2323

24+
def toDict(self):
25+
return {
26+
"mode": self.mode,
27+
"llama_version": self.llama_version,
28+
"temperature": self.temperature,
29+
"max_new_token": self.max_new_token,
30+
"openai_api_key": self.openai_api_key,
31+
"huggingfacehub_api_token": self.huggingfacehub_api_token,
32+
"endpoint_3_1_8B": self.endpoint_3_1_8B,
33+
"response_num_required": self.response_num_required
34+
}
35+
2436
def setup_llm(config: Config):
2537
"""Initialize the LLM model (GPT-4o or LLaMA 3) based on the given configuration."""
2638
if config.mode == 'gpt':
@@ -79,8 +91,11 @@ def evaluation_function(response, answer, config=None):
7991
start_time = time.process_time()
8092

8193
# Ensure config is provided
82-
config = Config() if (config is None or "mode" not in config) else config
83-
94+
if config is None:
95+
config = Config()
96+
elif type(config) is dict:
97+
config = Config(**config)
98+
8499
# Initialize LLM
85100
llm = setup_llm(config)
86101

0 commit comments

Comments
 (0)