levelapp 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl

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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: levelapp
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: LevelApp is an evaluation framework for AI/LLM-based software application. [Powered by Norma]
5
5
  Project-URL: Homepage, https://github.com/levelapp-org
6
6
  Project-URL: Repository, https://github.com/levelapp-org/levelapp-framework
@@ -114,23 +114,54 @@ evaluation:
114
114
  field_2 : LEVENSHTEIN
115
115
 
116
116
  reference_data:
117
- path:
117
+ path: "../data/conversation_example_1.json"
118
118
  data:
119
119
 
120
120
  endpoint:
121
- base_url: "http://127.0.0.1:8000"
122
- url_path: ''
123
- api_key: "<API-KEY>"
124
- bearer_token: "<BEARER-TOKEN>"
125
- model_id: "meta-llama/Meta-Llama-3.1-8B-Instruct"
126
- default_request_payload_template:
127
- # Change the user message field name only according to the request payload schema (example: 'prompt' to 'message').
128
- prompt: "${user_message}"
129
- details: "${request_payload}" # Rest of the request payload data.
130
- default_response_payload_template:
131
- # Change the placeholder value only according to the response payload schema (example: ${agent_reply} to ${reply}).
132
- agent_reply: "${agent_reply}"
133
- generated_metadata: "${generated_metadata}"
121
+ name: conversational-agent
122
+ base_url: http://127.0.0.1:8000
123
+ path: /v1/chat
124
+ method: POST
125
+ timeout: 60
126
+ retry_count: 3
127
+ retry_backoff: 0.5
128
+ headers:
129
+ - name: model_id
130
+ value: meta-llama/Meta-Llama-3-8B-Instruct
131
+ secure: false
132
+ - name: x-api-key
133
+ value: API_KEY # Load from .env file using python-dotenv.
134
+ secure: true
135
+ - name: Content-Type
136
+ value: application/json
137
+ secure: false
138
+ request_schema:
139
+ # Static field to be included in every request.
140
+ - field_path: message.source
141
+ value: system
142
+ value_type: static
143
+ required: true
144
+
145
+ # Dynamic field to be populated from runtime context.
146
+ - field_path: message.text
147
+ value: message_text # the key from the runtime context.
148
+ value_type: dynamic
149
+ required: true
150
+
151
+ # Env-based field (from OS environment variables).
152
+ - field_path: metadata.env
153
+ value: ENV_VAR_NAME
154
+ value_type: env
155
+ required: false
156
+
157
+ response_mapping:
158
+ # Map the response fields that will be extracted.
159
+ - field_path: reply.text
160
+ extract_as: agent_reply # The simulator requires this key: 'agent_reply'.
161
+ - field_path: reply.metadata
162
+ extract_as: generated_metadata # The simulator requires this key: 'generated_metadata'.
163
+ - field_path: reply.guardrail_flag
164
+ extract_as: guardrail_flag # The simulator requires this key: 'guardrail_flag'.
134
165
 
135
166
  repository:
136
167
  type: FIRESTORE # Pick one of the following: FIRESTORE, FILESYSTEM
@@ -138,8 +169,8 @@ repository:
138
169
  database_name: ""
139
170
  ```
140
171
 
141
- - **Endpoint Configuration**: Define how to interact with your LLM-based system (base URL, auth, payload templates).
142
- - **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}`).
172
+ - **Endpoint Configuration**: Define how to interact with your LLM-based system (base URL, headers, request/response payload schema).
173
+ - **Placeholders**: For dynamic request schema fields, use the values ('value') to dynamically populate these fields during runtime (e.g., `context = {'message_text': "Hello, world!"}`).
143
174
  - **Secrets**: Store API keys in `.env` and load via `python-dotenv` (e.g., `API_KEY=your_key_here`).
144
175
 
145
176
  For conversation scripts (used in Simulator), provide a JSON file with this schema:
@@ -154,16 +185,14 @@ For conversation scripts (used in Simulator), provide a JSON file with this sche
154
185
  "reference_reply": "Sure, I can help with that. Could you please specify the type of doctor you need to see?",
155
186
  "interaction_type": "initial",
156
187
  "reference_metadata": {},
