ai-model-evaluation-local 0.0.3b5089__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. ai_model_evaluation_local-0.0.3b5089/.env.play1.example +33 -0
  2. ai_model_evaluation_local-0.0.3b5089/.flake8 +2 -0
  3. ai_model_evaluation_local-0.0.3b5089/.logger.json +7 -0
  4. ai_model_evaluation_local-0.0.3b5089/CODEOWNERS +2 -0
  5. ai_model_evaluation_local-0.0.3b5089/PKG-INFO +24 -0
  6. ai_model_evaluation_local-0.0.3b5089/README.md +17 -0
  7. ai_model_evaluation_local-0.0.3b5089/bin/cmd/profile.bat +3 -0
  8. ai_model_evaluation_local-0.0.3b5089/bin/powershell/ExamplePowerShellModule/ExamplePowershellModule.psm1 +0 -0
  9. ai_model_evaluation_local-0.0.3b5089/bin/powershell/profile.ps1 +5 -0
  10. ai_model_evaluation_local-0.0.3b5089/bin/sh/profile.sh +5 -0
  11. ai_model_evaluation_local-0.0.3b5089/pyproject.toml +34 -0
  12. ai_model_evaluation_local-0.0.3b5089/pytest.ini +5 -0
  13. ai_model_evaluation_local-0.0.3b5089/python_packages/ai_model_evaluation_local/__init__.py +0 -0
  14. ai_model_evaluation_local-0.0.3b5089/python_packages/ai_model_evaluation_local/src/__init__.py +0 -0
  15. ai_model_evaluation_local-0.0.3b5089/python_packages/ai_model_evaluation_local/src/evaluation.py +21 -0
  16. ai_model_evaluation_local-0.0.3b5089/python_packages/ai_model_evaluation_local/src/evaluation_scenario.py +12 -0
  17. ai_model_evaluation_local-0.0.3b5089/python_packages/ai_model_evaluation_local/src/scenario_result.py +20 -0
  18. ai_model_evaluation_local-0.0.3b5089/python_packages/ai_model_evaluation_local/tests/__init__.py +0 -0
  19. ai_model_evaluation_local-0.0.3b5089/python_packages/ai_model_evaluation_local/tests/unit/evaluation_unit_test.py +26 -0
  20. ai_model_evaluation_local-0.0.3b5089/python_packages/ai_model_evaluation_local.egg-info/PKG-INFO +24 -0
  21. ai_model_evaluation_local-0.0.3b5089/python_packages/ai_model_evaluation_local.egg-info/SOURCES.txt +25 -0
  22. ai_model_evaluation_local-0.0.3b5089/python_packages/ai_model_evaluation_local.egg-info/dependency_links.txt +1 -0
  23. ai_model_evaluation_local-0.0.3b5089/python_packages/ai_model_evaluation_local.egg-info/top_level.txt +1 -0
  24. ai_model_evaluation_local-0.0.3b5089/requirements-dev.txt +8 -0
  25. ai_model_evaluation_local-0.0.3b5089/requirements.txt +1 -0
  26. ai_model_evaluation_local-0.0.3b5089/setup.cfg +4 -0
  27. ai_model_evaluation_local-0.0.3b5089/setup.py +88 -0
