azure-ai-evaluation 1.0.0__py3-none-any.whl → 1.0.0b2__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 (105) hide show
  1. azure/ai/evaluation/__init__.py +5 -31
  2. azure/ai/evaluation/_common/constants.py +2 -9
  3. azure/ai/evaluation/_common/rai_service.py +120 -300
  4. azure/ai/evaluation/_common/utils.py +23 -381
  5. azure/ai/evaluation/_constants.py +6 -19
  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} +7 -23
  8. azure/ai/evaluation/_evaluate/{_batch_run → _batch_run_client}/code_client.py +17 -33
  9. azure/ai/evaluation/_evaluate/{_batch_run → _batch_run_client}/proxy_client.py +4 -32
  10. azure/ai/evaluation/_evaluate/_eval_run.py +24 -81
  11. azure/ai/evaluation/_evaluate/_evaluate.py +239 -393
  12. azure/ai/evaluation/_evaluate/_telemetry/__init__.py +17 -17
  13. azure/ai/evaluation/_evaluate/_utils.py +28 -82
  14. azure/ai/evaluation/_evaluators/_bleu/_bleu.py +18 -17
  15. azure/ai/evaluation/_evaluators/{_retrieval → _chat}/__init__.py +2 -2
  16. azure/ai/evaluation/_evaluators/_chat/_chat.py +357 -0
  17. azure/ai/evaluation/_evaluators/{_service_groundedness → _chat/retrieval}/__init__.py +2 -2
  18. azure/ai/evaluation/_evaluators/_chat/retrieval/_retrieval.py +157 -0
  19. azure/ai/evaluation/_evaluators/_chat/retrieval/retrieval.prompty +48 -0
  20. azure/ai/evaluation/_evaluators/_coherence/_coherence.py +88 -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 +67 -105
  24. azure/ai/evaluation/_evaluators/{_multimodal/_content_safety_multimodal_base.py → _content_safety/_content_safety_base.py} +34 -24
  25. azure/ai/evaluation/_evaluators/_content_safety/_content_safety_chat.py +301 -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 +54 -44
  31. azure/ai/evaluation/_evaluators/_f1_score/_f1_score.py +19 -34
  32. azure/ai/evaluation/_evaluators/_fluency/_fluency.py +89 -76
  33. azure/ai/evaluation/_evaluators/_fluency/fluency.prompty +41 -66
  34. azure/ai/evaluation/_evaluators/_gleu/_gleu.py +16 -14
  35. azure/ai/evaluation/_evaluators/_groundedness/_groundedness.py +87 -113
  36. azure/ai/evaluation/_evaluators/_groundedness/groundedness.prompty +54 -0
  37. azure/ai/evaluation/_evaluators/_meteor/_meteor.py +27 -20
  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 +30 -23
  42. azure/ai/evaluation/_evaluators/_relevance/_relevance.py +96 -84
  43. azure/ai/evaluation/_evaluators/_relevance/relevance.prompty +47 -78
  44. azure/ai/evaluation/_evaluators/_rouge/_rouge.py +27 -26
  45. azure/ai/evaluation/_evaluators/_similarity/_similarity.py +38 -53
  46. azure/ai/evaluation/_evaluators/_similarity/similarity.prompty +5 -0
  47. azure/ai/evaluation/_evaluators/_xpia/xpia.py +105 -91
  48. azure/ai/evaluation/_exceptions.py +7 -28
  49. azure/ai/evaluation/_http_utils.py +132 -203
  50. azure/ai/evaluation/_model_configurations.py +8 -104
  51. azure/ai/evaluation/_version.py +1 -1
  52. azure/ai/evaluation/simulator/__init__.py +1 -2
  53. azure/ai/evaluation/simulator/_adversarial_scenario.py +1 -20
  54. azure/ai/evaluation/simulator/_adversarial_simulator.py +92 -111
  55. azure/ai/evaluation/simulator/_constants.py +1 -11
  56. azure/ai/evaluation/simulator/_conversation/__init__.py +12 -13
  57. azure/ai/evaluation/simulator/_conversation/_conversation.py +4 -4
  58. azure/ai/evaluation/simulator/_direct_attack_simulator.py +67 -33
  59. azure/ai/evaluation/simulator/_helpers/__init__.py +2 -1
  60. azure/ai/evaluation/{_common → simulator/_helpers}/_experimental.py +9 -24
  61. azure/ai/evaluation/simulator/_helpers/_simulator_data_classes.py +5 -26
  62. azure/ai/evaluation/simulator/_indirect_attack_simulator.py +94 -107
  63. azure/ai/evaluation/simulator/_model_tools/_identity_manager.py +22 -70
  64. azure/ai/evaluation/simulator/_model_tools/_proxy_completion_model.py +11 -28
  65. azure/ai/evaluation/simulator/_model_tools/_rai_client.py +4 -8
  66. azure/ai/evaluation/simulator/_model_tools/_template_handler.py +24 -68
  67. azure/ai/evaluation/simulator/_model_tools/models.py +10 -10
  68. azure/ai/evaluation/simulator/_prompty/task_query_response.prompty +10 -6
  69. azure/ai/evaluation/simulator/_prompty/task_simulate.prompty +5 -6
  70. azure/ai/evaluation/simulator/_simulator.py +207 -277
  71. azure/ai/evaluation/simulator/_tracing.py +4 -4
  72. azure/ai/evaluation/simulator/_utils.py +13 -31
  73. azure_ai_evaluation-1.0.0b2.dist-info/METADATA +449 -0
  74. azure_ai_evaluation-1.0.0b2.dist-info/RECORD +99 -0
  75. {azure_ai_evaluation-1.0.0.dist-info → azure_ai_evaluation-1.0.0b2.dist-info}/WHEEL +1 -1
  76. azure/ai/evaluation/_common/math.py +0 -89
  77. azure/ai/evaluation/_evaluate/_batch_run/target_run_context.py +0 -46
  78. azure/ai/evaluation/_evaluators/_common/__init__.py +0 -13
  79. azure/ai/evaluation/_evaluators/_common/_base_eval.py +0 -344
  80. azure/ai/evaluation/_evaluators/_common/_base_prompty_eval.py +0 -88
  81. azure/ai/evaluation/_evaluators/_common/_base_rai_svc_eval.py +0 -133
  82. azure/ai/evaluation/_evaluators/_groundedness/groundedness_with_query.prompty +0 -113
  83. azure/ai/evaluation/_evaluators/_groundedness/groundedness_without_query.prompty +0 -99
  84. azure/ai/evaluation/_evaluators/_multimodal/__init__.py +0 -20
  85. azure/ai/evaluation/_evaluators/_multimodal/_content_safety_multimodal.py +0 -132
  86. azure/ai/evaluation/_evaluators/_multimodal/_hate_unfairness.py +0 -100
  87. azure/ai/evaluation/_evaluators/_multimodal/_protected_material.py +0 -124
  88. azure/ai/evaluation/_evaluators/_multimodal/_self_harm.py +0 -100
  89. azure/ai/evaluation/_evaluators/_multimodal/_sexual.py +0 -100
  90. azure/ai/evaluation/_evaluators/_multimodal/_violence.py +0 -100
  91. azure/ai/evaluation/_evaluators/_retrieval/_retrieval.py +0 -112
  92. azure/ai/evaluation/_evaluators/_retrieval/retrieval.prompty +0 -93
  93. azure/ai/evaluation/_evaluators/_service_groundedness/_service_groundedness.py +0 -148
  94. azure/ai/evaluation/_vendor/__init__.py +0 -3
  95. azure/ai/evaluation/_vendor/rouge_score/__init__.py +0 -14
  96. azure/ai/evaluation/_vendor/rouge_score/rouge_scorer.py +0 -328
  97. azure/ai/evaluation/_vendor/rouge_score/scoring.py +0 -63
  98. azure/ai/evaluation/_vendor/rouge_score/tokenize.py +0 -63
  99. azure/ai/evaluation/_vendor/rouge_score/tokenizers.py +0 -53
  100. azure/ai/evaluation/simulator/_data_sources/__init__.py +0 -3
  101. azure/ai/evaluation/simulator/_data_sources/grounding.json +0 -1150
  102. azure_ai_evaluation-1.0.0.dist-info/METADATA +0 -595
  103. azure_ai_evaluation-1.0.0.dist-info/NOTICE.txt +0 -70
  104. azure_ai_evaluation-1.0.0.dist-info/RECORD +0 -119
  105. {azure_ai_evaluation-1.0.0.dist-info → azure_ai_evaluation-1.0.0b2.dist-info}/top_level.txt +0 -0
