Skip to content

Commit 94fa30e

Browse files
committed
Update docs metadata
1 parent 5506e3d commit 94fa30e

File tree

2 files changed

+42
-42
lines changed

2 files changed

+42
-42
lines changed

docs-ref-services/preview/ai-evaluation-readme.md

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
title: Azure AI Evaluation client library for Python
33
keywords: Azure, python, SDK, API, azure-ai-evaluation, evaluation
4-
ms.date: 10/01/2024
4+
ms.date: 10/16/2024
55
ms.topic: reference
66
ms.devlang: python
77
ms.service: evaluation
88
---
9-
# Azure AI Evaluation client library for Python - version 1.0.0b3
9+
# Azure AI Evaluation client library for Python - version 1.0.0b4
1010

1111

1212
We are excited to introduce the public preview of the Azure AI Evaluation SDK.
@@ -128,11 +128,6 @@ name: ApplicationPrompty
128128
description: Simulates an application
129129
model:
130130
api: chat
131-
configuration:
132-
type: azure_openai
133-
azure_deployment: ${env:AZURE_DEPLOYMENT}
134-
api_key: ${env:AZURE_OPENAI_API_KEY}
135-
azure_endpoint: ${env:AZURE_OPENAI_ENDPOINT}
136131
parameters:
137132
temperature: 0.0
138133
top_p: 1.0
@@ -161,52 +156,55 @@ import asyncio
161156
from typing import Any, Dict, List, Optional
162157
from azure.ai.evaluation.simulator import Simulator
163158
from promptflow.client import load_flow
164-
from azure.identity import DefaultAzureCredential
165159
import os
160+
import wikipedia
166161