157
- "guardrail_flag": false,
158
- "request_payload": {"user_id": "0001", "user_role": "ADMIN"}
188
+ "guardrail_flag": false
159
189
  },
160
190
  {
161
191
  "user_message": "I need to see a cardiologist.",
162
192
  "reference_reply": "When would you like to schedule your appointment?",
163
193
  "interaction_type": "intermediate",
164
194
  "reference_metadata": {},
165
- "guardrail_flag": false,
166
- "request_payload": {"user_id": "0001", "user_role": "ADMIN"}
195
+ "guardrail_flag": false
167
196
  },
168
197
  {
169
198
  "user_message": "I would like to book it for next Monday morning.",
@@ -174,8 +203,7 @@ For conversation scripts (used in Simulator), provide a JSON file with this sche
174
203
  "date": "next Monday",
175
204
  "time": "10 AM"
176
205
  },
177
- "guardrail_flag": false,
178
- "request_payload": {"user_id": "0001", "user_role": "ADMIN"}
206
+ "guardrail_flag": false
179
207
  },
180
208
  {
181
209
  "id": "f4f2dd35-71d7-4b75-ba2b-93a4f546004a",
@@ -183,8 +211,7 @@ For conversation scripts (used in Simulator), provide a JSON file with this sche
183
211
  "reference_reply": "Your appointment with the cardiologist is booked for 10 AM next Monday. Is there anything else I can help you with?",
184
212
  "interaction_type": "final",
185
213
  "reference_metadata": {},
186
- "guardrail_flag": false,
187
- "request_payload": {"user_id": "0001", "user_role": "ADMIN"}
214
+ "guardrail_flag": false
188
215
  }
189
216
  ],
190
217
  "description": "A conversation about booking a doctor appointment.",
@@ -245,11 +272,90 @@ if __name__ == "__main__":
245
272
 
246
273
 
247
274
  config_dict = {
248
- "process": {"project_name": "test-project", "workflow_type": "SIMULATOR", "evaluation_params": {"attempts": 2}},
249
- "evaluation": {"evaluators": ["JUDGE", "REFERENCE"], "providers": ["openai", "ionos"], "metrics_map": {"field_1": "EXACT"}},
250
- "reference_data": {"path": "", "data": {}},
251
- "endpoint": {"base_url": "http://127.0.0.1:8000", "api_key": "key", "model_id": "model"},
252
- "repository": {"type": "FIRESTORE", "source": "IN_MEMORY"},
275
+ "process": {
276
+ "project_name": "test-project",
277
+ "workflow_type": "SIMULATOR", # Pick one of the following workflows: SIMULATOR, COMPARATOR, ASSESSOR.
278
+ "evaluation_params": {
279
+ "attempts": 1, # Add the number of simulation attempts.
280
+ }
281
+ },
282
+ "evaluation": {
283
+ "evaluators": ["JUDGE", "REFERENCE"], # Select from the following: JUDGE, REFERENCE, RAG.
284
+ "providers": ["openai", "ionos"],
285
+ "metrics_map": {
286
+ "field_1": "EXACT",
287
+ "field_2": "LEVENSHTEIN"
288
+ }
289
+ },
290
+ "reference_data": {
291
+ "path": "../data/conversation_example_1.json",
292
+ "data": None
293
+ },
294
+ "endpoint": {
295
+ "name": "conversational-agent",
296
+ "base_url": "http://127.0.0.1:8000",
297
+ "path": "/v1/chat",
298
+ "method": "POST",
299
+ "timeout": 60,
300
+ "retry_count": 3,
301
+ "retry_backoff": 0.5,
302
+ "headers": [
303
+ {
304
+ "name": "model_id",
305
+ "value": "meta-llama/Meta-Llama-3.1-8B-Instruct",
306
+ "secure": False
307
+ },
308
+ {
309
+ "name": "x-api-key",
310
+ "value": "API_KEY", # Load from .env file using python-dotenv.
311
+ "secure": True
312
+ },
313
+ {
314
+ "name": "Content-Type",
315
+ "value": "application/json",
316
+ "secure": False
317
+ }
318
+ ],
319
+ "request_schema": [
320
+ {
321
+ "field_path": "message.source",
322
+ "value": "system",
323
+ "value_type": "static",
324
+ "required": True
325
+ },
326
+ {
327
+ "field_path": "message.text",
328
+ "value": "message_text", # the key from the runtime context.
329
+ "value_type": "dynamic",
330
+ "required": True
331
+ },
332
+ {
333
+ "field_path": "metadata.env",
334
+ "value": "ENV_VAR_NAME",
335
+ "value_type": "env",
336
+ "required": False
337
+ }
338
+ ],
339
+ "response_mapping": [
340
+ {
341
+ "field_path": "reply.text",
342
+ "extract_as": "agent_reply" # Remember that the simulator requires this key: 'agent_reply'.
343
+ },
344
+ {
345
+ "field_path": "reply.metadata",
346
+ "extract_as": "agent_reply" # Remember that the simulator requires this key: 'agent_reply'.
347
+ },
348
+ {
349
+ "field_path": "reply.guardrail_flag",
350
+ "extract_as": "metadata" # Remember that the simulator requires this key: 'agent_reply'.
351
+ }
352
+ ]
353
+ },
354
+ "repository": {
355
+ "type": "FIRESTORE", # Pick one of the following: FIRESTORE, FILESYSTEM
356
+ "project_id": "(default)",
357
+ "database_name": ""
358
+ }
253
359
  }
