AI-900-Generative AI in Azure AI Foundry Portal

 Generative AI in Azure AI Foundry Portal

Step 1 : Go to the Microsoft Azure Portal and sign in using your credentials.

Step 2 : In searchbar search for Azure AI Foundry.


Step 3 : On the AI Foundry page select Create an AI Foundry Resource.


Step 4 : Add details and click create.



Step 5 : Click on Go to resource.


Click on Go to Azure AI Foundry Portal.




Step 6 : From sidebar go to the Playground.


Step 7 : Select create new deployment and select from base models.


In the searchbar search for gpt-4o.


Click Confirm.


Add details and click Deploy.



Review every menu in Chat Playground.


Add any sample Prompt.




Go to the code section and review the code.


import os import base64 from openai import AzureOpenAI from azure.identity import DefaultAzureCredential, get_bearer_token_provider endpoint = os.getenv("ENDPOINT_URL", "https://YOUR-RESOURCE-NAME.openai.azure.com/") deployment = os.getenv("DEPLOYMENT_NAME", "YOUR-DEPLOYMENT-NAME") # Initialize Azure OpenAI client with Entra ID authentication token_provider = get_bearer_token_provider( DefaultAzureCredential(), "https://cognitiveservices.azure.com/.default" ) client = AzureOpenAI( azure_endpoint=endpoint, azure_ad_token_provider=token_provider, api_version="2025-01-01-preview", ) # IMAGE_PATH = "YOUR_IMAGE_PATH" # encoded_image = base64.b64encode(open(IMAGE_PATH, 'rb').read()).decode('ascii') chat_prompt = [ { "role": "system", "content": [ { "type": "text", "text": "You are an AI assistant that helps people find information." } ] }, { "role": "user", "content": [ { "type": "text", "text": " I'm planning a trip to Paris in September. Can you help me?" } ] }, { "role": "assistant", "content": [ { "type": "text", "text": "Of course! Paris in September is a wonderful time to visit, as the weather is often pleasant and the city is alive with events. Here's a guide to help you plan your trip:\n\n---\n\n### **Weather in Paris in September**\n- **Temperature**: Average highs of around 20–23°C (68–73°F) and lows of 12–15°C (54–59°F).\n- **Rain**: Light rain is possible, so pack a travel umbrella or waterproof jacket.\n- **Clothing**: Comfortable layers for mild weather, including light jackets, scarves, and comfortable walking shoes.\n\n---\n\n### **Key Attractions**\nHere are some must-see spots in Paris:\n1. **Eiffel Tower**: Visit during the day or at night for dazzling views.\n2. **Louvre Museum**: Home to the Mona Lisa and countless masterpieces.\n3. **Notre-Dame Cathedral**: Though under restoration, it's still worth admiring from the outside.\n4. **Montmartre & Sacré-Cœur Basilica**: Explore the charming streets and enjoy panoramic views of the city.\n5. **Musée d’Orsay**: Famous for its Impressionist art collection.\n6. **Seine River Cruise**: A relaxing way to see major landmarks like the Pont Alexandre III and Notre-Dame.\n7. **Champs-Élysées & Arc de Triomphe**: Great for shopping and iconic views.\n\n---\n\n### **Events in September**\nParis has many cultural events during September:\n- **Journées du Patrimoine (Heritage Days)** (mid-September): Historic landmarks and sites that are usually closed to the public open their doors for free or discounted admission.\n- **Paris Design Week** (early to mid-September): Showcasing innovative designs and exhibitions across the city.\n- **Techno Parade** (mid-September): A vibrant outdoor music event featuring DJs and electronic music.\n- **Fashion Week Prep**: While Fashion Week is later in September, you may notice the city buzzing with designers and models.\n\n---\n\n### **Dining in Paris**\nParis offers world-class cuisine. Consider:\n- **Breakfast**: Try a classic French croissant or pain au chocolat.\n- **Lunch/Dinner**: Visit bistros for traditional dishes like coq au vin or duck confit. Don’t miss Michelin-starred restaurants if you’re seeking fine dining.\n- **Wine & Cheese**: Indulge in wine pairings with local cheeses like Brie, Camembert, or Comté.\n- **Coffee & Pastries**: Stop by cafés for a café au lait or espresso with macarons or éclairs.\n\n---\n\n### **Transportation Tips**\n- **Metro**: The easiest way to get around. Get a Navigo Easy Pass or buy a carnet (pack of 10 tickets).\n- **Walking**: Paris is a walkable city, and exploring on foot lets you discover hidden gems.\n- **Bikes**: Use the Vélib’ Métropole bike-sharing system for eco-friendly transport.\n- **Airport Transfers**: From Charles de Gaulle (CDG) or Orly (ORY), you can take RER trains, buses, or taxis.\n\n---\n\n### **Budget Tips**\n- **Museum Pass**: Consider purchasing a Paris Museum Pass for free entry to over 50 museums and monuments.\n- **Free Attractions**: Many landmarks (e.g., Sacré-Cœur, parks like Jardin des Tuileries) are free to visit.\n- **Affordable Food**: Look for prix fixe menus at local bistros for budget-friendly meals.\n\n---\n\n### **Packing List**\n- Comfortable shoes (you’ll walk a lot!)\n- Light layers for cooler evenings\n- Portable umbrella\n- Crossbody bag for safety\n- Universal power adapter (France uses Type E plugs)\n- Travel guide or offline maps app\n\n---\n\n### **Extra Tips**\n1. **Language**: Learn a few basic French phrases like:\n - Bonjour (Hello)\n - Merci (Thank you)\n - Où est…? (Where is…?)\n - Parlez-vous anglais? (Do you speak English?)\n2. **Safety**: Be mindful of pickpockets, especially in tourist areas.\n3. **Reservations**: Book popular attractions, restaurants, and tours in advance.\n4. **Tipping**: Service charge is usually included in restaurant bills, but rounding up is appreciated.\n\n---\n\nLet me know if you want help with specific places, itineraries, or anything else!" } ] } ] # Include speech result if speech is enabled messages = chat_prompt completion = client.chat.completions.create( model=deployment, messages=messages, max_tokens=6553, temperature=0.7, top_p=0.95, frequency_penalty=0, presence_penalty=0, stop=None, stream=False ) print(completion.to_json())