@@ -6,14 +6,13 @@ import copy
6
6
  import json
7
7
  import time
8
8
  import uuid
9
- from typing import Any, Dict, List, Optional, cast
9
+ from typing import Dict, List
10
10
 
11
11
  from azure.ai.evaluation._http_utils import AsyncHttpPipeline, get_async_http_client
12
12
  from azure.ai.evaluation._user_agent import USER_AGENT
13
13
  from azure.core.exceptions import HttpResponseError
14
14
  from azure.core.pipeline.policies import AsyncRetryPolicy, RetryMode
15
15
 
16
- from .._model_tools._template_handler import TemplateParameters
17
16
  from .models import OpenAIChatCompletionsModel
18
17
 
19
18
 
@@ -34,15 +33,7 @@ class SimulationRequestDTO:
34
33
  :type template_parameters: Dict
35
34
  """
36
35
 
37
- def __init__(
38
- self,
39
- url: str,
40
- headers: Dict[str, str],
41
- payload: Dict[str, Any],
42
- params: Dict[str, str],
43
- templatekey: str,
44
- template_parameters: Optional[TemplateParameters],
45
- ):
36
+ def __init__(self, url, headers, payload, params, templatekey, template_parameters):
46
37
  self.url = url
47
38
  self.headers = headers
48
39
  self.json = json.dumps(payload)
@@ -56,12 +47,9 @@ class SimulationRequestDTO:
56
47
  :return: The DTO as a dictionary.
57
48
  :rtype: Dict
58
49
  """
