levelapp 0.1.0__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.
Potentially problematic release.
This version of levelapp might be problematic. Click here for more details.
- levelapp-0.1.0/.gitignore +207 -0
- levelapp-0.1.0/.python-version +1 -0
- levelapp-0.1.0/LICENSE +0 -0
- levelapp-0.1.0/MANIFEST.in +9 -0
- levelapp-0.1.0/Makefile +20 -0
- levelapp-0.1.0/PKG-INFO +254 -0
- levelapp-0.1.0/README.md +206 -0
- levelapp-0.1.0/examples/example_evaluation.py +0 -0
- levelapp-0.1.0/levelapp/__init__.py +0 -0
- levelapp-0.1.0/levelapp/aspects/__init__.py +8 -0
- levelapp-0.1.0/levelapp/aspects/loader.py +253 -0
- levelapp-0.1.0/levelapp/aspects/logger.py +59 -0
- levelapp-0.1.0/levelapp/aspects/monitor.py +614 -0
- levelapp-0.1.0/levelapp/aspects/sanitizer.py +168 -0
- levelapp-0.1.0/levelapp/clients/__init__.py +119 -0
- levelapp-0.1.0/levelapp/clients/anthropic.py +112 -0
- levelapp-0.1.0/levelapp/clients/ionos.py +116 -0
- levelapp-0.1.0/levelapp/clients/mistral.py +106 -0
- levelapp-0.1.0/levelapp/clients/openai.py +102 -0
- levelapp-0.1.0/levelapp/comparator/__init__.py +5 -0
- levelapp-0.1.0/levelapp/comparator/comparator.py +232 -0
- levelapp-0.1.0/levelapp/comparator/extractor.py +108 -0
- levelapp-0.1.0/levelapp/comparator/schemas.py +61 -0
- levelapp-0.1.0/levelapp/comparator/scorer.py +271 -0
- levelapp-0.1.0/levelapp/comparator/utils.py +136 -0
- levelapp-0.1.0/levelapp/config/__init__.py +5 -0
- levelapp-0.1.0/levelapp/config/endpoint.py +190 -0
- levelapp-0.1.0/levelapp/config/prompts.py +35 -0
- levelapp-0.1.0/levelapp/core/__init__.py +0 -0
- levelapp-0.1.0/levelapp/core/base.py +386 -0
- levelapp-0.1.0/levelapp/core/session.py +214 -0
- levelapp-0.1.0/levelapp/evaluator/__init__.py +3 -0
- levelapp-0.1.0/levelapp/evaluator/evaluator.py +265 -0
- levelapp-0.1.0/levelapp/metrics/__init__.py +67 -0
- levelapp-0.1.0/levelapp/metrics/embedding.py +2 -0
- levelapp-0.1.0/levelapp/metrics/exact.py +182 -0
- levelapp-0.1.0/levelapp/metrics/fuzzy.py +80 -0
- levelapp-0.1.0/levelapp/metrics/token.py +103 -0
- levelapp-0.1.0/levelapp/plugins/__init__.py +0 -0
- levelapp-0.1.0/levelapp/repository/__init__.py +3 -0
- levelapp-0.1.0/levelapp/repository/firestore.py +282 -0
- levelapp-0.1.0/levelapp/simulator/__init__.py +3 -0
- levelapp-0.1.0/levelapp/simulator/schemas.py +89 -0
- levelapp-0.1.0/levelapp/simulator/simulator.py +441 -0
- levelapp-0.1.0/levelapp/simulator/utils.py +201 -0
- levelapp-0.1.0/levelapp/workflow/__init__.py +5 -0
- levelapp-0.1.0/levelapp/workflow/base.py +113 -0
- levelapp-0.1.0/levelapp/workflow/factory.py +51 -0
- levelapp-0.1.0/levelapp/workflow/registration.py +6 -0
- levelapp-0.1.0/levelapp/workflow/schemas.py +121 -0
- levelapp-0.1.0/make.bat +35 -0
- levelapp-0.1.0/project_structure.txt +55 -0
- levelapp-0.1.0/pyproject.toml +63 -0
- levelapp-0.1.0/src/data/conversation_example_1.json +66 -0
- levelapp-0.1.0/src/data/endpoint_configuration.yaml +13 -0
- levelapp-0.1.0/src/data/payload_example_1.yaml +1 -0
- levelapp-0.1.0/src/data/payload_example_2.yaml +6 -0
- levelapp-0.1.0/src/data/workflow_config.yaml +35 -0
- levelapp-0.1.0/src/data/workflow_config_2.json +0 -0
- levelapp-0.1.0/src/level_app/__init__.py +2 -0
- levelapp-0.1.0/src/level_app/main.py +39 -0
- levelapp-0.1.0/src/level_app/main_monitoring.py +50 -0
- levelapp-0.1.0/src/level_app/main_session.py +16 -0
- levelapp-0.1.0/src/level_app/main_simulator.py +108 -0
- levelapp-0.1.0/tests/__init__.py +0 -0
- levelapp-0.1.0/tests/test_anthropic.py +56 -0
- levelapp-0.1.0/tests/test_comparator.py +0 -0
- levelapp-0.1.0/tests/test_ionos.py +67 -0
- levelapp-0.1.0/tests/test_mistral.py +56 -0
- levelapp-0.1.0/tests/test_monitoring.py +196 -0
- levelapp-0.1.0/tests/test_openai.py +56 -0
- levelapp-0.1.0/tests/test_session.py +0 -0
- levelapp-0.1.0/tests/test_simulator.py +0 -0
- levelapp-0.1.0/uv.lock +660 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
levelapp-0.1.0/LICENSE
ADDED
|
File without changes
|
levelapp-0.1.0/Makefile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line, and also
|
|
5
|
+
# from the environment for the first two.
|
|
6
|
+
SPHINXOPTS ?=
|
|
7
|
+
SPHINXBUILD ?= sphinx-build
|
|
8
|
+
SOURCEDIR = source
|
|
9
|
+
BUILDDIR = build
|
|
10
|
+
|
|
11
|
+
# Put it first so that "make" without argument is like "make help".
|
|
12
|
+
help:
|
|
13
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
14
|
+
|
|
15
|
+
.PHONY: help Makefile
|
|
16
|
+
|
|
17
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
18
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
19
|
+
%: Makefile
|
|
20
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
levelapp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: levelapp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: LevelApp is an evaluation framework for AI/LLM-based software application. [Powered by Norma]
|
|
5
|
+
Project-URL: Homepage, https://github.com/levelapp-org
|
|
6
|
+
Project-URL: Repository, https://github.com/levelapp-org/levelapp-framework
|
|
7
|
+
Project-URL: Documentation, https://levelapp.readthedocs.io
|
|
8
|
+
Project-URL: Issues, https://github.com/levelapp-org/levelapp-framework/issues
|
|
9
|
+
Author-email: KadriSof <kadrisofyen@gmail.com>
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,evaluation,framework,llm,testing
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Classifier: Topic :: Software Development :: Testing
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Requires-Dist: arrow>=1.3.0
|
|
21
|
+
Requires-Dist: httpx>=0.28.1
|
|
22
|
+
Requires-Dist: numpy>=2.3.2
|
|
23
|
+
Requires-Dist: openai>=1.99.9
|
|
24
|
+
Requires-Dist: pandas-stubs==2.3.0.250703
|
|
25
|
+
Requires-Dist: pandas>=2.3.1
|
|
26
|
+
Requires-Dist: pydantic>=2.11.7
|
|
27
|
+
Requires-Dist: python-dotenv>=1.1.1
|
|
28
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
29
|
+
Requires-Dist: rapid>=0.0.3
|
|
30
|
+
Requires-Dist: rapidfuzz>=3.13.0
|
|
31
|
+
Requires-Dist: requests>=2.32.4
|
|
32
|
+
Requires-Dist: tenacity>=9.1.2
|
|
33
|
+
Provides-Extra: dev
|
|
34
|
+
Requires-Dist: arrow>=1.3.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: httpx>=0.28.1; extra == 'dev'
|
|
36
|
+
Requires-Dist: numpy>=2.3.2; extra == 'dev'
|
|
37
|
+
Requires-Dist: openai>=1.99.9; extra == 'dev'
|
|
38
|
+
Requires-Dist: pandas-stubs==2.3.0.250703; extra == 'dev'
|
|
39
|
+
Requires-Dist: pandas>=2.3.1; extra == 'dev'
|
|
40
|
+
Requires-Dist: pydantic>=2.11.7; extra == 'dev'
|
|
41
|
+
Requires-Dist: python-dotenv>=1.1.1; extra == 'dev'
|
|
42
|
+
Requires-Dist: pyyaml>=6.0.2; extra == 'dev'
|
|
43
|
+
Requires-Dist: rapid>=0.0.3; extra == 'dev'
|
|
44
|
+
Requires-Dist: rapidfuzz>=3.13.0; extra == 'dev'
|
|
45
|
+
Requires-Dist: requests>=2.32.4; extra == 'dev'
|
|
46
|
+
Requires-Dist: tenacity>=9.1.2; extra == 'dev'
|
|
47
|
+
Description-Content-Type: text/markdown
|
|
48
|
+
|
|
49
|
+
# LevelApp: AI/LLM Evaluation Framework for Regression Testing
|
|
50
|
+
|
|
51
|
+
[](https://badge.fury.io/py/levelapp)
|
|
52
|
+
[](https://opensource.org/licenses/MIT)
|
|
53
|
+
[](https://www.python.org/downloads/)
|
|
54
|
+
|
|
55
|
+
## Overview
|
|
56
|
+
|
|
57
|
+
LevelApp is an evaluation framework designed for regression testing (black-box) of already built LLM-based systems in production or testing phases. It focuses on assessing the performance and reliability of AI/LLM applications through simulation and comparison modules. Powered by Norma.
|
|
58
|
+
|
|
59
|
+
Key benefits:
|
|
60
|
+
- Configuration-driven: Minimal coding required; define evaluations via YAML files.
|
|
61
|
+
- Supports LLM-as-a-judge for qualitative assessments and quantitative metrics for metadata evaluation.
|
|
62
|
+
- Modular architecture for easy extension to new workflows, evaluators, and repositories.
|
|
63
|
+
|
|
64
|
+
## Features
|
|
65
|
+
|
|
66
|
+
- **Simulator Module**: Evaluates dialogue systems by simulating conversations using predefined scripts. It uses an LLM as a judge to score replies against references and supports metrics (e.g., Exact, Embedded, Token-based, Fuzzy) for comparing extracted metadata to ground truth.
|
|
67
|
+
- **Comparator Module**: Evaluates metadata extraction from JSON outputs (e.g., from legal/financial document processing with LLMs) by comparing against reference/ground-truth data.
|
|
68
|
+
- **Configuration-Based Workflow**: Users provide YAML configs for endpoints, parameters, data sources, and metrics, reducing the need for custom code.
|
|
69
|
+
- **Supported Workflows**: SIMULATOR, COMPARATOR, ASSESSOR (coming soon!).
|
|
70
|
+
- **Repositories**: FIRESTORE, FILESYSTEM, MONGODB.
|
|
71
|
+
- **Evaluators**: JUDGE, REFERENCE, RAG.
|
|
72
|
+
- **Metrics**: Exact, Levenshtein, and more (see docs for full list).
|
|
73
|
+
- **Data Sources**: Local or remote JSON for conversation scripts.
|
|
74
|
+
|
|
75
|
+
## Installation
|
|
76
|
+
|
|
77
|
+
Install LevelApp via pip:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install levelapp
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Prerequisites
|
|
84
|
+
- Python 3.12 or higher.
|
|
85
|
+
- API keys for LLM providers (e.g., OpenAI, Anthropic) if using external clients—store in a `.env` file.
|
|
86
|
+
- Optional: Google Cloud credentials for Firestore repository.
|
|
87
|
+
- Dependencies are automatically installed, including `openai`, `pydantic`, `numpy`, etc. (see `pyproject.toml` for full list).
|
|
88
|
+
|
|
89
|
+
## Configuration
|
|
90
|
+
|
|
91
|
+
LevelApp uses a YAML configuration file to define the evaluation setup. Create a `workflow_config.yaml` with the following structure:
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
project_name: "test-project"
|
|
95
|
+
evaluation_params:
|
|
96
|
+
attempts: 1 # Number of simulation attempts.
|
|
97
|
+
|
|
98
|
+
workflow: SIMULATOR # SIMULATOR, COMPARATOR, ASSESSOR.
|
|
99
|
+
repository: FIRESTORE # FIRESTORE, FILESYSTEM, MONGODB.
|
|
100
|
+
evaluators: # JUDGE, REFERENCE, RAG.
|
|
101
|
+
- JUDGE
|
|
102
|
+
- REFERENCE
|
|
103
|
+
|
|
104
|
+
endpoint_configuration:
|
|
105
|
+
base_url: "http://127.0.0.1:8000"
|
|
106
|
+
url_path: ''
|
|
107
|
+
api_key: "<API-KEY>"
|
|
108
|
+
bearer_token: "<BEARER-TOKEN>"
|
|
109
|
+
model_id: "meta-llama/Meta-Llama-3.1-8B-Instruct"
|
|
110
|
+
payload_path: "../../src/data/payload_example_1.yaml"
|
|
111
|
+
default_request_payload_template:
|
|
112
|
+
prompt: "${user_message}"
|
|
113
|
+
details: "${request_payload}" # Rest of the request payload data.
|
|
114
|
+
default_response_payload_template:
|
|
115
|
+
agent_reply: "${agent_reply}"
|
|
116
|
+
guardrail_flag: "${guardrail_flag}"
|
|
117
|
+
generated_metadata: "${generated_metadata}"
|
|
118
|
+
|
|
119
|
+
reference_data:
|
|
120
|
+
source: LOCAL # LOCAL or REMOTE.
|
|
121
|
+
path: "../../src/data/conversation_example_1.json"
|
|
122
|
+
|
|
123
|
+
metrics_map:
|
|
124
|
+
field_1: EXACT
|
|
125
|
+
field_2: LEVENSHTEIN
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- **Endpoint Configuration**: Define how to interact with your LLM-based system (base URL, auth, payload templates).
|
|
129
|
+
- **Placeholders**: For the request payload, change the field names (e.g., 'prompt' to 'message') according to your API specs. For the response payload, change the place holders values (e.g., `${agent_reply}` to `${generated_reply}`).
|
|
130
|
+
- **Secrets**: Store API keys in `.env` and load via `python-dotenv` (e.g., `API_KEY=your_key_here`).
|
|
131
|
+
|
|
132
|
+
For conversation scripts (used in Simulator), provide a JSON file with this schema:
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"id": "1fa6f6ed-3cfe-4c0b-b389-7292f58879d4",
|
|
137
|
+
"scripts": [
|
|
138
|
+
{
|
|
139
|
+
"id": "65f58cec-d55d-4a24-bf16-fa8327a3aa6b",
|
|
140
|
+
"interactions": [
|
|
141
|
+
{
|
|
142
|
+
"id": "e99a2898-6a79-4a20-ac85-dfe977ea9935",
|
|
143
|
+
"user_message": "Hello, I would like to book an appointment with a doctor.",
|
|
144
|
+
"reference_reply": "Sure, I can help with that. Could you please specify the type of doctor you need to see?",
|
|
145
|
+
"interaction_type": "initial",
|
|
146
|
+
"reference_metadata": {},
|
|
147
|
+
"generated_metadata": {},
|
|
148
|
+
"guardrail_flag": false,
|
|
149
|
+
"request_payload": {"user_id": "0001", "user_role": "ADMIN"}
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"id": "fe5c539a-d0a1-40ee-97bd-dbe456703ccc",
|
|
153
|
+
"user_message": "I need to see a cardiologist.",
|
|
154
|
+
"reference_reply": "When would you like to schedule your appointment?",
|
|
155
|
+
"interaction_type": "intermediate",
|
|
156
|
+
"reference_metadata": {},
|
|
157
|
+
"generated_metadata": {},
|
|
158
|
+
"guardrail_flag": false,
|
|
159
|
+
"request_payload": {"user_id": "0001", "user_role": "ADMIN"}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"id": "2cfdbd1c-a065-48bb-9aa9-b958342154b1",
|
|
163
|
+
"user_message": "I would like to book it for next Monday morning.",
|
|
164
|
+
"reference_reply": "We have an available slot at 10 AM next Monday. Does that work for you?",
|
|
165
|
+
"interaction_type": "intermediate",
|
|
166
|
+
"reference_metadata": {
|
|
167
|
+
"appointment_type": "Cardiology",
|
|
168
|
+
"date": "next Monday",
|
|
169
|
+
"time": "10 AM"
|
|
170
|
+
},
|
|
171
|
+
"generated_metadata": {
|
|
172
|
+
"appointment_type": "Cardiology",
|
|
173
|
+
"date": "next Monday",
|
|
174
|
+
"time": "morning"
|
|
175
|
+
},
|
|
176
|
+
"guardrail_flag": false,
|
|
177
|
+
"request_payload": {"user_id": "0001", "user_role": "ADMIN"}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"id": "f4f2dd35-71d7-4b75-ba2b-93a4f546004a",
|
|
181
|
+
"user_message": "Yes, please book it for 10 AM then.",
|
|
182
|
+
"reference_reply": "Your appointment with the cardiologist is booked for 10 AM next Monday. Is there anything else I can help you with?",
|
|
183
|
+
"interaction_type": "final",
|
|
184
|
+
"reference_metadata": {},
|
|
185
|
+
"generated_metadata": {},
|
|
186
|
+
"guardrail_flag": false,
|
|
187
|
+
"request_payload": {"user_id": "0001", "user_role": "ADMIN"}
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
"description": "A conversation about booking a doctor appointment.",
|
|
191
|
+
"details": {
|
|
192
|
+
"context": "Booking a doctor appointment"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
- **Fields**: Include user messages, reference/references replies, metadata for comparison, guardrail flags, and request payloads.
|
|
200
|
+
|
|
201
|
+
## Usage Example
|
|
202
|
+
|
|
203
|
+
To run an evaluation:
|
|
204
|
+
|
|
205
|
+
1. Prepare your YAML config and JSON data files.
|
|
206
|
+
2. Use the following Python script:
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
if __name__ == "__main__":
|
|
210
|
+
from levelapp.workflow.schemas import WorkflowConfig
|
|
211
|
+
from levelapp.core.session import EvaluationSession
|
|
212
|
+
|
|
213
|
+
# Load configuration from YAML
|
|
214
|
+
config = WorkflowConfig.load(path="../data/workflow_config.yaml")
|
|
215
|
+
|
|
216
|
+
# Run evaluation session
|
|
217
|
+
with EvaluationSession(session_name="sim-test", workflow_config=config) as session:
|
|
218
|
+
session.run()
|
|
219
|
+
results = session.workflow.collect_results()
|
|
220
|
+
print("Results:", results)
|
|
221
|
+
|
|
222
|
+
stats = session.get_stats()
|
|
223
|
+
print(f"session stats:\n{stats}")
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
- This loads the config, runs the specified workflow (e.g., Simulator), collects results, and prints stats.
|
|
227
|
+
|
|
228
|
+
For more examples, see the `examples/` directory.
|
|
229
|
+
|
|
230
|
+
## Documentation
|
|
231
|
+
|
|
232
|
+
Detailed docs are in the `docs/` directory, including API references and advanced configuration.
|
|
233
|
+
|
|
234
|
+
## Contributing
|
|
235
|
+
|
|
236
|
+
Contributions are welcome! Please follow these steps:
|
|
237
|
+
- Fork the repository on GitHub.
|
|
238
|
+
- Create a feature branch (`git checkout -b feature/new-feature`).
|
|
239
|
+
- Commit changes (`git commit -am 'Add new feature'`).
|
|
240
|
+
- Push to the branch (`git push origin feature/new-feature`).
|
|
241
|
+
- Open a pull request.
|
|
242
|
+
|
|
243
|
+
Report issues via GitHub Issues. Follow the code of conduct (if applicable).
|
|
244
|
+
|
|
245
|
+
## Acknowledgments
|
|
246
|
+
|
|
247
|
+
- Powered by Norma.
|
|
248
|
+
- Thanks to contributors and open-source libraries like Pydantic, NumPy, and OpenAI SDK.
|
|
249
|
+
|
|
250
|
+
## License
|
|
251
|
+
|
|
252
|
+
This project is licensed under the MIT License - see the [LICENCE](LICENCE) file for details.
|
|
253
|
+
|
|
254
|
+
---
|