Skip to content

Commit 61b4d5d

Browse files
Merge pull request #1233 from PacificAI/fix/vulnerabilities-and-security-issues
Fix/vulnerabilities and security issues
2 parents a85f122 + 8c27241 commit 61b4d5d

30 files changed

Lines changed: 5376 additions & 5256 deletions

.github/workflows/build_and_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
python-version: [ "3.9","3.10", "3.11" ]
20+
python-version: ["3.12", "3.13" ]
2121

2222
steps:
2323
- name: Free up disk space at start
@@ -53,7 +53,7 @@ jobs:
5353
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
5454
run: |
5555
poetry cache clear pypi --all -n > /dev/null
56-
poetry install --with dev --all-extras --no-cache --quiet --no-interaction
56+
poetry install --with dev --all-extras --no-cache --no-interaction
5757
source ./.venv/bin/activate && pip uninstall -y pyspark && rm -rf ./.venv/lib/python${{ matrix.python-version }}/site-packages/pyspark*/
5858
pip install pyspark==3.5.6
5959

.github/workflows/llm_tests_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
python-version: [ "3.8", "3.9", "3.10" ]
13+
python-version: [ "3.12", "3.13" ]
1414

1515
steps:
1616
- uses: actions/checkout@v3

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
python-version: [3.9]
12+
python-version: [3.12]
1313
poetry-version: [2.1.3]
1414
os: [ubuntu-latest]
1515
runs-on: ${{ matrix.os }}

langtest/datahandler/datasource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ def load_raw_data(self, standardize_columns: bool = False) -> List[Dict]:
808808
parsed CSV file into list of dicts
809809
"""
810810

811-
if type(self._file_path) == dict:
811+
if isinstance(self._file_path, dict):
812812
df = pd.read_csv(self._file_path["data_source"])
813813

814814
if self.task == "text-classification":

langtest/langtest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def configure(self, config: Union[HarnessConfig, dict, str]) -> HarnessConfig:
286286
Returns:
287287
dict: Loaded configuration.
288288
"""
289-
if type(config) == dict:
289+
if isinstance(config, dict):
290290
self._config = config
291291
else:
292292
with open(config, "r", encoding="utf-8") as yml:

langtest/metrics/llm_eval.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,22 @@ def build_prompt(
6666
f"""\n\nScore the student answer based on the following criteria:\n{eval_criteria}"""
6767
)
6868

69-
prompt += dedent(
70-
f"""
71-
Example Format:
72-
QUESTION: question here
73-
STUDENT ANSWER: student's answer here
74-
TRUE ANSWER: true answer here
75-
GRADE: {grade_list} here
76-
77-
{
78-
("Grade the student answers based ONLY on their factual accuracy. Ignore differences"
79-
" in punctuation and phrasing between the student answer and true answer. It is OK "
80-
"if the student answer contains more or relevant information than the true answer, as"
81-
" long as it does not contain any conflicting statements. Begin!")
82-
}
83-
84-
QUESTION: {{query}}
85-
STUDENT ANSWER: {{result}}
86-
TRUE ANSWER: {{answer}}
87-
GRADE:"""
69+
prompt += (
70+
"Example Format:\n"
71+
"QUESTION: question here\n"
72+
"STUDENT ANSWER: student's answer here\n"
73+
"TRUE ANSWER: true answer here\n"
74+
f"GRADE: {grade_list} here"
75+
"\n\n"
76+
"Grade the student answers based ONLY on their factual accuracy. Ignore differences"
77+
" in punctuation and phrasing between the student answer and true answer. It is OK "
78+
"if the student answer contains more or relevant information than the true answer, as"
79+
" long as it does not contain any conflicting statements. Begin!"
80+
"\n\n"
81+
"QUESTION: {{query}}\n"
82+
"STUDENT ANSWER: {{result}}\n"
83+
"TRUE ANSWER: {{answer}}\n"
84+
"GRADE:\n"
8885
)
8986
return prompt
9087

langtest/modelhandler/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333

3434

3535
if "langchain" in INSTALLED_HUBS:
36-
import langchain
36+
import langchain_classic
3737

3838
LANGCHAIN_HUBS = {
3939
(
4040
RENAME_HUBS.get(hub.lower(), hub.lower())
4141
if hub.lower() in RENAME_HUBS
4242
else hub.lower()
4343
): hub
44-
for hub in langchain.llms.__all__
44+
for hub in langchain_classic.llms.__all__
4545
}
4646
LANGCHAIN_HUBS["openrouter"] = "openrouter"
4747

langtest/modelhandler/llm_modelhandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
import os
55
from typing import Any, List, Type, Union, TypeVar
6-
import langchain.llms as lc
6+
import langchain_classic.llms as lc
77
import langchain.chat_models as chat_models
8-
from langchain.chains.llm import LLMChain
8+
from langchain_classic.chains.llm import LLMChain
99
from langchain_core.prompts import PromptTemplate
1010
from langchain_core.language_models.base import BaseLanguageModel
1111
from langchain_core.exceptions import OutputParserException

langtest/modelhandler/modelhandler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
}
1515

1616
if try_import_lib("langchain"):
17-
import langchain
18-
import langchain.llms
17+
import langchain_classic
18+
import langchain_classic.llms
1919

2020
LANGCHAIN_HUBS = {
2121
(
2222
RENAME_HUBS.get(hub.lower(), hub.lower())
2323
if hub.lower() in RENAME_HUBS
2424
else hub.lower()
2525
): hub
26-
for hub in langchain.llms.__all__
26+
for hub in langchain_classic.llms.__all__
2727
}
2828
LANGCHAIN_HUBS["openrouter"] = "openrouter"
2929
else:

langtest/transform/accuracy.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ class BaseAccuracy(ABC):
276276

277277
TestConfig = TypedDict(
278278
"TestConfig",
279-
min_score=Union[Dict[str, float], float],
279+
# min_score=Union[Dict[str, float], float],
280+
{"min_score": Union[Dict[str, float], float]},
280281
)
281282

282283
@classmethod
@@ -1029,9 +1030,15 @@ class LLMEval(BaseAccuracy):
10291030

10301031
TestConfig = TypedDict(
10311032
"TestConfig",
1032-
model=str,
1033-
hub=str,
1034-
min_score=float,
1033+
# model=str,
1034+
# hub=str,
1035+
# min_score=float,
1036+
{
1037+
"model": str,
1038+
"hub": str,
1039+
"model_parameters": dict,
1040+
"min_score": float,
1041+
},
10351042
)
10361043

10371044
@classmethod

0 commit comments

Comments
 (0)