From 8736e166b51c0a5f76487adfdb694d1c88233ee6 Mon Sep 17 00:00:00 2001 From: Eric <64810940+BeG04T@users.noreply.github.com> Date: Sat, 4 Apr 2026 21:18:32 -0400 Subject: [PATCH] Added variable checking Variable checking is one of the ideas we had for reducing queries to the LLM. the new function now has an additional parameter of dependencies will no longer be queried for versions and instead be added to the loop: teh code will instead loop through every candidate version for those dependencies similar to the way it checks for python versions --- tools/pllm/helpers/ollama_helper_tester.py | 51 +++++++++++++--------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/tools/pllm/helpers/ollama_helper_tester.py b/tools/pllm/helpers/ollama_helper_tester.py index 7b981747..ef3ea171 100644 --- a/tools/pllm/helpers/ollama_helper_tester.py +++ b/tools/pllm/helpers/ollama_helper_tester.py @@ -80,13 +80,14 @@ def get_module_specifics(self, llm_eval): # Also returns an updated python version, based on what the model had provided llm_eval['python_modules'], llm_eval['python_version'] = self.pypi.get_module_specifics(llm_eval) - module_versions = self.get_module_versions(llm_eval) + module_versions = self.get_module_versions(llm_eval, []) llm_eval['python_modules'] = module_versions return llm_eval # Loops through the modules and request a version for each - def get_module_versions(self, details): + def get_module_versions(self, details, excludedMs): + # Added excludedMs, it should be a dictionary with the modules as a key and the version limits as their values. modules = details['python_modules'] if len(modules) <= 0: @@ -104,25 +105,33 @@ def get_module_versions(self, details): while not completed: try: for idx, module in enumerate(modules): - versions = self.read_python_file(f"{self.base_modules}/{module}_{details['python_version']}.txt") - - tp = "Infer a possible working version of the '{module}' module for Python {python_version}.\nReturn the information with the format {format_instructions}" - pv = {"version_details": versions, "module": module, "python_version": details['python_version'], "format_instructions": parser.get_format_instructions()} - if self.rag: - tp = "Given a comma separated list of '{version_details}', for the '{module}' module, from oldest to newest.\nSelect a recent version for us to use that isn't previously used: 'Previously used: {previous}, and return the information with the format {format_instructions}" - pv = {"version_details": versions, "module": module, "previous": [], "format_instructions": parser.get_format_instructions()} - - prompt = PromptTemplate( - template=tp, - input_variables=[], - partial_variables=pv - ) - - chain = prompt | self.model | parser - - out = chain.invoke({}) - - updated_modules[out['module']] = out['version'].split(' ')[0] + if module not in excludedMs: + versions = self.read_python_file(f"{self.base_modules}/{module}_{details['python_version']}.txt") + + pv = {"version_details": versions, "module": module, "python_version": details['python_version'], "format_instructions": parser.get_format_instructions()} + tp = "Infer a possible working version of the '{module}' module for Python {python_version}" + if len(excludedMs) > 0: + tp += ", ensure it is compatible with the following Python Module versions: " + for exmod in excludedMs: + modstring = exmod + ": " + str(excludedMs[exmod]) + tp+= modstring + tp += ".\nReturn the information with the format {format_instructions}" + + if self.rag: + tp = "Given a comma separated list of '{version_details}', for the '{module}' module, from oldest to newest.\nSelect a recent version for us to use that isn't previously used: 'Previously used: {previous}, and return the information with the format {format_instructions}" + pv = {"version_details": versions, "module": module, "previous": [], "format_instructions": parser.get_format_instructions()} + + prompt = PromptTemplate( + template=tp, + input_variables=[], + partial_variables=pv + ) + + chain = prompt | self.model | parser + + out = chain.invoke({}) + + updated_modules[out['module']] = out['version'].split(' ')[0] completed = True except Exception as e: completed = False