59
- toReturn = self.__dict__.copy()
60
-
61
- if toReturn["templateParameters"] is not None:
62
- toReturn["templateParameters"] = {str(k): str(v) for k, v in toReturn["templateParameters"].items()}
63
-
64
- return toReturn
50
+ if self.templateParameters is not None:
51
+ self.templateParameters = {str(k): str(v) for k, v in self.templateParameters.items()}
52
+ return self.__dict__
65
53
 
66
54
  def to_json(self):
67
55
  """Convert the DTO to a JSON string.
@@ -85,12 +73,12 @@ class ProxyChatCompletionsModel(OpenAIChatCompletionsModel):
85
73
  :keyword kwargs: Additional keyword arguments to pass to the parent class.
86
74
  """
87
75
 
88
- def __init__(self, name: str, template_key: str, template_parameters: TemplateParameters, **kwargs) -> None:
76
+ def __init__(self, name: str, template_key: str, template_parameters, *args, **kwargs) -> None:
89
77
  self.tkey = template_key
90
78
  self.tparam = template_parameters
91
- self.result_url: Optional[str] = None
79
+ self.result_url = None
92
80
 
93
- super().__init__(name=name, **kwargs)
81
+ super().__init__(name=name, *args, **kwargs)
94
82
 
95
83
  def format_request_data(self, messages: List[Dict], **request_params) -> Dict: # type: ignore[override]
