Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix return type annotation #29

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion promptwizard/glue/common/llm/llm_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions promptwizard/glue/promptopt/instantiate.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
from os.path import dirname, join
import pickle
import time
from typing import Any
from typing import Any, Tuple

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 ..promptopt.constants import PromptOptimizationLiterals
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
Expand Down Expand Up @@ -106,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)
Expand Down Expand Up @@ -154,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.
Expand Down
4 changes: 3 additions & 1 deletion promptwizard/glue/promptopt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down