254
360
 
255
361
  content = {
@@ -275,9 +381,18 @@ if __name__ == "__main__":
275
381
  # Load reference data from dict variable
276
382
  config.set_reference_data(content=content)
277
383
 
278
- evaluation_session = EvaluationSession(session_name="test-session-2", workflow_config=config)
384
+ evaluation_session = EvaluationSession(
385
+ session_name="test-session",
386
+ workflow_config=config,
387
+ enable_monitoring=True # To disable the monitoring aspect, set this to False.
388
+ )
279
389
 
280
390
  with evaluation_session as session:
391
+ # Optional: Run connectivity test before the full evaluation
392
+ test_results = session.run_connectivity_test(
393
+ context={"user_message": "I want to book an appointment with a dentist."}
394
+ )
395
+ print(f"Connectivity Test Results:\n{test_results}\n---")
281
396
  session.run()
282
397
  results = session.workflow.collect_results()
283
398
  print("Results:", results)
@@ -1,6 +1,6 @@
1
1
  levelapp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  levelapp/aspects/__init__.py,sha256=_OaPcjTWBizqcUdDVj5aYue7lG9ytjQGLhPvReriKnU,326
3
- levelapp/aspects/loader.py,sha256=xWpcWtS25zbVhZ0UnIJEcQA9klajKk10TLK4j1IStH0,9543
3
+ levelapp/aspects/loader.py,sha256=IB2sZTmTdAvYHQZlH7PdZGQHh3r86P-zX3rIp0PyG2M,9577
4
4
  levelapp/aspects/logger.py,sha256=MJ9HphyHYkTE5-ajA_WuMUTM0qQzd0WIP243vF-pj3M,1698
5
5
  levelapp/aspects/monitor.py,sha256=ibUk01Y5y67_qBJRA5YzvjMX8QrRkMTJ-mN77ztuLlo,22113
6
6
  levelapp/aspects/sanitizer.py,sha256=zUqgb76tXJ8UUYtHp0Rz7q9PZjAHpSpHPPFfGTjjQNg,5229
@@ -16,15 +16,25 @@ levelapp/comparator/schemas.py,sha256=lUAQzEyStidt2ePQgV2zq-An5MLBrVSw6t8fB0FQKJ
16
16
  levelapp/comparator/scorer.py,sha256=LBRy8H11rXulSa-k40BcycPcMAHgdUm13qS7ibWHq6I,9032
17
17
  levelapp/comparator/utils.py,sha256=Eu48nDrNzFr0lwAJJS0aNhKsAWQ72syTEWYMNYfg764,4331
18
18
  levelapp/config/__init__.py,sha256=9oaajE5zW-OVWOszUzMAG6nHDSbLQWa3KT6bVoSvzRA,137
19
+ levelapp/config/api_config.yaml,sha256=t5OGz2YyEWM6G6n5PX7erYLivnZJQ5AD61wnA7Ntd8k,4364
20
+ levelapp/config/dashq_api.yaml,sha256=msQn-0pQOcNueb4A3funSt8mJqNjmOv0EIxhGeVmKRM,3019
19
21
  levelapp/config/endpoint.py,sha256=B-uIEKF-0_Y6Vo8MZ8eoCZocRkghijrdpwT3zq0FDLk,7647
20
- levelapp/config/endpoint_.py,sha256=-abrIYKbFPLxTqNst-zbCI4MpMCmCMe9VZ6O8OwNRiE,1629
22
+ levelapp/config/endpoint_.py,sha256=KEVEgYvnB1UfVczWyvYJjtIafFAeqKT-mHE776hMxlE,13379
23
+ levelapp/config/endpoints.yaml,sha256=9FyK9CvfKKG8Vp200_GrxYzm1ZUYw8g8Ad5VEPW2P6k,1101
21
24
  levelapp/config/prompts.py,sha256=NXOKRp5l1VQ9LO0pUojVH6TDJhWyZImsAvZEz2QiD9k,2206
22
25
  levelapp/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
26
  levelapp/core/base.py,sha256=oh4OkKgwGxmw_jgjX6wrBoK0KPc1JvCMZfbZP_mGmIg,12453
24
27
  levelapp/core/schemas.py,sha256=E47d93MMOj4eRYZIqUyLBiE5Ye7WgwkOJPOWQ6swRmo,465
25
- levelapp/core/session.py,sha256=6utDbLdg6DjwHL5dP-4wGe4_f7gFgEukuNNeOnbCbtA,9035
28
+ levelapp/core/session.py,sha256=-NXpJlwyQRnswaQU8sQ-Ozgi9YQOe17Rxay__ILrUHQ,9344
29
+ levelapp/endpoint/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
+ levelapp/endpoint/client.py,sha256=QBCGAikGjZvlylvXiLKZLprQ4anZwAUpGSmsiOneCrQ,3496
31
+ levelapp/endpoint/manager.py,sha256=xypEQqYxi1RiSaUbL0HlHNJwvCliz3Tx9u_TGKPELSo,4212
32
+ levelapp/endpoint/parsers.py,sha256=13RewihOiWVt7gMQ3g-UOEz8kNpSZ-KY2NgAN44Il2E,4263
33
+ levelapp/endpoint/schemas.py,sha256=V0tpXC8aawHpX5zatderYa0fB14_QEkPiKRvfsuGZRM,851
34
+ levelapp/endpoint/tester.py,sha256=6ylVRwsS_BRo19pJh_J7UcH3NZIfDxxOoccfSqQ9tR4,2078
35
+ levelapp/endpoint/usage_example.py,sha256=XKpUYffLIe81osmFdoSM5oYHUw9HkKdQr_0h4TIZxSg,1242
26
36
  levelapp/evaluator/__init__.py,sha256=K-P75Q1FXXLCNqH1wyhT9sf4y2R9a1qR5449AXEsY1k,109
27
- levelapp/evaluator/evaluator.py,sha256=JCRgQps9GKlJBDYw9xzVrC2_aGy0GhGAJ0ZkSC_IWWA,10806
37
+ levelapp/evaluator/evaluator.py,sha256=kkWQg4GEqDyNeIVwFzkk36uDYfPFXRQQ7jsK51BDSA4,11000
28
38
  levelapp/metrics/__init__.py,sha256=x8iTaeDezJyQ9-NFe8GGvzwIBhyAJHWSRfBE3JRX-PE,1878
29
39
  levelapp/metrics/embedding.py,sha256=wvlT8Q5DjDT6GrAIFtc5aFbA_80hDLUXMP4RbSpSwHE,115
30
40
  levelapp/metrics/exact.py,sha256=Kb13nD2OVLrl3iYHaXrxDfrxDuhW0SMVvLAEXPaJtlY,6235
@@ -32,19 +42,20 @@ levelapp/metrics/fuzzy.py,sha256=Rg8ashzMxtQwKO-z_LLzdj2PDIRqL4CBw6PGRf9IBrI,259
32
42
  levelapp/metrics/token.py,sha256=yQi9hxT_fXTGjLiCCemDxQ4Uk2zD-wQYtSnDlI2AuuY,3521
33
43
  levelapp/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
44
  levelapp/repository/__init__.py,sha256=hNmFRZ7kKJN1mMlOHeW9xf0j9Q7gqTXYJ3hMCzk9to4,79
45
+ levelapp/repository/filesystem.py,sha256=-C2oVThZt16K41iZNSEaM2qO3tTPsFKVsDYQQiwo1Bk,7475
35
46
  levelapp/repository/firestore.py,sha256=K9JgxsNCelAKtzTDv19c1dHRlitMeRzo7H3caTlKuF8,10369
36
47
  levelapp/simulator/__init__.py,sha256=8Dz8g7rbpBZX3WoknVmMVoWm_VT72ZL9BABOF1xFpqs,83
37
- levelapp/simulator/schemas.py,sha256=YGprtuRZ4m33WBD35xj1Ib5EbMTdDCOp-wCykf-Iz-4,3700
38
- levelapp/simulator/simulator.py,sha256=yreado12XMVEJ4N4cYj5m_bYVKU3BsOv5oQycB7wCFw,19889
39
- levelapp/simulator/utils.py,sha256=xZXdF24rrOm5RCp5ELk0wQxxGd70CahDT79cIC-XmlE,9589
48
+ levelapp/simulator/schemas.py,sha256=LvkXa8KGh8aGZAz8mB9-hUDFVbQjzD8zVzMXeoI6ZGI,3715
49
+ levelapp/simulator/simulator.py,sha256=7rlovMrbwyRndDnltAG98ff8ojny6hoXdVFGEdBkm0U,20474
50
+ levelapp/simulator/utils.py,sha256=smSrZ8praKINK0wFpKl3tmqr21OUz_dheUOTH0miTys,4882
40
51
  levelapp/workflow/__init__.py,sha256=27b2obG7ObhR43yd2uH-R0koRB7-DG8Emnvrq8EjsTA,193
41
- levelapp/workflow/base.py,sha256=1A_xKSBOmVjfMbRBcNhDK6G17SEjqRIm-XjMw45IPC4,5596
42
- levelapp/workflow/config.py,sha256=MlHt1PsXD09aukB93fvKTew0D8WD4_jdnO93Nn6b2U0,2923
43
- levelapp/workflow/context.py,sha256=gjAZXHEdlsXqWY6DbXOfKXNbxQbahRPSnNzyWDqryPU,2559
52
+ levelapp/workflow/base.py,sha256=wkvVbxAhWH1D9YJOoHCE4xfC4Hnl4hYpFYCG8_v-8dk,6643
53
+ levelapp/workflow/config.py,sha256=hgch9KV-TMtbesEFi00eibFdk5JJStJwb5TGO5m-o-M,3124
54
+ levelapp/workflow/context.py,sha256=KOXm_5HJWYyWfl9C83BqT37X7QVuUYSS-ZoDpZgXFQw,2696
44
55
  levelapp/workflow/factory.py,sha256=z1ttJmI59sU9HgOvPo3ixUJ_oPv838XgehfuOorlTt8,1634
45
56
  levelapp/workflow/registration.py,sha256=VHUHjLHXad5kjcKukaEOIf7hBZ09bT3HAzVmIT08aLo,359
46
- levelapp/workflow/runtime.py,sha256=cFyXNWXSuURKbrMDHdkTcjeItM9wHP-5DPljntwYL5g,686
47
- levelapp-0.1.4.dist-info/METADATA,sha256=zCmgM_evZ9Y0xcAX-so7foD_auO0I9PSzLGw0pL2HUY,12572
48
- levelapp-0.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
49
- levelapp-0.1.4.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
- levelapp-0.1.4.dist-info/RECORD,,
57
+ levelapp/workflow/runtime.py,sha256=a3REqikh3-QHj0uYikqx0b4xQjq-w6VNyiUandL5GWw,690
58
+ levelapp-0.1.5.dist-info/METADATA,sha256=rs-J5XSEWR2WNUWP6wVJkbIgwOooLPul3POZZZdsjUQ,16130
59
+ levelapp-0.1.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
60
+ levelapp-0.1.5.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
61
+ levelapp-0.1.5.dist-info/RECORD,,