96
84
  """Format the request data to query the model with.
@@ -172,6 +160,7 @@ class ProxyChatCompletionsModel(OpenAIChatCompletionsModel):
172
160
  }
173
161
  # add all additional headers
174
162
  headers.update(self.additional_headers) # type: ignore[arg-type]
163
+
175
164
  params = {}
176
165
  if self.api_version:
177
166
  params["api-version"] = self.api_version
@@ -195,8 +184,8 @@ class ProxyChatCompletionsModel(OpenAIChatCompletionsModel):
195
184
  message=f"Received unexpected HTTP status: {response.status_code} {response.text()}", response=response
196
185
  )
197
186
 
198
- response_data = response.json()
199
- self.result_url = cast(str, response_data["location"])
187
+ response = response.json()
188
+ self.result_url = response["location"]
200
189
 
201
190
  retry_policy = AsyncRetryPolicy( # set up retry configuration
202
191
  retry_on_status_codes=[202], # on which statuses to retry
@@ -213,12 +202,6 @@ class ProxyChatCompletionsModel(OpenAIChatCompletionsModel):
213
202
  time.sleep(15)
214
203
 
215
204
  async with get_async_http_client().with_policies(retry_policy=retry_policy) as exp_retry_client:
216
- token = await self.token_manager.get_token_async()
217
- proxy_headers = {
218
- "Authorization": f"Bearer {token}",
219
- "Content-Type": "application/json",
220
- "User-Agent": USER_AGENT,
221
- }
222
205
  response = await exp_retry_client.get( # pylint: disable=too-many-function-args,unexpected-keyword-arg
223
206
  self.result_url, headers=proxy_headers
224
207
  )
@@ -74,18 +74,14 @@ class RAIClient: # pylint: disable=client-accepts-api-version-keyword
74
74
  timeout=5,
75
75
  )
76
76
  if response.status_code != 200:
77
- msg = (
78
- f"Failed to connect to your Azure AI project. Please check if the project scope is configured "
79
- f"correctly, and make sure you have the necessary access permissions. "
80
- f"Status code: {response.status_code}."
81
- )
77
+ msg = "Failed to retrieve the discovery service URL."
82
78
  raise EvaluationException(
83
79
  message=msg,
80
+ internal_message=msg,
84
81
  target=ErrorTarget.RAI_CLIENT,
85
- category=ErrorCategory.PROJECT_ACCESS_ERROR,
86
- blame=ErrorBlame.USER_ERROR,
82
+ category=ErrorCategory.SERVICE_UNAVAILABLE,
83
+ blame=ErrorBlame.UNKNOWN,
87
84
  )
88
-
89
85
  base_url = urlparse(response.json()["properties"]["discoveryUrl"])
90
86
  return f"{base_url.scheme}://{base_url.netloc}"
91
87
 
@@ -2,66 +2,25 @@
2
2
  # Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  # ---------------------------------------------------------
4
4
 
5
- from typing import Dict, List, Optional, TypedDict, cast
6
-
7
- from typing_extensions import NotRequired
5
+ from typing import Optional
8
6
 
9
7
  from azure.ai.evaluation._model_configurations import AzureAIProject
10
8
 
11
9
  from ._rai_client import RAIClient
12
10
 
13
- CONTENT_HARM_TEMPLATES_COLLECTION_KEY = {
14
- "adv_qa",
15
- "adv_conversation",
16
- "adv_summarization",
17
- "adv_search",
18
- "adv_rewrite",
19
- "adv_content_gen_ungrounded",
20
- "adv_content_gen_grounded",
21
- "adv_content_protected_material",
22
- "adv_politics",
23
- }
24
-
25
-
26
- class TemplateParameters(TypedDict):
27
- """Parameters used in Templates
28
-
29
- .. note::
30
-
31
- This type is good enough to type check, but is incorrect. It's meant to represent a dictionary with a known
32
- `metadata` key (Dict[str, str]), a known `ch_template_placeholder` key (str), and an unknown number of keys
33
- that map to `str` values.
34
-
35
- In typescript, this type would be spelled:
36
-
37
- .. code-block:: typescript
38
-
39
- type AdversarialTemplateParameters = {
40
- [key: string]: string
41
- ch_template_placeholder: string
42
- metadata: {[index: string]: string} # Doesn't typecheck but gets the point across
43
- }
44
-
45
- At time of writing, this isn't possible to express with a TypedDict. TypedDicts must be "closed" in that
46
- they fully specify all the keys they can contain.
47
-
48
- `PEP 728 – TypedDict with Typed Extra Items <https://peps.python.org/pep-0728/>` is a proposal to support
49
- this, but would only be available in Python 3.13 at the earliest.
50
- """
51
-
52
- metadata: Dict[str, str]
53
- conversation_starter: str
54
- ch_template_placeholder: str
55
- group_of_people: NotRequired[str]
56
- category: NotRequired[str]
57
- target_population: NotRequired[str]
58
- topic: NotRequired[str]
59
-
60
-
61
- class _CategorizedParameter(TypedDict):
62
- parameters: List[TemplateParameters]
63
- category: str
64
- parameters_key: str
11
+ CONTENT_HARM_TEMPLATES_COLLECTION_KEY = set(
12
+ [
13
+ "adv_qa",
14
+ "adv_conversation",
15
+ "adv_summarization",
16
+ "adv_search",
17
+ "adv_rewrite",
18
+ "adv_content_gen_ungrounded",
19
+ "adv_content_gen_grounded",
20
+ "adv_content_protected_material",
21
+ "adv_politics",
22
+ ]
23
+ )
65
24
 
66
25
 
67
26
  class ContentHarmTemplatesUtils:
@@ -126,19 +85,13 @@ class AdversarialTemplate:
126
85
  :param template_parameters: The template parameters.
127
86
  """
