azure-ai-evaluation 1.0.0__py3-none-any.whl → 1.0.0b1__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 azure-ai-evaluation might be problematic. Click here for more details.

Files changed (108) hide show
  1. azure/ai/evaluation/__init__.py +4 -26
  2. azure/ai/evaluation/_common/constants.py +2 -9
  3. azure/ai/evaluation/_common/rai_service.py +122 -302
  4. azure/ai/evaluation/_common/utils.py +35 -393
  5. azure/ai/evaluation/_constants.py +6 -28
  6. azure/ai/evaluation/_evaluate/{_batch_run → _batch_run_client}/__init__.py +2 -3
  7. azure/ai/evaluation/_evaluate/{_batch_run/eval_run_context.py → _batch_run_client/batch_run_context.py} +8 -25
  8. azure/ai/evaluation/_evaluate/{_batch_run → _batch_run_client}/code_client.py +30 -68
  9. azure/ai/evaluation/_evaluate/_batch_run_client/proxy_client.py +61 -0
  10. azure/ai/evaluation/_evaluate/_eval_run.py +40 -117
  11. azure/ai/evaluation/_evaluate/_evaluate.py +255 -416
  12. azure/ai/evaluation/_evaluate/_telemetry/__init__.py +19 -24
  13. azure/ai/evaluation/_evaluate/_utils.py +47 -108
  14. azure/ai/evaluation/_evaluators/_bleu/_bleu.py +19 -18
  15. azure/ai/evaluation/_evaluators/{_retrieval → _chat}/__init__.py +2 -2
  16. azure/ai/evaluation/_evaluators/_chat/_chat.py +350 -0
  17. azure/ai/evaluation/_evaluators/{_service_groundedness → _chat/retrieval}/__init__.py +2 -2
  18. azure/ai/evaluation/_evaluators/_chat/retrieval/_retrieval.py +163 -0
  19. azure/ai/evaluation/_evaluators/_chat/retrieval/retrieval.prompty +48 -0
  20. azure/ai/evaluation/_evaluators/_coherence/_coherence.py +93 -78
  21. azure/ai/evaluation/_evaluators/_coherence/coherence.prompty +39 -76
  22. azure/ai/evaluation/_evaluators/_content_safety/__init__.py +4 -0
  23. azure/ai/evaluation/_evaluators/_content_safety/_content_safety.py +68 -104
  24. azure/ai/evaluation/_evaluators/{_multimodal/_content_safety_multimodal_base.py → _content_safety/_content_safety_base.py} +35 -24
  25. azure/ai/evaluation/_evaluators/_content_safety/_content_safety_chat.py +296 -0
  26. azure/ai/evaluation/_evaluators/_content_safety/_hate_unfairness.py +54 -105
  27. azure/ai/evaluation/_evaluators/_content_safety/_self_harm.py +52 -99
  28. azure/ai/evaluation/_evaluators/_content_safety/_sexual.py +52 -101
  29. azure/ai/evaluation/_evaluators/_content_safety/_violence.py +51 -101
  30. azure/ai/evaluation/_evaluators/_eci/_eci.py +55 -45
  31. azure/ai/evaluation/_evaluators/_f1_score/_f1_score.py +20 -36
  32. azure/ai/evaluation/_evaluators/_fluency/_fluency.py +94 -76
  33. azure/ai/evaluation/_evaluators/_fluency/fluency.prompty +41 -66
  34. azure/ai/evaluation/_evaluators/_gleu/_gleu.py +17 -15
  35. azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py +92 -113
  36. azure/ai/evaluation/_evaluators/_groundedness/groundedness.prompty +54 -0
  37. azure/ai/evaluation/_evaluators/_meteor/_meteor.py +27 -21
  38. azure/ai/evaluation/_evaluators/_protected_material/_protected_material.py +80 -89
  39. azure/ai/evaluation/_evaluators/_protected_materials/__init__.py +5 -0
  40. azure/ai/evaluation/_evaluators/_protected_materials/_protected_materials.py +104 -0
  41. azure/ai/evaluation/_evaluators/_qa/_qa.py +43 -25
  42. azure/ai/evaluation/_evaluators/_relevance/_relevance.py +101 -84
  43. azure/ai/evaluation/_evaluators/_relevance/relevance.prompty +47 -78
  44. azure/ai/evaluation/_evaluators/_rouge/_rouge.py +27 -27
  45. azure/ai/evaluation/_evaluators/_similarity/_similarity.py +45 -55
  46. azure/ai/evaluation/_evaluators/_similarity/similarity.prompty +5 -0
  47. azure/ai/evaluation/_evaluators/_xpia/xpia.py +106 -91
  48. azure/ai/evaluation/_exceptions.py +7 -28
  49. azure/ai/evaluation/_http_utils.py +134 -205
  50. azure/ai/evaluation/_model_configurations.py +8 -104
  51. azure/ai/evaluation/_version.py +1 -1
  52. azure/ai/evaluation/simulator/__init__.py +2 -3
  53. azure/ai/evaluation/simulator/_adversarial_scenario.py +1 -20
  54. azure/ai/evaluation/simulator/_adversarial_simulator.py +95 -116
  55. azure/ai/evaluation/simulator/_constants.py +1 -11
  56. azure/ai/evaluation/simulator/_conversation/__init__.py +13 -14
  57. azure/ai/evaluation/simulator/_conversation/_conversation.py +20 -20
  58. azure/ai/evaluation/simulator/_direct_attack_simulator.py +68 -34
  59. azure/ai/evaluation/simulator/_helpers/__init__.py +1 -1
  60. azure/ai/evaluation/simulator/_helpers/_simulator_data_classes.py +28 -31
  61. azure/ai/evaluation/simulator/_indirect_attack_simulator.py +95 -108
  62. azure/ai/evaluation/simulator/_model_tools/_identity_manager.py +22 -70
  63. azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py +14 -30
  64. azure/ai/evaluation/simulator/_model_tools/_rai_client.py +14 -25
  65. azure/ai/evaluation/simulator/_model_tools/_template_handler.py +24 -68
  66. azure/ai/evaluation/simulator/_model_tools/models.py +21 -19
  67. azure/ai/evaluation/simulator/_prompty/task_query_response.prompty +10 -6
  68. azure/ai/evaluation/simulator/_prompty/task_simulate.prompty +5 -6
  69. azure/ai/evaluation/simulator/_tracing.py +28 -25
  70. azure/ai/evaluation/simulator/_utils.py +13 -34
  71. azure/ai/evaluation/simulator/simulator.py +579 -0
  72. azure_ai_evaluation-1.0.0b1.dist-info/METADATA +377 -0
  73. azure_ai_evaluation-1.0.0b1.dist-info/RECORD +97 -0
  74. {azure_ai_evaluation-1.0.0.dist-info → azure_ai_evaluation-1.0.0b1.dist-info}/WHEEL +1 -1
  75. azure/ai/evaluation/_common/_experimental.py +0 -172
  76. azure/ai/evaluation/_common/math.py +0 -89
  77. azure/ai/evaluation/_evaluate/_batch_run/proxy_client.py +0 -99
  78. azure/ai/evaluation/_evaluate/_batch_run/target_run_context.py +0 -46
  79. azure/ai/evaluation/_evaluators/_common/__init__.py +0 -13
  80. azure/ai/evaluation/_evaluators/_common/_base_eval.py +0 -344
  81. azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py +0 -88
  82. azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py +0 -133
  83. azure/ai/evaluation/_evaluators/_groundedness/groundedness_with_query.prompty +0 -113
  84. azure/ai/evaluation/_evaluators/_groundedness/groundedness_without_query.prompty +0 -99
  85. azure/ai/evaluation/_evaluators/_multimodal/__init__.py +0 -20
  86. azure/ai/evaluation/_evaluators/_multimodal/_content_safety_multimodal.py +0 -132
  87. azure/ai/evaluation/_evaluators/_multimodal/_hate_unfairness.py +0 -100
  88. azure/ai/evaluation/_evaluators/_multimodal/_protected_material.py +0 -124
  89. azure/ai/evaluation/_evaluators/_multimodal/_self_harm.py +0 -100
  90. azure/ai/evaluation/_evaluators/_multimodal/_sexual.py +0 -100
  91. azure/ai/evaluation/_evaluators/_multimodal/_violence.py +0 -100
  92. azure/ai/evaluation/_evaluators/_retrieval/_retrieval.py +0 -112
  93. azure/ai/evaluation/_evaluators/_retrieval/retrieval.prompty +0 -93
  94. azure/ai/evaluation/_evaluators/_service_groundedness/_service_groundedness.py +0 -148
  95. azure/ai/evaluation/_vendor/__init__.py +0 -3
  96. azure/ai/evaluation/_vendor/rouge_score/__init__.py +0 -14
  97. azure/ai/evaluation/_vendor/rouge_score/rouge_scorer.py +0 -328
  98. azure/ai/evaluation/_vendor/rouge_score/scoring.py +0 -63
  99. azure/ai/evaluation/_vendor/rouge_score/tokenize.py +0 -63
  100. azure/ai/evaluation/_vendor/rouge_score/tokenizers.py +0 -53
  101. azure/ai/evaluation/simulator/_data_sources/__init__.py +0 -3
  102. azure/ai/evaluation/simulator/_data_sources/grounding.json +0 -1150
  103. azure/ai/evaluation/simulator/_prompty/__init__.py +0 -0
  104. azure/ai/evaluation/simulator/_simulator.py +0 -716
  105. azure_ai_evaluation-1.0.0.dist-info/METADATA +0 -595
  106. azure_ai_evaluation-1.0.0.dist-info/NOTICE.txt +0 -70
  107. azure_ai_evaluation-1.0.0.dist-info/RECORD +0 -119
  108. {azure_ai_evaluation-1.0.0.dist-info → azure_ai_evaluation-1.0.0b1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,377 @@
1
+ Metadata-Version: 2.1
2
+ Name: azure-ai-evaluation
3
+ Version: 1.0.0b1
4
+ Summary: Microsoft Azure Evaluation Library for Python
5
+ Home-page: https://github.com/Azure/azure-sdk-for-python
6
+ Author: Microsoft Corporation
7
+ Author-email: azuresdkengsysadmins@microsoft.com
8
+ License: MIT License
9
+ Project-URL: Bug Reports, https://github.com/Azure/azure-sdk-for-python/issues
10
+ Project-URL: Source, https://github.com/Azure/azure-sdk-for-python
11
+ Keywords: azure,azure sdk
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: License :: OSI Approved :: MIT License
21
+ Classifier: Operating System :: OS Independent
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: promptflow-devkit >=1.15.0
25
+ Requires-Dist: promptflow-core >=1.15.0
26
+ Requires-Dist: pyjwt >=2.8.0
27
+ Requires-Dist: azure-identity >=1.12.0
28
+ Requires-Dist: azure-core >=1.30.2
29
+ Requires-Dist: nltk >=3.9.1
30
+ Requires-Dist: rouge-score >=0.1.2
31
+ Requires-Dist: numpy >=1.23.2 ; python_version < "3.12"
32
+ Requires-Dist: numpy >=1.26.4 ; python_version >= "3.12"
33
+ Provides-Extra: pf-azure
34
+ Requires-Dist: promptflow-azure <2.0.0,>=1.15.0 ; extra == 'pf-azure'
35
+
36
+ # Azure AI Evaluation client library for Python
37
+
38
+ ## Getting started
39
+
40
+ ### Install the package
41
+
42
+ Install the Azure AI Evaluation library for Python with:
43
+
44
+ ```bash
45
+ pip install azure-ai-evaluation
46
+ ```
47
+
48
+ ## Key concepts
49
+
50
+ Evaluators are custom or prebuilt classes or functions that are designed to measure the quality of the outputs from language models.
51
+
52
+ ## Examples
53
+
54
+ Users can create evaluator runs on the local machine as shown in the example below:
55
+
56
+ ```python
57
+ import os
58
+ from pprint import pprint
59
+
60
+ from azure.ai.evaluation import evaluate, RelevanceEvaluator, ViolenceEvaluator
61
+
62
+
63
+ def response_length(response, **kwargs):
64
+ return {"value": len(response)}
65
+
66
+
67
+ if __name__ == "__main__":
68
+ # Built-in evaluators
69
+ # Initialize Azure OpenAI Model Configuration
70
+ model_config = {
71
+ "azure_endpoint": os.environ.get("AZURE_OPENAI_ENDPOINT"),
72
+ "api_key": os.environ.get("AZURE_OPENAI_KEY"),
73
+ "azure_deployment": os.environ.get("AZURE_OPENAI_DEPLOYMENT"),
74
+ }
75
+
76
+ # Initialzing Relevance Evaluator
77
+ relevance_eval = RelevanceEvaluator(model_config)
78
+
79
+ # Running Relevance Evaluator on single input row
80
+ relevance_score = relevance_eval(
81
+ response="The Alpine Explorer Tent is the most waterproof.",
82
+ context="From the our product list,"
83
+ " the alpine explorer tent is the most waterproof."
84
+ " The Adventure Dining Table has higher weight.",
85
+ query="Which tent is the most waterproof?",
86
+ )
87
+
88
+ pprint(relevance_score)
89
+ # {'gpt_relevance': 5.0}
90
+
91
+ # Content Safety Evaluator
92
+
93
+ # Initialize Project Scope
94
+ azure_ai_project = {
95
+ "subscription_id": "e0fd569c-e34a-4249-8c24-e8d723c7f054",
96
+ "resource_group_name": "rg-test",
97
+ "project_name": "project-test",
98
+ }
99
+
100
+ violence_eval = ViolenceEvaluator(azure_ai_project)
101
+ violence_score = violence_eval(query="What is the capital of France?", response="Paris.")
102
+ pprint(violence_score)
103
+ # {'violence': 'Very low',
104
+ # 'violence_reason': "The system's response is a straightforward factual response "
105
+ # 'to a geography question. There is no violent content or '
106
+ # 'language present.',
107
+ # 'violence_score': 0}
108
+
109
+ # Code based evaluator
110
+ response_length("The Alpine Explorer Tent is the most waterproof.")
111
+ # {'value': 48}
112
+
113
+ # Using multiple evaluators together using `Evaluate` API
114
+
115
+ result = evaluate(
116
+ data="evaluate_test_data.jsonl",
117
+ evaluators={
118
+ "response_length": response_length,
119
+ "violence": violence_eval,
120
+ },
121
+ )
122
+
123
+ pprint(result)
124
+ ```
125
+ ## Simulator
126
+
127
+ Sample application prompty
128
+
129
+ ```yaml
130
+ ---
131
+ name: ApplicationPrompty
132
+ description: Simulates an application
133
+ model:
134
+ api: chat
135
+ configuration:
136
+ type: azure_openai
137
+ azure_deployment: ${env:AZURE_DEPLOYMENT}
138
+ api_key: ${env:AZURE_OPENAI_API_KEY}
139
+ azure_endpoint: ${env:AZURE_OPENAI_ENDPOINT}
140
+ parameters:
141
+ temperature: 0.0
142
+ top_p: 1.0
143
+ presence_penalty: 0
144
+ frequency_penalty: 0
145
+ response_format:
146
+ type: text
147
+
148
+ inputs:
149
+ conversation_history:
150
+ type: dict
151
+
152
+ ---
153
+ system:
154
+ You are a helpful assistant and you're helping with the user's query. Keep the conversation engaging and interesting.
155
+
156
+ Output with a string that continues the conversation, responding to the latest message from the user, given the conversation history:
157
+ {{ conversation_history }}
158
+
159
+ ```
160
+ Application code:
161
+
162
+ ```python
163
+ import json
164
+ import asyncio
165
+ from typing import Any, Dict, List, Optional
166
+ from azure.ai.evaluation.synthetic import Simulator
167
+ from promptflow.client import load_flow
168
+ from azure.identity import DefaultAzureCredential
169
+ import os
170
+
171
+ azure_ai_project = {
172
+ "subscription_id": os.environ.get("AZURE_SUBSCRIPTION_ID"),
173
+ "resource_group_name": os.environ.get("RESOURCE_GROUP"),
174
+ "project_name": os.environ.get("PROJECT_NAME"),
175
+ "credential": DefaultAzureCredential(),
176
+ }
177
+
178
+ import wikipedia
179
+ wiki_search_term = "Leonardo da vinci"
180
+ wiki_title = wikipedia.search(wiki_search_term)[0]
181
+ wiki_page = wikipedia.page(wiki_title)
182
+ text = wiki_page.summary[:1000]
183
+
184
+ def method_to_invoke_application_prompty(query: str):
185
+ try:
186
+ current_dir = os.path.dirname(__file__)
187
+ prompty_path = os.path.join(current_dir, "application.prompty")
188
+ _flow = load_flow(source=prompty_path, model={
189
+ "configuration": azure_ai_project
190
+ })
191
+ response = _flow(
192
+ query=query,
193
+ context=context,
194
+ conversation_history=messages_list
195
+ )
196
+ return response
197
+ except:
198
+ print("Something went wrong invoking the prompty")
199
+ return "something went wrong"
200
+
201
+ async def callback(
202
+ messages: List[Dict],
203
+ stream: bool = False,
204
+ session_state: Any = None, # noqa: ANN401
205
+ context: Optional[Dict[str, Any]] = None,
206
+ ) -> dict:
207
+ messages_list = messages["messages"]
208
+ # get last message
209
+ latest_message = messages_list[-1]
210
+ query = latest_message["content"]
211
+ context = None
212
+ # call your endpoint or ai application here
213
+ response = method_to_invoke_application_prompty(query)
214
+ # we are formatting the response to follow the openAI chat protocol format
215
+ formatted_response = {
216
+ "content": response,
217
+ "role": "assistant",
218
+ "context": {
219
+ "citations": None,
220
+ },
221
+ }
222
+ messages["messages"].append(formatted_response)
223
+ return {"messages": messages["messages"], "stream": stream, "session_state": session_state, "context": context}
224
+
225
+
226
+
227
+ async def main():
228
+ simulator = Simulator(azure_ai_project=azure_ai_project, credential=DefaultAzureCredential())
229
+ outputs = await simulator(
230
+ target=callback,
231
+ text=text,
232
+ num_queries=2,
233
+ max_conversation_turns=4,
234
+ user_persona=[
235
+ f"I am a student and I want to learn more about {wiki_search_term}",
236
+ f"I am a teacher and I want to teach my students about {wiki_search_term}"
237
+ ],
238
+ )
239
+ print(json.dumps(outputs))
240
+
241
+ if __name__ == "__main__":
242
+ os.environ["AZURE_SUBSCRIPTION_ID"] = ""
243
+ os.environ["RESOURCE_GROUP"] = ""
244
+ os.environ["PROJECT_NAME"] = ""
245
+ os.environ["AZURE_OPENAI_API_KEY"] = ""
246
+ os.environ["AZURE_OPENAI_ENDPOINT"] = ""
247
+ os.environ["AZURE_DEPLOYMENT"] = ""
248
+ asyncio.run(main())
249
+ print("done!")
250
+ ```
251
+
252
+ Simulators allow users to generate synthentic data using their application. Simulator expects the user to have a callback method that invokes
253
+ their AI application. Here's a sample of a callback which invokes AsyncAzureOpenAI:
254
+
255
+ ```python
256
+ from from azure.ai.evaluation.simulator import AdversarialSimulator, AdversarialScenario
257
+ from azure.identity import DefaultAzureCredential
258
+ from typing import Any, Dict, List, Optional
259
+ import asyncio
260
+
261
+
262
+ azure_ai_project = {
263
+ "subscription_id": <subscription_id>,
264
+ "resource_group_name": <resource_group_name>,
265
+ "project_name": <project_name>
266
+ }
267
+
268
+ async def callback(
269
+ messages: List[Dict],
270
+ stream: bool = False,
271
+ session_state: Any = None,
272
+ context: Dict[str, Any] = None
273
+ ) -> dict:
274
+ messages_list = messages["messages"]
275
+ # get last message
276
+ latest_message = messages_list[-1]
277
+ query = latest_message["content"]
278
+ context = None
279
+ if 'file_content' in messages["template_parameters"]:
280
+ query += messages["template_parameters"]['file_content']
281
+ # the next few lines explains how to use the AsyncAzureOpenAI's chat.completions
282
+ # to respond to the simulator. You should replace it with a call to your model/endpoint/application
283
+ # make sure you pass the `query` and format the response as we have shown below
284
+ from openai import AsyncAzureOpenAI
285
+ oai_client = AsyncAzureOpenAI(
286
+ api_key=<api_key>,
287
+ azure_endpoint=<endpoint>,
288
+ api_version="2023-12-01-preview",
289
+ )
290
+ try:
291
+ response_from_oai_chat_completions = await oai_client.chat.completions.create(messages=[{"content": query, "role": "user"}], model="gpt-4", max_tokens=300)
292
+ except Exception as e:
293
+ print(f"Error: {e}")
294
+ # to continue the conversation, return the messages, else you can fail the adversarial with an exception
295
+ message = {
296
+ "content": "Something went wrong. Check the exception e for more details.",
297
+ "role": "assistant",
298
+ "context": None,
299
+ }
300
+ messages["messages"].append(message)
301
+ return {
302
+ "messages": messages["messages"],
303
+ "stream": stream,
304
+ "session_state": session_state
305
+ }
306
+ response_result = response_from_oai_chat_completions.choices[0].message.content
307
+ formatted_response = {
308
+ "content": response_result,
309
+ "role": "assistant",
310
+ "context": {},
311
+ }
312
+ messages["messages"].append(formatted_response)
313
+ return {
314
+ "messages": messages["messages"],
315
+ "stream": stream,
316
+ "session_state": session_state,
317
+ "context": context
318
+ }
319
+
320
+ ```
321
+ ### Adversarial QA:
322
+ ```python
323
+ scenario = AdversarialScenario.ADVERSARIAL_QA
324
+ simulator = AdversarialSimulator(azure_ai_project=azure_ai_project, credential=DefaultAzureCredential())
325
+
326
+ outputs = asyncio.run(
327
+ simulator(
328
+ scenario=scenario,
329
+ max_conversation_turns=1,
330
+ max_simulation_results=3,
331
+ target=callback
332
+ )
333
+ )
334
+
335
+ print(outputs.to_eval_qa_json_lines())
336
+ ```
337
+ ### Direct Attack Simulator
338
+
339
+ ```python
340
+ scenario = AdversarialScenario.ADVERSARIAL_QA
341
+ simulator = DirectAttackSimulator(azure_ai_project=azure_ai_project, credential=DefaultAzureCredential())
342
+
343
+ outputs = asyncio.run(
344
+ simulator(
345
+ scenario=scenario,
346
+ max_conversation_turns=1,
347
+ max_simulation_results=2,
348
+ target=callback
349
+ )
350
+ )
351
+
352
+ print(outputs)
353
+ ```
354
+ ## Troubleshooting
355
+
356
+ ## Next steps
357
+
358
+ ## Contributing
359
+
360
+
361
+ # Release History
362
+
363
+ ## 1.0.0b1 (2024-09-20)
364
+
365
+ ### Breaking Changes
366
+
367
+ - The `synthetic` namespace has been renamed to `simulator`, and sub-namespaces under this module have been removed
368
+ - The `evaluate` and `evaluators` namespaces have been removed, and everything previously exposed in those modules has been added to the root namespace `azure.ai.evaluation`
369
+ - The parameter name `project_scope` in content safety evaluators have been renamed to `azure_ai_project` for consistency with evaluate API and simulators.
370
+ - Model configurations classes are now of type `TypedDict` and are exposed in the `azure.ai.evaluation` module instead of coming from `promptflow.core`.
371
+ - Updated the parameter names for `question` and `answer` in built-in evaluators to more generic terms: `query` and `response`.
372
+
373
+ ### Features Added
374
+
375
+ - First preview
376
+ - This package is port of `promptflow-evals`. New features will be added only to this package moving forward.
377
+ - Added a `TypedDict` for `AzureAIProject` that allows for better intellisense and type checking when passing in project information
@@ -0,0 +1,97 @@
1
+ azure/ai/evaluation/__init__.py,sha256=aCQXu_6B3tB-WSRtdPrMUODYMytwK1pVoOTwkR5EItg,1984
2
+ azure/ai/evaluation/_constants.py,sha256=MtXK9FV3TgDiq8IYSMkSDbNXVQsZw62D26g7ZXJ62NU,1422
3
+ azure/ai/evaluation/_exceptions.py,sha256=HUMfvguDc7ygcbs3MTK14R3PK7UxGNWQQHH3hYXIV3U,4168
4
+ azure/ai/evaluation/_http_utils.py,sha256=13G64fWveezBdcmjwwwbJrIkdZp2ns3Jvd-addKw1SU,13983
5
+ azure/ai/evaluation/_model_configurations.py,sha256=D02AzOdyO6LQCia0k232Msd7ro35-EcwmlQ0tOD_5H0,652
6
+ azure/ai/evaluation/_user_agent.py,sha256=O2y-QPBAcw7w7qQ6M2aRPC3Vy3TKd789u5lcs2yuFaI,290
7
+ azure/ai/evaluation/_version.py,sha256=oZ93SfxVsREL_UaqV9_yCzfIy_LG5t9AwK_uEE8HjXI,201
8
+ azure/ai/evaluation/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ azure/ai/evaluation/_common/__init__.py,sha256=LHTkf6dMLLxikrGNgbUuREBVQcs4ORHR6Eryo4bm9M8,586
10
+ azure/ai/evaluation/_common/constants.py,sha256=ZKHGVgGA1Fc6Pvo22X-CeOUX6-m0q_UwpOKOWATTSuI,1639
11
+ azure/ai/evaluation/_common/rai_service.py,sha256=Cci_YnX1XeYHiZX4DTVj6_bAj2JADXh1znXS_cDM45M,17540
12
+ azure/ai/evaluation/_common/utils.py,sha256=Ed2pgAXzswrOskWopYyRGdPMOkwbP-cgj32kBOuWMZw,2941
13
+ azure/ai/evaluation/_evaluate/__init__.py,sha256=Yx1Iq2GNKQ5lYxTotvPwkPL4u0cm6YVxUe-iVbu1clI,180
14
+ azure/ai/evaluation/_evaluate/_eval_run.py,sha256=eUUUzF6o3FjkQ6L5aZnESQjWM_UscM5MnCD-5P0dldA,20237
15
+ azure/ai/evaluation/_evaluate/_evaluate.py,sha256=HP7J39YUn9yMKLl2z-k-7_BVpzQIhDQwFOExQk6nb9w,28379
16
+ azure/ai/evaluation/_evaluate/_utils.py,sha256=-8xv0TF3QQPfZlEpLOCGSq2Nvb-esZfpaDySOHLeey4,9680
17
+ azure/ai/evaluation/_evaluate/_batch_run_client/__init__.py,sha256=BkxhojWca3e2QM3hFwO2xrLiiQ0i-3f8wsMfOx1zchs,361
18
+ azure/ai/evaluation/_evaluate/_batch_run_client/batch_run_context.py,sha256=wL_gNM2u8_DYUKopxFnJFc0cUAxWo9HV5gNSfZoluJo,2983
19
+ azure/ai/evaluation/_evaluate/_batch_run_client/code_client.py,sha256=xmck4Wlp0wrzkN6sZsmW-7MMAc1rIw16xwSV52_V8to,7120
20
+ azure/ai/evaluation/_evaluate/_batch_run_client/proxy_client.py,sha256=_2NynIyH_QFZQf5TDZ9x_FtDUXrzvMfGVuTtpZJazpo,1981
21
+ azure/ai/evaluation/_evaluate/_telemetry/__init__.py,sha256=gF0mHhCYjrlOBgR4I6mQ5KIfExpq7W2On31ITmjYN8M,6400
22
+ azure/ai/evaluation/_evaluators/__init__.py,sha256=Yx1Iq2GNKQ5lYxTotvPwkPL4u0cm6YVxUe-iVbu1clI,180
23
+ azure/ai/evaluation/_evaluators/_bleu/__init__.py,sha256=quKKO0kvOSkky5hcoNBvgBuMeeVRFCE9GSv70mAdGP4,260
24
+ azure/ai/evaluation/_evaluators/_bleu/_bleu.py,sha256=q8hTVC8Ubfb0lQmlGnsuEb6J7Qx5c7eYso4ss6RhgOw,2413
25
+ azure/ai/evaluation/_evaluators/_chat/__init__.py,sha256=xOsSHYNGJJiZvBMPbmLd_-ZZs8_15Sblvk-OF7iVoIo,250
26
+ azure/ai/evaluation/_evaluators/_chat/_chat.py,sha256=GsK7EERUNo5uuh025EazxpK6wuN7mzz891_l8WFxqXg,14692
27
+ azure/ai/evaluation/_evaluators/_chat/retrieval/__init__.py,sha256=DmBjBkwDDlCsSGpBeXfpfMM9ekxIJs62dij4rBXND7k,273
28
+ azure/ai/evaluation/_evaluators/_chat/retrieval/_retrieval.py,sha256=X_2UzFd-FP032nT4fjH1EY67bvIcRpmmjv9KQrXpfUE,5739
29
+ azure/ai/evaluation/_evaluators/_chat/retrieval/retrieval.prompty,sha256=NoHNDf_UE8BGAixqZPhRQ4ecxOUi9w9gO8HfHhJuxaY,1761
30
+ azure/ai/evaluation/_evaluators/_coherence/__init__.py,sha256=GRqcSCQse02Spyki0UsRNWMIXiea2lLtPPXNGvkJzQ0,258
31
+ azure/ai/evaluation/_evaluators/_coherence/_coherence.py,sha256=sOP2rYwGe1k_80FhBr5PGG8metmpJwGfx4U7-aVroIs,4121
32
+ azure/ai/evaluation/_evaluators/_coherence/coherence.prompty,sha256=WVEXxKmh_Gbb11_00N2WCIIJSMgPssFxJ5h2--rMG-w,2725
33
+ azure/ai/evaluation/_evaluators/_content_safety/__init__.py,sha256=mR5CbcMyxV9GQoY71Saoi0bQTpEB74HrYmM8gcVhnAg,746
34
+ azure/ai/evaluation/_evaluators/_content_safety/_content_safety.py,sha256=VUazS5AcJ5Z-BOrqfCRt5SdRhmTlxWdxl03FML0zHq4,3998
35
+ azure/ai/evaluation/_evaluators/_content_safety/_content_safety_base.py,sha256=Yb2x-sI5_GivAe8o8BvA2gM64yQCv73v5LS_QyiR9vQ,2802
36
+ azure/ai/evaluation/_evaluators/_content_safety/_content_safety_chat.py,sha256=7cLTnbz0iHderZeXPKYbbBSwvKYZtMiExEMYQSfggd4,11909
37
+ azure/ai/evaluation/_evaluators/_content_safety/_hate_unfairness.py,sha256=Ur1gQPBdr0b_Ov8K0Jflmvua2mgSrk9DhlPOAQR-7w4,2875
38
+ azure/ai/evaluation/_evaluators/_content_safety/_self_harm.py,sha256=MrCOPNmv6PAkVFKDrwNfXeOyhTmyDa2Tik_xEFKxYwg,2676
39
+ azure/ai/evaluation/_evaluators/_content_safety/_sexual.py,sha256=MyRI9QtqElb2gDGPGnyQYfAHsjdw_oK6Ekjz4Voo9rg,2644
40
+ azure/ai/evaluation/_evaluators/_content_safety/_violence.py,sha256=YH0NxossokGX5tFKAIZJvMiprs34KuiNQnMXAbOOMCM,2668
41
+ azure/ai/evaluation/_evaluators/_eci/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
+ azure/ai/evaluation/_evaluators/_eci/_eci.py,sha256=vm8G-YvZuXipvJSixA6mktEL7xQvqnsHcD1trqh7Cxw,4058
43
+ azure/ai/evaluation/_evaluators/_f1_score/__init__.py,sha256=aEVbO7iMoF20obdpLQKcKm69Yyu3mYnblKELLqu8OGI,260
44
+ azure/ai/evaluation/_evaluators/_f1_score/_f1_score.py,sha256=KNMni1m8dtaC6kLf9JRUVfJ1hZfYBi-g6iZiruJ_Hyc,4553
45
+ azure/ai/evaluation/_evaluators/_fluency/__init__.py,sha256=EEJw39xRa0bOAA1rELTTKXQu2s60n_7CZQRD0Gu2QVw,259
46
+ azure/ai/evaluation/_evaluators/_fluency/_fluency.py,sha256=0KSSYQjWzPpGLBK-NIkIdfp0fPcCOpjIkuKMbYprqI0,4082
47
+ azure/ai/evaluation/_evaluators/_fluency/fluency.prompty,sha256=RparSdDZs-xiGbq7lRifz9z7jaD10ldXDU3E7sO0v2s,2579
48
+ azure/ai/evaluation/_evaluators/_gleu/__init__.py,sha256=Ae2EvQ7gqiYAoNO3LwGIhdAAjJPJDfT85rQGKrRrmbA,260
49
+ azure/ai/evaluation/_evaluators/_gleu/_gleu.py,sha256=qQR5Ic4K4biHrMm8XLe1DtKc3MSwbfCjK_-CLpL9aCc,2326
50
+ azure/ai/evaluation/_evaluators/_groundedness/__init__.py,sha256=UYNJUeRvBwcSVFyZpdsf29un5eyaDzYoo3QvC1gvlLg,274
51
+ azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py,sha256=BZdr2Gqgos1CDTnMPJPUfoa_Pkq9WxgdL-Qem6GbINs,4301
52
+ azure/ai/evaluation/_evaluators/_groundedness/groundedness.prompty,sha256=dDclp_YowBjeiGhwmCxCnS4A3K9r4v2tzsUm-ccLt-I,3199
53
+ azure/ai/evaluation/_evaluators/_meteor/__init__.py,sha256=209na3pPsdmcuYpYHUYtqQybCpc3yZkc93HnRdicSlI,266
54
+ azure/ai/evaluation/_evaluators/_meteor/_meteor.py,sha256=62AD1DVH_T_t9MDK4GEcvujC0Aka-SEggxEAmc68byg,3315
55
+ azure/ai/evaluation/_evaluators/_protected_material/__init__.py,sha256=eRAQIU9diVXfO5bp6aLWxZoYUvOsrDIfy1gnDOeNTiI,109
56
+ azure/ai/evaluation/_evaluators/_protected_material/_protected_material.py,sha256=6eZXjp2iXSaTNCx_8_8A96lhH5cdm3rmeJfvzMJHV9k,4233
57
+ azure/ai/evaluation/_evaluators/_protected_materials/__init__.py,sha256=A12UsRVIebGvy9FtZLBPsOIAWUskBt8iuhRdILyRcSo,112
58
+ azure/ai/evaluation/_evaluators/_protected_materials/_protected_materials.py,sha256=pRB48BwbnCuozVo7hpblh_ZnApWzmrqiTx0JqhH4ioY,4204
59
+ azure/ai/evaluation/_evaluators/_qa/__init__.py,sha256=bcXfT--C0hjym2haqd1B2-u9bDciyM0ThOFtU1Q69sk,244
60
+ azure/ai/evaluation/_evaluators/_qa/_qa.py,sha256=QSpk4wKIBdwVaI0-u4iRVlnezgxhPnSEAWRUxSwOJM8,3792
61
+ azure/ai/evaluation/_evaluators/_relevance/__init__.py,sha256=JlxytW32Nl8pbE-fI3GRpfgVuY9EG6zxIAn5VZGSwyc,265
62
+ azure/ai/evaluation/_evaluators/_relevance/_relevance.py,sha256=YFLxC8VQ9kvEGK6jge7_yQCxXM1yPChy9d-dANVJA60,4507
63
+ azure/ai/evaluation/_evaluators/_relevance/relevance.prompty,sha256=AO70ho2nMhBtKcl_q4nKFW4kA1LjYsmSfymNa-Cbcrw,3735
64
+ azure/ai/evaluation/_evaluators/_rouge/__init__.py,sha256=kusCDaYcXogDugGefRP8MQSn9xv107oDbrMCqZ6K4GA,291
65
+ azure/ai/evaluation/_evaluators/_rouge/_rouge.py,sha256=IbD10QZMYzaXKqr6q4Diy7p06yhJ3kT8pMv2jnyMNtQ,3444
66
+ azure/ai/evaluation/_evaluators/_similarity/__init__.py,sha256=V2Mspog99_WBltxTkRHG5NpN5s9XoiTSN4I8POWEkLA,268
67
+ azure/ai/evaluation/_evaluators/_similarity/_similarity.py,sha256=z_mUu0lL_gZI041PZvIBgSZ9Aj7j8wUgyy5OPFlBJ_w,4495
68
+ azure/ai/evaluation/_evaluators/_similarity/similarity.prompty,sha256=p2Tb4IW6QnP2BaGRQsAicW4V0B23Oezhf5l3Hau0nxU,4770
69
+ azure/ai/evaluation/_evaluators/_xpia/__init__.py,sha256=VMEL8WrpJQeh4sQiOLzP7hRFPnjzsvwfvTzaGCVJPCM,88
70
+ azure/ai/evaluation/_evaluators/_xpia/xpia.py,sha256=-A9EpdZXr5wZzo_-cF_OX8mMAjy8AgKjNXt1D6Up0NU,5819
71
+ azure/ai/evaluation/simulator/__init__.py,sha256=4O7O6esevfOX0Vb7Eo6nl_m9Qx_WDytwfSgZ7-E1HkE,485
72
+ azure/ai/evaluation/simulator/_adversarial_scenario.py,sha256=SxpyMw5wmM5-fiUjl1_oJH0GQEnsa7ASso10MAr2Hjw,1030
73
+ azure/ai/evaluation/simulator/_adversarial_simulator.py,sha256=toUDdMOD4JrsTOh9tsFTLTBz87o6YLgoY6djXnbO7Fk,20577
74
+ azure/ai/evaluation/simulator/_constants.py,sha256=xM-Or2x7RytfoeBM3N7Vt4JQDJX66UdL3CPz0YN5rvE,485
75
+ azure/ai/evaluation/simulator/_direct_attack_simulator.py,sha256=ACd4HZBtY18stKBTGW7iHEq0hn42gNK453V_pioOcxA,11702
76
+ azure/ai/evaluation/simulator/_indirect_attack_simulator.py,sha256=4HX_034m2j8CBNBVSap9CfwKJX00l0fbvuXJyuZYavU,9639
77
+ azure/ai/evaluation/simulator/_tracing.py,sha256=svCnjlI09AQ4aNH8yeXZiE6RKg9Pi4q66oQ8LstKJBk,2968
78
+ azure/ai/evaluation/simulator/_utils.py,sha256=v-_nzpNj8RYnSyBeXcdxqu-jj1Xj_UgYdc21Gty8uwY,4219
79
+ azure/ai/evaluation/simulator/simulator.py,sha256=902a7P5DGrkN1blbCTzHGDEFhA60LlxdjVEJVVa4cSQ,28464
80
+ azure/ai/evaluation/simulator/_conversation/__init__.py,sha256=Qxu2x1cJ2fPTQtYhhNP5C4-d8P33Sru4Zn6xAgroDso,12774
81
+ azure/ai/evaluation/simulator/_conversation/_conversation.py,sha256=9a2plS1QzyuvWbJYj6rY128401e6d_n_yiBNekIDkww,7251
82
+ azure/ai/evaluation/simulator/_conversation/constants.py,sha256=3v7zkjPwJAPbSpJYIK6VOZZy70bJXMo_QTVqSFGlq9A,984
83
+ azure/ai/evaluation/simulator/_helpers/__init__.py,sha256=CD2fGrUgEE3puIm5QYqbkCN1AtntpF-3hRbF98hkhqE,203
84
+ azure/ai/evaluation/simulator/_helpers/_language_suffix_mapping.py,sha256=7BBLH78b7YDelHDLbAIwf-IO9s9cAEtn-RRXmNReHdc,1017
85
+ azure/ai/evaluation/simulator/_helpers/_simulator_data_classes.py,sha256=NjsmHy-bb0yeqKVz9j7f7KIlTEB7MeZe1NzFOLBdBm4,2531
86
+ azure/ai/evaluation/simulator/_model_tools/__init__.py,sha256=aMv5apb7uVjuhMF9ohhA5kQmo652hrGIJlhdl3y2R1I,835
87
+ azure/ai/evaluation/simulator/_model_tools/_identity_manager.py,sha256=qhYmG2r4IAKDePtf9DdqgvNGYlc0xjH4x5sShGxS-lA,5070
88
+ azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py,sha256=fHE6OUc1drkABwGQ5L0ctrqARPjv5uwO-u7yOJhdCuQ,8397
89
+ azure/ai/evaluation/simulator/_model_tools/_rai_client.py,sha256=ITPiciPQQkZa5s2E8pa-x3lKrf8rp7sbr_WSPpECOnc,6725
90
+ azure/ai/evaluation/simulator/_model_tools/_template_handler.py,sha256=hpxBYui1eaw9_lDJJMnKj8CSWFDXiTa7XAKXA4lS0J4,5482
91
+ azure/ai/evaluation/simulator/_model_tools/models.py,sha256=5pUESJR5b5rzp9W7B3Aaokz_HLHTSLjR13YKumLAxqs,21813
92
+ azure/ai/evaluation/simulator/_prompty/task_query_response.prompty,sha256=lNSioz2XiGQJb-AXRNYm2JCLMivZKa3JlHfol2Jd7fY,2244
93
+ azure/ai/evaluation/simulator/_prompty/task_simulate.prompty,sha256=00zLVfNgHZdlbC2XvBedSrwDJOaAhl3B1ohE3LKsGg4,928
94
+ azure_ai_evaluation-1.0.0b1.dist-info/METADATA,sha256=1XGkdZ7U-s9NVdHGktn_nk5S8BBUUQA-jrf-_VUpdVU,12268
95
+ azure_ai_evaluation-1.0.0b1.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
96
+ azure_ai_evaluation-1.0.0b1.dist-info/top_level.txt,sha256=S7DhWV9m80TBzAhOFjxDUiNbKszzoThbnrSz5MpbHSQ,6
97
+ azure_ai_evaluation-1.0.0b1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (74.1.3)
2
+ Generator: setuptools (72.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,172 +0,0 @@
1
- # ---------------------------------------------------------
2
- # Copyright (c) Microsoft Corporation. All rights reserved.
3
- # ---------------------------------------------------------
4
-
5
- import os
6
- import functools
7
- import inspect
8
- import logging
9
- import sys
10
- from typing import Callable, Type, TypeVar, Union, overload
11
-
12
- from typing_extensions import ParamSpec, TypeGuard
13
-
14
- DOCSTRING_TEMPLATE = ".. note:: {0} {1}\n\n"
15
- DOCSTRING_DEFAULT_INDENTATION = 8
16
- EXPERIMENTAL_CLASS_MESSAGE = "This is an experimental class,"
17
- EXPERIMENTAL_METHOD_MESSAGE = "This is an experimental method,"
18
- EXPERIMENTAL_FIELD_MESSAGE = "This is an experimental field,"
19
- EXPERIMENTAL_LINK_MESSAGE = (
20
- "and may change at any time. Please see https://aka.ms/azuremlexperimental for more information."
21
- )
22
-
23
- _warning_cache = set()
24
- module_logger = logging.getLogger(__name__)
25
-
26
- P = ParamSpec("P")
27
- T = TypeVar("T")
28
-
29
-
30
- @overload
31
- def experimental(wrapped: Type[T]) -> Type[T]: ...
32
-
33
-
34
- @overload
35
- def experimental(wrapped: Callable[P, T]) -> Callable[P, T]: ...
36
-
37
-
38
- def experimental(wrapped: Union[Type[T], Callable[P, T]]) -> Union[Type[T], Callable[P, T]]:
39
- """Add experimental tag to a class or a method.
40
-
41
- :param wrapped: Either a Class or Function to mark as experimental
42
- :type wrapped: Union[Type[T], Callable[P, T]]
43
- :return: The wrapped class or method
44
- :rtype: Union[Type[T], Callable[P, T]]
45
- """
46
-
47
- def is_class(t: Union[Type[T], Callable[P, T]]) -> TypeGuard[Type[T]]:
48
- return isinstance(t, type)
49
-
50
- if is_class(wrapped):
51
- return _add_class_docstring(wrapped)
52
- if inspect.isfunction(wrapped):
53
- return _add_method_docstring(wrapped)
54
- return wrapped
55
-
56
-
57
- def _add_class_docstring(cls: Type[T]) -> Type[T]:
58
- """Add experimental tag to the class doc string.
59
-
60
- :return: The updated class
61
- :rtype: Type[T]
62
- """
63
-
64
- P2 = ParamSpec("P2")
65
-
66
- def _add_class_warning(func: Callable[P2, None]) -> Callable[P2, None]:
67
- """Add warning message for class __init__.
68
-
69
- :param func: The original __init__ function
70
- :type func: Callable[P2, None]
71
- :return: Updated __init__
72
- :rtype: Callable[P2, None]
73
- """
74
-
75
- @functools.wraps(func)
76
- def wrapped(*args, **kwargs):
77
- message = "Class {0}: {1} {2}".format(cls.__name__, EXPERIMENTAL_CLASS_MESSAGE, EXPERIMENTAL_LINK_MESSAGE)
78
- if not _should_skip_warning() and not _is_warning_cached(message):
79
- module_logger.warning(message)
80
- return func(*args, **kwargs)
81
-
82
- return wrapped
83
-
84
- doc_string = DOCSTRING_TEMPLATE.format(EXPERIMENTAL_CLASS_MESSAGE, EXPERIMENTAL_LINK_MESSAGE)
85
- if cls.__doc__:
86
- cls.__doc__ = _add_note_to_docstring(cls.__doc__, doc_string)
87
- else:
88
- cls.__doc__ = doc_string + ">"
89
- cls.__init__ = _add_class_warning(cls.__init__) # type: ignore[method-assign]
90
- return cls
91
-
92
-
93
- def _add_method_docstring(func: Callable[P, T]) -> Callable[P, T]:
94
- """Add experimental tag to the method doc string.
95
-
96
- :param func: The function to update
97
- :type func: Callable[P, T]
98
- :return: A wrapped method marked as experimental
99
- :rtype: Callable[P,T]
100
- """
101
- doc_string = DOCSTRING_TEMPLATE.format(EXPERIMENTAL_METHOD_MESSAGE, EXPERIMENTAL_LINK_MESSAGE)
102
- if func.__doc__:
103
- func.__doc__ = _add_note_to_docstring(func.__doc__, doc_string)
104
- else:
105
- # '>' is required. Otherwise the note section can't be generated
106
- func.__doc__ = doc_string + ">"
107
-
108
- @functools.wraps(func)
109
- def wrapped(*args: P.args, **kwargs: P.kwargs) -> T:
110
- message = "Method {0}: {1} {2}".format(func.__name__, EXPERIMENTAL_METHOD_MESSAGE, EXPERIMENTAL_LINK_MESSAGE)
111
- if not _should_skip_warning() and not _is_warning_cached(message):
112
- module_logger.warning(message)
113
- return func(*args, **kwargs)
114
-
115
- return wrapped
116
-
117
-
118
- def _add_note_to_docstring(doc_string: str, note: str) -> str:
119
- """Adds experimental note to docstring at the top and correctly indents original docstring.
120
-
121
- :param doc_string: The docstring
122
- :type doc_string: str
123
- :param note: The note to add to the docstring
124
- :type note: str
125
- :return: Updated docstring
126
- :rtype: str
127
- """
128
- indent = _get_indentation_size(doc_string)
129
- doc_string = doc_string.rjust(len(doc_string) + indent)
130
- return note + doc_string
131
-
132
-
133
- def _get_indentation_size(doc_string: str) -> int:
134
- """Finds the minimum indentation of all non-blank lines after the first line.
135
-
136
- :param doc_string: The docstring
137
- :type doc_string: str
138
- :return: Minimum number of indentation of the docstring
139
- :rtype: int
140
- """
141
- lines = doc_string.expandtabs().splitlines()
142
- indent = sys.maxsize
143
- for line in lines[1:]:
144
- stripped = line.lstrip()
145
- if stripped:
146
- indent = min(indent, len(line) - len(stripped))
147
- return indent if indent < sys.maxsize else DOCSTRING_DEFAULT_INDENTATION
148
-
149
-
150
- def _should_skip_warning():
151
- skip_warning_msg = False
152
-
153
- if os.getenv("AI_EVALS_DISABLE_EXPERIMENTAL_WARNING", "false").lower() == "true":
154
- skip_warning_msg = True
155
-
156
- # Cases where we want to suppress the warning:
157
- # 1. When converting from REST object to SDK object
158
- for frame in inspect.stack():
159
- if frame.function == "_from_rest_object":
160
- skip_warning_msg = True
161
- break
162
-
163
- return skip_warning_msg
164
-
165
-
166
- def _is_warning_cached(warning_msg):
167
- # use cache to make sure we only print same warning message once under same session
168
- # this prevents duplicated warnings got printed when user does a loop call on a method or a class
169
- if warning_msg in _warning_cache:
170
- return True
171
- _warning_cache.add(warning_msg)
172
- return False