167-
azure_ai_project = {
168-
"subscription_id": os.environ.get("AZURE_SUBSCRIPTION_ID"),
169-
"resource_group_name": os.environ.get("RESOURCE_GROUP"),
170-
"project_name": os.environ.get("PROJECT_NAME")
162+
# Set up the model configuration without api_key, using DefaultAzureCredential
163+
model_config = {
164+
"azure_endpoint": os.environ.get("AZURE_OPENAI_ENDPOINT"),
165+
"azure_deployment": os.environ.get("AZURE_DEPLOYMENT"),
166+
# not providing key would make the SDK pick up `DefaultAzureCredential`
167+
# use "api_key": "<your API key>"
171168
}
172169

173-
import wikipedia
174-
wiki_search_term = "Leonardo da vinci"
170+
# Use Wikipedia to get some text for the simulation
171+
wiki_search_term = "Leonardo da Vinci"
175172
wiki_title = wikipedia.search(wiki_search_term)[0]
176173
wiki_page = wikipedia.page(wiki_title)
177174
text = wiki_page.summary[:1000]
178175

179-
def method_to_invoke_application_prompty(query: str):
176+
def method_to_invoke_application_prompty(query: str, messages_list: List[Dict], context: Optional[Dict]):
180177
try:
181178
current_dir = os.path.dirname(__file__)
182179
prompty_path = os.path.join(current_dir, "application.prompty")
183-
_flow = load_flow(source=prompty_path, model={
184-
"configuration": azure_ai_project
185-
})
180+
_flow = load_flow(
181+
source=prompty_path,
182+
model=model_config,
183+
credential=DefaultAzureCredential()
184+
)
186185
response = _flow(
187186
query=query,
188187
context=context,
189188
conversation_history=messages_list
190189
)
191190
return response
192-
except:
193-
print("Something went wrong invoking the prompty")
191+
except Exception as e:
192+
print(f"Something went wrong invoking the prompty: {e}")
194193
return "something went wrong"
195194

196195
async def callback(
197-
messages: List[Dict],
196+
messages: Dict[str, List[Dict]],
198197
stream: bool = False,
199198
session_state: Any = None, # noqa: ANN401
200199
context: Optional[Dict[str, Any]] = None,
201200
) -> dict:
202201
messages_list = messages["messages"]
203-
# get last message
202+
# Get the last message from the user
204203
latest_message = messages_list[-1]
205204
query = latest_message["content"]
206-
context = None
207-
# call your endpoint or ai application here
208-
response = method_to_invoke_application_prompty(query)
209-
# we are formatting the response to follow the openAI chat protocol format
205+
# Call your endpoint or AI application here
206+
response = method_to_invoke_application_prompty(query, messages_list, context)
207+
# Format the response to follow the OpenAI chat protocol format
210208
formatted_response = {
211209
"content": response,
212210
"role": "assistant",
@@ -217,10 +215,8 @@ async def callback(
217215
messages["messages"].append(formatted_response)
218216
return {"messages": messages["messages"], "stream": stream, "session_state": session_state, "context": context}
219217

220-
221-
222218
async def main():
223-
simulator = Simulator(azure_ai_project=azure_ai_project, credential=DefaultAzureCredential())
219+
simulator = Simulator(model_config=model_config)
224220
outputs = await simulator(
225221
target=callback,
226222
text=text,
@@ -231,17 +227,17 @@ async def main():
231227
f"I am a teacher and I want to teach my students about {wiki_search_term}"
232228
],
233229
)
234-
print(json.dumps(outputs))
230+
print(json.dumps(outputs, indent=2))
235231

236232
if __name__ == "__main__":
237-
os.environ["AZURE_SUBSCRIPTION_ID"] = ""
238-
os.environ["RESOURCE_GROUP"] = ""
239-
os.environ["PROJECT_NAME"] = ""
240-
os.environ["AZURE_OPENAI_API_KEY"] = ""
241-
os.environ["AZURE_OPENAI_ENDPOINT"] = ""
242-
os.environ["AZURE_DEPLOYMENT"] = ""
233+
# Ensure that the following environment variables are set in your environment:
234+
# AZURE_OPENAI_ENDPOINT and AZURE_DEPLOYMENT
235+
# Example:
236+
# os.environ["AZURE_OPENAI_ENDPOINT"] = "https://your-endpoint.openai.azure.com/"
237+
# os.environ["AZURE_DEPLOYMENT"] = "your-deployment-name"
243238
asyncio.run(main())
244239
print("done!")
240+
245241
```
246242

247243
#### Adversarial Simulator
@@ -380,18 +376,18 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
380376

381377
<!-- LINKS -->
382378

383-
[source_code]: https://github.com/Azure/azure-sdk-for-python/tree/azure-ai-evaluation_1.0.0b3/sdk/evaluation/azure-ai-evaluation
379+
[source_code]: https://github.com/Azure/azure-sdk-for-python/tree/azure-ai-evaluation_1.0.0b4/sdk/evaluation/azure-ai-evaluation
384380
[evaluation_pypi]: https://pypi.org/project/azure-ai-evaluation/
385381
[evaluation_ref_docs]: https://learn.microsoft.com/python/api/azure-ai-evaluation/azure.ai.evaluation?view=azure-python-preview
386382
[evaluation_samples]: https://github.com/Azure-Samples/azureai-samples/tree/main/scenarios
387383
[product_documentation]: https://learn.microsoft.com/azure/ai-studio/how-to/develop/evaluate-sdk
388384
[python_logging]: https://docs.python.org/3/library/logging.html
389385
[sdk_logging_docs]: /azure/developer/python/azure-sdk-logging
390-
[azure_core_readme]: https://github.com/Azure/azure-sdk-for-python/blob/azure-ai-evaluation_1.0.0b3/sdk/core/azure-core/README.md
386+
[azure_core_readme]: https://github.com/Azure/azure-sdk-for-python/blob/azure-ai-evaluation_1.0.0b4/sdk/core/azure-core/README.md
391387
[pip_link]: https://pypi.org/project/pip/
392388
[azure_core_ref_docs]: https://aka.ms/azsdk-python-core-policies
393-
[azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/azure-ai-evaluation_1.0.0b3/sdk/core/azure-core/README.md
394-
[azure_identity]: https://github.com/Azure/azure-sdk-for-python/tree/azure-ai-evaluation_1.0.0b3/sdk/identity/azure-identity
389+
[azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/azure-ai-evaluation_1.0.0b4/sdk/core/azure-core/README.md
390+
[azure_identity]: https://github.com/Azure/azure-sdk-for-python/tree/azure-ai-evaluation_1.0.0b4/sdk/identity/azure-identity
395391
[cla]: https://cla.microsoft.com
396392
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
397393
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/

metadata/preview/azure-ai-evaluation.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Name": "azure-ai-evaluation",
3-
"Version": "1.0.0b3",
3+
"Version": "1.0.0b4",
44
"DevVersion": null,
55
"DirectoryPath": "sdk/evaluation/azure-ai-evaluation",
66
"ServiceDirectory": "evaluation",
@@ -10,11 +10,15 @@
1010
"SdkType": "client",
1111
"IsNewSdk": true,
1212
"ArtifactName": "azure-ai-evaluation",
13-
"ReleaseStatus": "2024-10-01",
13+
"ReleaseStatus": "2024-10-16",
1414
"IncludedForValidation": false,
1515
"AdditionalValidationPackages": [
1616
""
1717
],
18+
"ArtifactDetails": {
19+
"name": "azure-ai-evaluation",
20+
"safeName": "azureaievaluation"
21+
},
1822
"Namespaces": [
1923
"azure.ai.evaluation"
2024
]

0 commit comments

Comments
 (0)