128
87
 
129
- def __init__(
130
- self,
131
- template_name: str,
132
- text: Optional[str],
133
- context_key: List,
134
- template_parameters: Optional[List[TemplateParameters]] = None,
135
- ) -> None:
88
+ def __init__(self, template_name, text, context_key, template_parameters=None) -> None:
136
89
  self.text = text
137
90
  self.context_key = context_key
138
91
  self.template_name = template_name
139
- self.template_parameters = template_parameters or []
92
+ self.template_parameters = template_parameters
140
93
 
141
- def __str__(self) -> str:
94
+ def __str__(self):
142
95
  return "{{ch_template_placeholder}}"
143
96
 
144
97
 
@@ -153,13 +106,16 @@ class AdversarialTemplateHandler:
153
106
  """
154
107
 
155
108
  def __init__(self, azure_ai_project: AzureAIProject, rai_client: RAIClient) -> None:
109
+ self.cached_templates_source = {}
110
+ # self.template_env = JinjaEnvironment(loader=JinjaFileSystemLoader(searchpath=template_dir))
156
111
  self.azure_ai_project = azure_ai_project
157
- self.categorized_ch_parameters: Optional[Dict[str, _CategorizedParameter]] = None
112
+ self.categorized_ch_parameters = None
158
113
  self.rai_client = rai_client
159
114
 
160
- async def _get_content_harm_template_collections(self, collection_key: str) -> List[AdversarialTemplate]:
115
+ async def _get_content_harm_template_collections(self, collection_key):
116
+
161
117
  if self.categorized_ch_parameters is None:
162
- categorized_parameters: Dict[str, _CategorizedParameter] = {}
118
+ categorized_parameters = {}
163
119
  util = ContentHarmTemplatesUtils
164
120
 
165
121
  parameters = await self.rai_client.get_contentharm_parameters()
@@ -167,7 +123,7 @@ class AdversarialTemplateHandler:
167
123
  for k in parameters.keys():
168
124
  template_key = util.get_template_key(k)
169
125
  categorized_parameters[template_key] = {
170
- "parameters": cast(List[TemplateParameters], parameters[k]),
126
+ "parameters": parameters[k],
171
127
  "category": util.get_template_category(k),
172
128
  "parameters_key": k,
173
129
  }
@@ -49,10 +49,10 @@ class LLMBase(ABC):
49
49
  Base class for all LLM models.
50
50
  """