@@ -0,0 +1,33 @@
1
+ # TODO Please add all the environment variables uses in this repo here without any sensative/private information/credentials
2
+
3
+ # This is the .env file for play1 environment in the project directory and not in the root directory
4
+ # Please do not delete/rename this file
5
+
6
+ BRAND_NAME=Circlez
7
+ ENVIRONMENT_NAME=play1
8
+
9
+ # TODO In -local-package we need RDS environment variables, in -remote-package please delete the RDS variables from this file
10
+ RDS_HOSTNAME=db.play1.circ.zone
11
+ # TODO: Please update your RDS_USERNAME and RDS_PASSWORD
12
+ # RDS_USERNAME withour the @circ.zone
13
+ RDS_USERNAME=tal.r
14
+ RDS_PASSWORD=
15
+
16
+ # TODO In -local-package we need JWT_SECRET_KEY environment variables, in -remote-package please delete the JWT_SECRET_KEY variables from this file
17
+ JWT_SECRET_KEY=4rehrkj43h5lkefkdslcw4r
18
+
19
+ LOGZIO_TOKEN=cXNHuVkkffkilnkKzZlWExECRlSKqopE
20
+
21
+ # Needed by the logger-local
22
+ # TODO: Please update you username in the product i.e. tal.r@circ.zone and the password in the product
23
+ PRODUCT_USER_IDENTIFIER=
24
+ PRODUCT_PASSWORD=
25
+
26
+ # AWS (in case of Local you need AWS environment variables, in case of remote AWS environment variables are not needed)
27
+
28
+ AWS_ACCESS_KEY_ID=
29
+ AWS_SECRET_ACCESS_KEY=
30
+
31
+ AWS_DEFAULT_STORAGE_BUCKET_NAME="storage.us-east-1.play1.circ.zone"
32
+
33
+ AWS_DEFAULT_REGION=us-east-1
@@ -0,0 +1,2 @@
1
+ [flake8]
2
+ exclude = lib/
@@ -0,0 +1,7 @@
1
+ {
2
+ "default": {
3
+ "Console": "Info",
4
+ "Datadog": "Warning",
5
+ "MySQLDatabase": "Exception"
6
+ }
7
+ }
@@ -0,0 +1,2 @@
1
+ # TODO: You can add your GitHub user in the end of the line
2
+ * @circles-zone/python-team-lead @talr
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: ai-model-evaluation-local
3
+ Version: 0.0.3b5089
4
+ Summary: PyPI ai-model-evaluation-local Python Package owned by Circlez.ai
5
+ Home-page: https://github.com/circles-zone/ai-model-evaluation-python-local-package
6
+ Author: Circles
7
+ Author-email: info@circlez.ai
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ Dynamic: author
14
+ Dynamic: author-email
15
+ Dynamic: classifier
16
+ Dynamic: description
17
+ Dynamic: description-content-type
18
+ Dynamic: home-page
19
+ Dynamic: license
20
+ Dynamic: requires-python
21
+ Dynamic: summary
22
+
23
+ PyPI ai-model-evaluation-local Python Package owned by Circlez.ai
24
+ GHA: https://github.com/circles-zone/ai-model-evaluation-python-local-package/actions
@@ -0,0 +1,17 @@
1
+ # ai-model-evaluation-python-local-package
2
+
3
+ Deterministic evaluation of a bot or a model: send scenarios, check each reply against an expected pattern.
4
+
5
+ ```python
6
+ from ai_model_evaluation_local.src.evaluation import evaluate_scenarios, get_summary_line
7
+ from ai_model_evaluation_local.src.evaluation_scenario import EvaluationScenario
8
+
9
+ scenarios = [
10
+ EvaluationScenario("runner-token", "sunny", "runner token", r"registration token"),
11
+ EvaluationScenario("chat", "rainy", "Thanks!", None), # no reply is expected
12
+ ]
13
+ scenario_results = evaluate_scenarios(scenarios, get_reply_texts) # get_reply_texts(scenario) -> list[str]
14
+ print(get_summary_line(scenario_results))
15
+ ```
16
+
17
+ Keep the evaluations of a repo in `tests/evals/`.
@@ -0,0 +1,3 @@
1
+ # Profile a Python program (to check and improve its performance).
2
+ rem https://stackoverflow.com/questions/582336/how-do-i-profile-a-python-script
3
+ python -m cProfile %1
@@ -0,0 +1,5 @@
1
+ # Profile a Python program (to check and improve its performance).
2
+ # https://stackoverflow.com/questions/582336/how-do-i-profile-a-python-script
3
+
4
+ python -m cProfile $args[0]
5
+
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+ # Profile a Python program (to check and improve its performance).
3
+ # https://stackoverflow.com/questions/582336/how-do-i-profile-a-python-script
4
+
5
+ python -m cProfile "$1"
@@ -0,0 +1,34 @@
1
+ # This file should be in the future instead of setup.py
2
+ # https://python-poetry.org/docs/pyproject
3
+ # https://stackoverflow.com/questions/78048223/adding-folder-with-data-with-pyproject-toml
4
+ # https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license
5
+
6
+ # This file is mandatory for the `poetry version patch`
7
+
8
+ # It seems we need to copy this file also to serverless-com repo, as required by dialog-workflow-python-package
9
+
10
+ [build-system]
11
+ # "setuptools_scm>=6.2" is required for writing the version in my_package/_version.py and may be also for "poetry version patch" to work
12
+ requires = ["setuptools>=61.0", "setuptools_scm>=6.2"]
13
+ build-backend = "setuptools.build_meta"
14
+
15
+ [tool.setuptools_scm]
16
+ write_to = "python_packages/ai_model_evaluation_local/_version.py"
17
+
18
+ [tool.pytest.ini_options]
19
+ pythonpath = ["."]
20
+
21
+ [tool.poetry]
22
+ name = "ai-model-evaluation-local"
23
+ # TODO After the b (beta), you should add the Jira Work Item ID (was generated by Jira). If you run sdk-local Makec.ps1 it should do it for you.
24
+ # I believe we are still using the version from setup.py and not from here until Potery will work
25
+ version = "0.0.3b5089" # https://pypi.org/project/ai-model-evaluation-local/
26
+ description = "ai-model-evaluation-local Python Package"
27
+ readme = "README.md"
28
+ authors = [
29
+ "Circlez.ai <info@circlez.ai>",
30
+ ]
31
+
32
+ [tool.poetry.dev-dependencies]
33
+ pytest = "^8.0"
34
+ pytest-cov = "^5.0"
@@ -0,0 +1,5 @@
1
+ [pytest]
2
+ ; Makec -MaxFail (default 1) writes it (BU-4225)
3
+ addopts = --maxfail=1
4
+ testpaths = python_packages/ai_model_evaluation_local/tests
5
+ pythonpath = python_packages
@@ -0,0 +1,21 @@
1
+ from collections.abc import Callable
2
+
3
+ from .evaluation_scenario import EvaluationScenario
4
+ from .scenario_result import ScenarioResult
5
+
6
+
7
+ def evaluate_scenarios(scenarios: list[EvaluationScenario],
8
+ get_reply_texts: Callable[[EvaluationScenario], list[str]]) -> list[ScenarioResult]:
9
+ """get_reply_texts sends the scenario to the evaluated system and returns its replies"""
10
+ scenario_results = [ScenarioResult(scenario, get_reply_texts(scenario)) for scenario in scenarios]
11
+ return scenario_results
12
+
13
+
14
+ def get_summary_line(scenario_results: list[ScenarioResult]) -> str:
15
+ failed_scenarios = [f"{scenario_result.scenario.name} {scenario_result.scenario.weather}"
16
+ for scenario_result in scenario_results if not scenario_result.is_pass]
17
+ number_of_passes = len(scenario_results) - len(failed_scenarios)
18
+ summary_line = f"{number_of_passes} PASS, {len(failed_scenarios)} FAIL"
19
+ if failed_scenarios:
20
+ summary_line += " (" + ", ".join(failed_scenarios) + ")"
21
+ return summary_line
@@ -0,0 +1,12 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass(frozen=True)
5
+ class EvaluationScenario:
6
+ name: str
7
+ # sunny: the user does what is expected; rainy: a mistake that must be answered (or ignored) correctly
8
+ weather: str
9
+ # What is sent to the evaluated system: a prompt, a Slack message ...
10
+ text: str
11
+ # A reply must match it; None: there must be no reply (a correct rejection is a PASS)
12
+ expected_reply_pattern: str | None
@@ -0,0 +1,20 @@
1
+ import re
2
+ from dataclasses import dataclass
3
+
4
+ from .evaluation_scenario import EvaluationScenario
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class ScenarioResult:
9
+ scenario: EvaluationScenario
10
+ reply_texts: list[str]
11
+
12
+ @property
13
+ def is_pass(self) -> bool:
14
+ """Deterministic: the same replies always get the same result"""
15
+ expected_reply_pattern = self.scenario.expected_reply_pattern
16
+ if expected_reply_pattern is None:
17
+ is_pass_result = not self.reply_texts
18
+ else:
19
+ is_pass_result = any(re.search(expected_reply_pattern, reply_text) for reply_text in self.reply_texts)
20
+ return is_pass_result
@@ -0,0 +1,26 @@
1
+ import pytest
2
+
3
+ from ai_model_evaluation_local.src.evaluation import evaluate_scenarios, get_summary_line
4
+ from ai_model_evaluation_local.src.evaluation_scenario import EvaluationScenario
5
+ from ai_model_evaluation_local.src.scenario_result import ScenarioResult
6
+
7
+ SUNNY_SCENARIO = EvaluationScenario("runner-token", "sunny", "runner token", r"registration token")
8
+ IGNORED_SCENARIO = EvaluationScenario("chat", "rainy", "Thanks!", None)
9
+
10
+
11
+ @pytest.mark.parametrize("scenario, reply_texts, is_expected_pass", [
12
+ (SUNNY_SCENARIO, ["Hi", "Your registration token: X"], True),
13
+ (SUNNY_SCENARIO, ["I don't understand"], False),
14
+ (SUNNY_SCENARIO, [], False),
15
+ (IGNORED_SCENARIO, [], True),
16
+ (IGNORED_SCENARIO, ["Missing Summary"], False),
17
+ ])
18
+ def test_is_pass(scenario: EvaluationScenario, reply_texts: list[str], is_expected_pass: bool) -> None:
19
+ assert ScenarioResult(scenario, reply_texts).is_pass is is_expected_pass
20
+
21
+
22
+ def test_evaluate_scenarios_and_summary_line() -> None:
23
+ replies = {"runner token": ["Your registration token: X"], "Thanks!": ["Missing Summary"]}
24
+ scenario_results = evaluate_scenarios([SUNNY_SCENARIO, IGNORED_SCENARIO], lambda scenario: replies[scenario.text])
25
+ assert get_summary_line(scenario_results) == "1 PASS, 1 FAIL (chat rainy)"
26
+ assert get_summary_line(scenario_results[:1]) == "1 PASS, 0 FAIL"
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: ai-model-evaluation-local
3
+ Version: 0.0.3b5089
4
+ Summary: PyPI ai-model-evaluation-local Python Package owned by Circlez.ai
5
+ Home-page: https://github.com/circles-zone/ai-model-evaluation-python-local-package
6
+ Author: Circles
7
+ Author-email: info@circlez.ai
8
+ License: MIT
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ Dynamic: author
14
+ Dynamic: author-email
15
+ Dynamic: classifier
16
+ Dynamic: description
17
+ Dynamic: description-content-type
18
+ Dynamic: home-page
19
+ Dynamic: license
20
+ Dynamic: requires-python
21
+ Dynamic: summary
22
+
23
+ PyPI ai-model-evaluation-local Python Package owned by Circlez.ai
24
+ GHA: https://github.com/circles-zone/ai-model-evaluation-python-local-package/actions
@@ -0,0 +1,25 @@
1
+ .env.play1.example
2
+ .flake8
3
+ .logger.json
4
+ CODEOWNERS
5
+ README.md
6
+ pyproject.toml
7
+ pytest.ini
8
+ requirements-dev.txt
9
+ requirements.txt
10
+ setup.py
11
+ bin/cmd/profile.bat
12
+ bin/powershell/profile.ps1
13
+ bin/powershell/ExamplePowerShellModule/ExamplePowershellModule.psm1
14
+ bin/sh/profile.sh
15
+ python_packages/ai_model_evaluation_local/__init__.py
16
+ python_packages/ai_model_evaluation_local.egg-info/PKG-INFO
17
+ python_packages/ai_model_evaluation_local.egg-info/SOURCES.txt
18
+ python_packages/ai_model_evaluation_local.egg-info/dependency_links.txt
19
+ python_packages/ai_model_evaluation_local.egg-info/top_level.txt
20
+ python_packages/ai_model_evaluation_local/src/__init__.py
21
+ python_packages/ai_model_evaluation_local/src/evaluation.py
22
+ python_packages/ai_model_evaluation_local/src/evaluation_scenario.py
23
+ python_packages/ai_model_evaluation_local/src/scenario_result.py
24
+ python_packages/ai_model_evaluation_local/tests/__init__.py
25
+ python_packages/ai_model_evaluation_local/tests/unit/evaluation_unit_test.py
@@ -0,0 +1,8 @@
1
+ # Requirements for Tests/Testing (Do not add to setup.py install_requires)
2
+ pytest # https://pypi.org/project/pytest/
3
+ pytest-cov # This is used by MakePy.ps1 pytest to simulate the tests running in GHA and save us time and money
4
+ # TODO When do we use this? - I think we are not using it in all packages
5
+ # pytest-mock
6
+
7
+ # TODO Do we need this in all packages?
8
+ # pycallgraph2
@@ -0,0 +1 @@
1
+ # Runtime packages, as in setup.py install_requires (none)
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,88 @@
1
+ # serverless.com repo "python -m build" works without setup.py
2
+ # Should update package_dir if not using our recommended directory structure
3
+
4
+ import setuptools
5
+
6
+ # For reading the version my_package/_version.py or my_package/__init__.py
7
+
8
+ import codecs
9
+ import os
10
+
11
+
12
+ def read(rel_path):
13
+ here = os.path.abspath(os.path.dirname(__file__))
14
+ with codecs.open(os.path.join(here, rel_path), 'r') as fp:
15
+ return fp.read()
16
+
17
+
18
+ def get_version(rel_path):
19
+ for line in read(rel_path).splitlines():
20
+ if line.startswith('__version__'):
21
+ return line.split('"')[1] # או "'" בהתאם לשימוש
22
+ raise RuntimeError("Unable to find version string.")
23
+
24
+
25
+ # TODO: Change the PACKAGE_NAME to the package's name - Either xxx-local or
26
+ # xxx-remote (without the -python-package suffix). Only lowercase, no
27
+ # underlines.
28
+ # Used by pypa/gh-action-pypi-publish
29
+ # Package Name should be identical to the inner directory name
30
+ # Changing the package name here, will cause a change in the package directory
31
+ # name as well
32
+ # PACKAGE_NAME should be singular if handling only one instance
33
+ # PACKAGE_NAME should not include the word "main"
34
+
35
+ # e.g.: queue-local, without python-package suffix
36
+ PACKAGE_NAME = "ai-model-evaluation-local"
37
+
38
+ package_dir = PACKAGE_NAME.replace("-", "_")
39
+ # If we need backward-compatible:
40
+ # old_package_dir = "old_package_name"
41
+
42
+ PACKAGE_DESCRIPTION = f"PyPI {PACKAGE_NAME} Python Package owned by Circlez.ai"
43
+
44
+ setuptools.setup(
45
+ # TODO license was added using Makec? If not, update VerticalChangesPySetupPy to call a function in python-sdk-remote Setup.psm1 to add it
46
+ license='MIT',
47
+ python_requires='>=3.10',
48
+ name=PACKAGE_NAME,
49
+ # Increase this number every time you make a change
50
+ # want to publish. After 0.0.9 switch to 0.0.10 and not 0.1.0
51
+ # version can't be 0.0.
52
+ # If you find yourself increasing the version in more than one patch number (it might indicate there are multiple branches, which you should submit their PRs before your PR) # noqa: E501
53
+ # Updating the b<Jira Work Item ID> done automatically by makec.ps1 / make_py.ps1
54
+ # TODO add the Jira Work Item (Jira Issue) number after the version, i.e., 0.0.1b2432
55
+ # TODO: According to GitFlow, in the Feature Branch, please update after the letter 'b' the Jira Work Item ID, and in the exceptional case you can't get a Jira Work Item directly or using the Slack Channel, please use the PR number. Semantic Version simver.org
56
+ version="0.0.3b5089", # https://pypi.org/project/ai-model-evaluation-local#History
57
+ author="Circles",
58
+ author_email="info@circlez.ai",
59
+ description=f"{PACKAGE_DESCRIPTION}",
60
+ long_description=f"{PACKAGE_DESCRIPTION} \nGHA: https://github.com/circles-zone/ai-model-evaluation-python-local-package/actions",
61
+ long_description_content_type='text/markdown',
62
+ url="https://github.com/circles-zone/ai-model-evaluation-python-local-package",
63
+ # packages=[package_dir],
64
+ # packages=[package_dir, old_package_dir],
65
+ packages=setuptools.find_packages(where="python_packages", exclude=["*.tests", "*.tests.*"]),
66
+ package_dir={"": "python_packages"},
67
+
68
+ # I'm not sure we need package_dir
69
+ # package_dir={package_dir: f'{package_dir}/src'},
70
+ # TODO Unfortunately in event-main-local-restapi there are no
71
+ # repo-directory and no package directory (flat directory structure)
72
+ # package_dir={package_dir: f'src'},
73
+
74
+ # package_dir={package_dir: f'{package_dir}/src',
75
+ # old_package_dir: f'{package_dir}/src'},
76
+ classifiers=[
77
+ "Programming Language :: Python :: 3",
78
+ # https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license
79
+ # TODO Fix all repos, especially the Python templates
80
+ #
81
+ "Operating System :: OS Independent",
82
+ ],
83
+ # Do not add packages needed only for tests, i.e., packages for get_test_xxx(
84
+ # TODO: Update which packages to include with this package in production
85
+ # (dependencies) - Not for development/testing
86
+ install_requires=[]
87
+ )
88
+