From eb67e55084131486a097dc77dea31ec7038fd7a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20EK=C4=B0NC=C4=B0?= <211805030@stu.adu.edu.tr> Date: Fri, 3 Jan 2025 23:18:43 +0300 Subject: [PATCH 1/4] remove unused imports --- promptwizard/glue/promptopt/instantiate.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/promptwizard/glue/promptopt/instantiate.py b/promptwizard/glue/promptopt/instantiate.py index 9d2a105..52aefb8 100644 --- a/promptwizard/glue/promptopt/instantiate.py +++ b/promptwizard/glue/promptopt/instantiate.py @@ -3,9 +3,8 @@ import time from typing import Any -from ..common.base_classes import LLMConfig, SetupConfig +from ..common.base_classes import SetupConfig from ..common.constants.log_strings import CommonLogsStr -from ..common.llm.llm_mgr import LLMMgr from ..common.utils.logging import get_glue_logger, set_logging_config from ..common.utils.file import read_jsonl, yaml_to_class, yaml_to_dict, read_jsonl_row from ..paramlogger import ParamLogger From 217db92777c9f0b96df4c13d31f0deb4306e3256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20EK=C4=B0NC=C4=B0?= <211805030@stu.adu.edu.tr> Date: Fri, 3 Jan 2025 23:22:30 +0300 Subject: [PATCH 2/4] correct return type --- promptwizard/glue/promptopt/instantiate.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/promptwizard/glue/promptopt/instantiate.py b/promptwizard/glue/promptopt/instantiate.py index 52aefb8..341101c 100644 --- a/promptwizard/glue/promptopt/instantiate.py +++ b/promptwizard/glue/promptopt/instantiate.py @@ -1,7 +1,7 @@ from os.path import dirname, join import pickle import time -from typing import Any +from typing import Any, Tuple from ..common.base_classes import SetupConfig from ..common.constants.log_strings import CommonLogsStr @@ -12,7 +12,6 @@ from ..promptopt.techniques.common_logic import DatasetSpecificProcessing from ..promptopt.utils import get_promptopt_class - class GluePromptOpt: """ This class is trigger point for any prompt optimization method. Different prompt optimization techniques are @@ -105,7 +104,7 @@ def __init__(self, self.prompt_opt = prompt_opt_cls(training_dataset, base_path, self.setup_config, self.prompt_pool, self.data_processor, self.logger) - def get_best_prompt(self,use_examples=False,run_without_train_examples=False,generate_synthetic_examples=False) -> (str, Any): + def get_best_prompt(self,use_examples=False,run_without_train_examples=False,generate_synthetic_examples=False) -> Tuple[str, Any]: """ Call get_best_prompt() method of class PromptOptimizer & return its value. :return: (best_prompt, expert_profile) @@ -153,7 +152,7 @@ def evaluate(self, test_dataset_jsonl: str) -> float: return total_correct / total_count @iolog.log_io_params - def predict_and_access(self, question: str, gt_answer: str) -> (bool, str, str): + def predict_and_access(self, question: str, gt_answer: str) -> Tuple[bool, str, str]: """ For the given input question, get answer to it from LLM, using the BEST_PROMPT & EXPERT_PROFILE computes earlier. From 29fca6872a3d607606a5514dee63e55c3505968d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20EK=C4=B0NC=C4=B0?= <211805030@stu.adu.edu.tr> Date: Fri, 3 Jan 2025 23:23:44 +0300 Subject: [PATCH 3/4] correct return type --- promptwizard/glue/promptopt/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/promptwizard/glue/promptopt/utils.py b/promptwizard/glue/promptopt/utils.py index 55ab31a..d657be8 100644 --- a/promptwizard/glue/promptopt/utils.py +++ b/promptwizard/glue/promptopt/utils.py @@ -5,8 +5,10 @@ from .techniques.critique_n_refine.base_classes import CritiqueNRefineParams, \ CritiqueNRefinePromptPool +from typing import Tuple -def get_promptopt_class(prompt_technique_name: str) -> (PromptOptimizer, PromptOptimizationParams, PromptPool): + +def get_promptopt_class(prompt_technique_name: str) -> Tuple[PromptOptimizer, PromptOptimizationParams, PromptPool]: """ :params prompt_technique_name: Name of prompt optimization technique :return: Instance of class PromptRefinements, which is super class for all Prompt Optimization classes, From a70d44ca5c335162181095bb892768c8be96b792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20EK=C4=B0NC=C4=B0?= <211805030@stu.adu.edu.tr> Date: Fri, 3 Jan 2025 23:57:23 +0300 Subject: [PATCH 4/4] remove unused imports --- promptwizard/glue/common/llm/llm_mgr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/promptwizard/glue/common/llm/llm_mgr.py b/promptwizard/glue/common/llm/llm_mgr.py index c5cec9c..09fcce5 100644 --- a/promptwizard/glue/common/llm/llm_mgr.py +++ b/promptwizard/glue/common/llm/llm_mgr.py @@ -5,7 +5,7 @@ from tenacity import retry, stop_after_attempt, wait_fixed, wait_random from ..base_classes import LLMConfig from ..constants.str_literals import InstallLibs, OAILiterals, \ - OAILiterals, LLMLiterals, LLMOutputTypes + LLMLiterals, LLMOutputTypes from .llm_helper import get_token_counter from ..exceptions import GlueLLMException from ..utils.runtime_tasks import install_lib_if_missing