51
51
 
52
- def __init__(self, endpoint_url: str, name: str = "unknown", additional_headers: Optional[Dict[str, str]] = None):
52
+ def __init__(self, endpoint_url: str, name: str = "unknown", additional_headers: Optional[dict] = {}):
53
53
  self.endpoint_url = endpoint_url
54
54
  self.name = name
55
- self.additional_headers = additional_headers or {}
55
+ self.additional_headers = additional_headers
56
56
  self.logger = logging.getLogger(repr(self))
57
57
 
58
58
  # Metric tracking
@@ -208,7 +208,7 @@ class OpenAICompletionsModel(LLMBase):
208
208
  *,
209
209
  endpoint_url: str,
210
210
  name: str = "OpenAICompletionsModel",
211
- additional_headers: Optional[Dict[str, str]] = None,
211
+ additional_headers: Optional[dict] = {},
212
212
  api_version: Optional[str] = "2023-03-15-preview",
213
213
  token_manager: APITokenManager,
214
214
  azureml_model_deployment: Optional[str] = None,
@@ -220,7 +220,7 @@ class OpenAICompletionsModel(LLMBase):
220
220
  frequency_penalty: Optional[float] = 0,
221
221
  presence_penalty: Optional[float] = 0,
222
222
  stop: Optional[Union[List[str], str]] = None,
223
- image_captions: Optional[Dict[str, str]] = None,
223
+ image_captions: Dict[str, str] = {},
224
224
  images_dir: Optional[str] = None, # Note: unused, kept for class compatibility
225
225
  ):
226
226
  super().__init__(endpoint_url=endpoint_url, name=name, additional_headers=additional_headers)
@@ -234,7 +234,7 @@ class OpenAICompletionsModel(LLMBase):
234
234
  self.n = n
235
235
  self.frequency_penalty = frequency_penalty
236
236
  self.presence_penalty = presence_penalty
237
- self.image_captions = image_captions or {}
237
+ self.image_captions = image_captions
238
238
 
239
239
  # Default stop to end token if not provided
240
240
  if not stop:
@@ -263,7 +263,7 @@ class OpenAICompletionsModel(LLMBase):
263
263
  def get_model_params(self):
264
264
  return {param: getattr(self, param) for param in self.model_param_names if getattr(self, param) is not None}
265
265
 
266
- def format_request_data(self, prompt: Dict[str, str], **request_params) -> Dict[str, str]: # type: ignore[override]
266
+ def format_request_data(self, prompt: str, **request_params) -> Dict[str, str]:
267
267
  """
268
268
  Format the request data for the OpenAI API.
269
269
  """
@@ -328,7 +328,7 @@ class OpenAICompletionsModel(LLMBase):
328
328
  # Format prompts and tag with index
329
329
  request_datas: List[Dict] = []
330
330
  for idx, prompt in enumerate(prompts):
331
- prompt = self.format_request_data(prompt, **request_params)
331
+ prompt: Dict[str, str] = self.format_request_data(prompt, **request_params)
332
332
  prompt[self.prompt_idx_key] = idx # type: ignore[assignment]
333
333
  request_datas.append(prompt)
334
334
 
@@ -447,7 +447,7 @@ class OpenAICompletionsModel(LLMBase):
447
447
 
448
448
  self._log_request(request_data)
449
449
 
450
- token = self.token_manager.get_token()
450
+ token = await self.token_manager.get_token()
451
451
 