import os import base64 from openai import AzureOpenAI endpoint = os.getenv("ENDPOINT_URL", "https://YOUR-RESOURCE-NAME.openai.azure.com/") deployment = os.getenv("DEPLOYMENT_NAME", "YOUR-DEPLOYMENT-NAME") subscription_key = os.getenv("AZURE_OPENAI_API_KEY", "REPLACE_WITH_YOUR_KEY_VALUE_HERE") # Initialize Azure OpenAI client with key-based authentication client = AzureOpenAI( azure_endpoint=endpoint, api_key=subscription_key, api_version="2025-01-01-preview", ) # IMAGE_PATH = "YOUR_IMAGE_PATH" # encoded_image = base64.b64encode(open(IMAGE_PATH, 'rb').read()).decode('ascii') # Prepare the chat prompt chat_prompt = [ { "role": "system", "content": [ { "type": "text", "text": "You are an AI assistant that helps people find information." } ] }, { "role": "user", "content": [ { "type": "text", "text": " I'm planning a trip to Paris in September. Can you help me?" } ] }, { "role": "assistant", "content": [ { "type": "text", "text": "Of course! Paris in September is a wonderful time to visit, as the weather is often pleasant and the city is alive with events. Here's a guide to help you plan your trip:\n\n---\n\n### **Weather in Paris in September**\n- **Temperature**: Average highs of around 20–23°C (68–73°F) and lows of 12–15°C (54–59°F).\n- **Rain**: Light rain is possible, so pack a travel umbrella or waterproof jacket.\n- **Clothing**: Comfortable layers for mild weather, including light jackets, scarves, and comfortable walking shoes.\n\n---\n\n### **Key Attractions**\nHere are some must-see spots in Paris:\n1. **Eiffel Tower**: Visit during the day or at night for dazzling views.\n2. **Louvre Museum**: Home to the Mona Lisa and countless masterpieces.\n3. **Notre-Dame Cathedral**: Though under restoration, it's still worth admiring from the outside.\n4. **Montmartre & Sacré-Cœur Basilica**: Explore the charming streets and enjoy panoramic views of the city.\n5. **Musée d’Orsay**: Famous for its Impressionist art collection.\n6. **Seine River Cruise**: A relaxing way to see major landmarks like the Pont Alexandre III and Notre-Dame.\n7. **Champs-Élysées & Arc de Triomphe**: Great for shopping and iconic views.\n\n---\n\n### **Events in September**\nParis has many cultural events during September:\n- **Journées du Patrimoine (Heritage Days)** (mid-September): Historic landmarks and sites that are usually closed to the public open their doors for free or discounted admission.\n- **Paris Design Week** (early to mid-September): Showcasing innovative designs and exhibitions across the city.\n- **Techno Parade** (mid-September): A vibrant outdoor music event featuring DJs and electronic music.\n- **Fashion Week Prep**: While Fashion Week is later in September, you may notice the city buzzing with designers and models.\n\n---\n\n### **Dining in Paris**\nParis offers world-class cuisine. Consider:\n- **Breakfast**: Try a classic French croissant or pain au chocolat.\n- **Lunch/Dinner**: Visit bistros for traditional dishes like coq au vin or duck confit. Don’t miss Michelin-starred restaurants if you’re seeking fine dining.\n- **Wine & Cheese**: Indulge in wine pairings with local cheeses like Brie, Camembert, or Comté.\n- **Coffee & Pastries**: Stop by cafés for a café au lait or espresso with macarons or éclairs.\n\n---\n\n### **Transportation Tips**\n- **Metro**: The easiest way to get around. Get a Navigo Easy Pass or buy a carnet (pack of 10 tickets).\n- **Walking**: Paris is a walkable city, and exploring on foot lets you discover hidden gems.\n- **Bikes**: Use the Vélib’ Métropole bike-sharing system for eco-friendly transport.\n- **Airport Transfers**: From Charles de Gaulle (CDG) or Orly (ORY), you can take RER trains, buses, or taxis.\n\n---\n\n### **Budget Tips**\n- **Museum Pass**: Consider purchasing a Paris Museum Pass for free entry to over 50 museums and monuments.\n- **Free Attractions**: Many landmarks (e.g., Sacré-Cœur, parks like Jardin des Tuileries) are free to visit.\n- **Affordable Food**: Look for prix fixe menus at local bistros for budget-friendly meals.\n\n---\n\n### **Packing List**\n- Comfortable shoes (you’ll walk a lot!)\n- Light layers for cooler evenings\n- Portable umbrella\n- Crossbody bag for safety\n- Universal power adapter (France uses Type E plugs)\n- Travel guide or offline maps app\n\n---\n\n### **Extra Tips**\n1. **Language**: Learn a few basic French phrases like:\n - Bonjour (Hello)\n - Merci (Thank you)\n - Où est…? (Where is…?)\n - Parlez-vous anglais? (Do you speak English?)\n2. **Safety**: Be mindful of pickpockets, especially in tourist areas.\n3. **Reservations**: Book popular attractions, restaurants, and tours in advance.\n4. **Tipping**: Service charge is usually included in restaurant bills, but rounding up is appreciated.\n\n---\n\nLet me know if you want help with specific places, itineraries, or anything else!" } ] } ] # Include speech result if speech is enabled messages = chat_prompt # Generate the completion completion = client.chat.completions.create( model=deployment, messages=messages, max_tokens=6553, temperature=0.7, top_p=0.95, frequency_penalty=0, presence_penalty=0, stop=None, stream=False ) print(completion.to_json())












































Comments

Popular posts from this blog

AI-900-3,4

AI-900 12,13

AI-900 10,11