Skip to content

Instantly share code, notes, and snippets.

View vman's full-sized avatar
👨‍💻

Vardhaman Deshpande vman

👨‍💻
View GitHub Profile
🧠 REASONING SUMMARY
────────────────────
Compute distance for each segment (speed × time), add them for total distance, then divide total distance by total time to get average speed.
✅ FINAL ANSWER
────────────────────
Distance = (60 mph × 2.5 h) + (40 mph × 1.5 h) = 150 + 60 = 210 miles.
Total time = 2.5 + 1.5 = 4.0 hours.
Average speed = 210 ÷ 4.0 = 52.5 mph.
using OpenAI;
using OpenAI.Responses;
using System.ClientModel;
static string Require(string? v, string name)
=> string.IsNullOrWhiteSpace(v) ? throw new InvalidOperationException($"{name} is missing") : v;
var endpoint = Require(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"), "AZURE_OPENAI_ENDPOINT");
// Example endpoint: https://YOUR-RESOURCE-NAME.openai.azure.com
var apiKey = Require(Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY"), "AZURE_OPENAI_API_KEY");
dotnet new console -n AzureOpenAIReasoningSummary
cd AzureOpenAIReasoningSummary
dotnet add package OpenAI
# Delegated token for the signed-in user with Files.Read.All + Sites.Read.All
$token = "<ACCESS_TOKEN>"
$body = @{
queryString = "What is our paternal leave policy?"
dataSource = "sharePoint"
filterExpression = 'path:"https://contoso.sharepoint.com/sites/HR1/"'
resourceMetadata = @("title","author")
maximumNumberOfResults = 4
} | ConvertTo-Json -Depth 6
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [
{ "type": "TextBlock", "text": "${title}", "size": "Large", "weight": "Bolder" },
{ "type": "FactSet", "facts": [
{ "title": "Temperature", "value": "${current.temperature_2m} °C" },
{ "title": "Wind", "value": "${current.wind_speed_10m} km/h" },
{ "title": "Time", "value": "${current.time}" },
{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5",
"body": [
{ "type": "TextBlock", "text": "${title}", "size": "Medium", "weight": "Bolder" },
{ "type": "FactSet", "facts": [
{ "title": "Admin Area", "value": "${admin1}" },
{ "title": "Latitude", "value": "${latitude}" },
{ "title": "Longitude", "value": "${longitude}" }
import "@typespec/http";
import "@microsoft/typespec-m365-copilot";
using TypeSpec.Http;
using TypeSpec.M365.Copilot.Actions;
/* -------- Geocoding (city -> coords) -------- */
@service
@server("https://geocoding-api.open-meteo.com", "Open-Meteo Geocoding")
@actions(#{
import "@typespec/http";
import "@microsoft/typespec-m365-copilot";
import "./actions.tsp";
using TypeSpec.Http;
using TypeSpec.M365.Copilot.Agents;
@agent("Weather Helper", "Gets weather by city name using geocoding + forecast")
@instructions("""
When a user provides a city, first call searchCity to get latitude/longitude.
import "@typespec/http";
import "@typespec/openapi3";
import "@microsoft/typespec-m365-copilot";
import "./actions.tsp";
using TypeSpec.Http;
using TypeSpec.M365.Copilot;
using TypeSpec.M365.Copilot.Agents;
using TypeSpec.M365.Copilot.Actions;
{
"type": "AdaptiveCard",
"version": "1.5",
"layouts": [
{
"type": "Layout.AreaGrid",
"targetWidth": "AtLeast:Standard",
"columns": [
{
"physicalSize": 100,