452
452
  headers = {
453
453
  "Content-Type": "application/json",
@@ -522,8 +522,8 @@ class OpenAIChatCompletionsModel(OpenAICompletionsModel):
522
522
  formats the prompt for chat completion.
523
523
  """
524
524
 
525
- def __init__(self, name="OpenAIChatCompletionsModel", **kwargs):
526
- super().__init__(name=name, **kwargs)
525
+ def __init__(self, name="OpenAIChatCompletionsModel", *args, **kwargs):
526
+ super().__init__(name=name, *args, **kwargs)
527
527
 
528
528
  def format_request_data(self, messages: List[dict], **request_params): # type: ignore[override]
529
529
  request_data = {"messages": messages, **self.get_model_params()}
@@ -3,6 +3,11 @@ name: TaskSimulatorQueryResponse
3
3
  description: Gets queries and responses from a blob of text
4
4
  model:
5
5
  api: chat
6
+ configuration:
7
+ type: azure_openai
8
+ azure_deployment: ${env:AZURE_DEPLOYMENT}
9
+ api_key: ${env:AZURE_OPENAI_API_KEY}
10
+ azure_endpoint: ${env:AZURE_OPENAI_ENDPOINT}
6
11
  parameters:
7
12
  temperature: 0.0
8
13
  top_p: 1.0
@@ -28,16 +33,15 @@ Answer must not be more than 5 words
28
33
  Answer must be picked from Text as is
29
34
  Question should be as descriptive as possible and must include as much context as possible from Text
30
35
  Output must always have the provided number of QnAs
31
- Output must be in JSON format.
32
- Output must have {{num_queries}} objects in the format specified below. Any other count is unacceptable.
36
+ Output must be in JSON format
33
37
  Text:
34
38
  <|text_start|>
35
39
  On January 24, 1984, former Apple CEO Steve Jobs introduced the first Macintosh. In late 2003, Apple had 2.06 percent of the desktop share in the United States.
36
40
  Some years later, research firms IDC and Gartner reported that Apple's market share in the U.S. had increased to about 6%.
37
41
  <|text_end|>
38
42
  Output with 5 QnAs:
39
- {
40
- "qna":[{
43
+ [
44
+ {
41
45
  "q": "When did the former Apple CEO Steve Jobs introduced the first Macintosh?",
42
46
  "r": "January 24, 1984"
43
47
  },
@@ -56,8 +60,8 @@ Output with 5 QnAs:
56
60
  {
57
61
  "q": "What was the percentage increase of Apple's market share in the U.S., as reported by research firms IDC and Gartner?",
58
62
  "r": "6%"
59
- }]
60
- }
63
+ }
64
+ ]
61
65
  Text:
62
66
  <|text_start|>
63
67
  {{ text }}
@@ -3,6 +3,10 @@ name: TaskSimulatorWithPersona
3
3
  description: Simulates a user to complete a conversation
4
4
  model:
5
5
  api: chat
6
+ configuration:
7
+ type: azure_openai
8
+ azure_deployment: ${env:AZURE_DEPLOYMENT}
9
+ azure_endpoint: ${env:AZURE_OPENAI_ENDPOINT}
6
10
  parameters:
7
11
  temperature: 0.0
8
12
  top_p: 1.0
@@ -16,9 +20,6 @@ inputs:
16
20
  type: string
17
21
  conversation_history:
18
22
  type: dict
19
- action:
20
- type: string
21
- default: continue the converasation and make sure the task is completed by asking relevant questions
22
23
 
23
24
  ---
24
25
  system:
@@ -28,10 +29,8 @@ Output must be in JSON format
28
29
  Here's a sample output:
29
30
  {
30
31
  "content": "Here is my follow-up question.",
31
- "role": "user"
32
+ "user": "user"
32
33
  }
33
34
 
34
35
  Output with a json object that continues the conversation, given the conversation history:
35
36
  {{ conversation_history }}
36
-
37
- {{ action }}