|
12 | 12 | import pathlib |
13 | 13 |
|
14 | 14 | from agent_framework import Content |
15 | | -from agent_framework_azure_ai import AzureAIInferenceEmbeddingClient |
| 15 | +from agent_framework.azure import AzureAIInferenceEmbeddingClient |
16 | 16 | from dotenv import load_dotenv |
17 | 17 |
|
18 | 18 | load_dotenv() |
|
24 | 24 | Images are passed as ``Content`` objects created with ``Content.from_data()``. |
25 | 25 |
|
26 | 26 | Prerequisites: |
27 | | - Set the following environment variables or add them to a .env file: |
28 | | - - AZURE_AI_INFERENCE_ENDPOINT: Your Azure AI model inference endpoint URL |
| 27 | + Deploy an embedding model in Azure AI Inference that supports image inputs, such as Cohere-embed-v3-english. |
| 28 | +
|
| 29 | + The details page for that model, has a target URI and a Key, which should be set in environment variables or a .env |
| 30 | + file as follows, the target URI should append the `/models` path: |
| 31 | + - AZURE_AI_INFERENCE_ENDPOINT: Your Azure AI model inference endpoint URL, for instance: |
| 32 | + https://<apim-instance>.azure-api.net/<foundry-instance>/models |
29 | 33 | - AZURE_AI_INFERENCE_API_KEY: Your API key |
30 | 34 | - AZURE_AI_INFERENCE_EMBEDDING_MODEL_ID: The text embedding model name |
31 | 35 | (e.g. "text-embedding-3-small") |
@@ -73,15 +77,17 @@ async def main() -> None: |
73 | 77 |
|
74 | 78 |
|
75 | 79 | """ |
76 | | -Sample output (using Cohere-embed-v3-english): |
| 80 | +Sample output (using deployment: Cohere-embed-v3-english, which is Cohere's "embed-english-v3.0-image" model): |
77 | 81 | Image embedding dimensions: 1024 |
78 | | -First 5 values: [0.023, -0.045, 0.067, -0.089, 0.011] |
79 | | -Model: Cohere-embed-v3-english |
80 | | -Usage: {'prompt_tokens': 1, 'total_tokens': 1} |
| 82 | +First 5 values: [0.029159546, -0.007926941, -0.0032978058, -0.0030403137, -0.012786865] |
| 83 | +Model: embed-english-v3.0-image |
| 84 | +Usage: {'input_token_count': 1000, 'output_token_count': 0} |
81 | 85 |
|
82 | | -Image+text (separate) results: |
83 | 86 | Text embedding dimensions: 1536 |
| 87 | +First 5 values: [-0.019439403, 0.015791258, 0.012358093, 0.0028533707, -0.01649483] |
84 | 88 | Image embedding dimensions: 1024 |
| 89 | +First 5 values: [0.029159546, -0.007926941, -0.0032978058, -0.0030403137, -0.012786865] |
85 | 90 |
|
86 | 91 | Document embedding dimensions: 1024 |
| 92 | +First 5 values: [0.029159546, -0.007926941, -0.0032978058, -0.0030403137, -0.012786865] |
87 | 93 | """ |
0 commit comments