Sr. Content Developer at Microsoft, working remotely in PA, TechBash conference organizer, former Microsoft MVP, Husband, Dad and Geek.
162703 stories
·
33 followers

How To Use Method Writing To Create Better Characters

1 Share

Learn how to use method writing to create believable characters, explore their emotions, and bring your fictional world to life.

From Method Acting To Method Writing

Writers create the characters that actors play. It makes sense therefore to create a character the same way an actor prepares for a role.

Actors like Robert De Niro, Meryl Streep, and Daniel Day-Lewis have drawn on personal experiences, sensory memories, and emotions to prepare for challenging roles. T This is known as method acting.

Konstantin Stanislavski developed a system of acting that encouraged actors to explore their characters’ inner lives and motivations. His work influenced method acting, which was later developed further by teachers such as Lee Strasberg.

Writers can do the same. We can draw on similar experiences and, if we get it right, we can infuse our writing with a resonance and strength that takes the reader’s breath away.

How To Use Method Writing To Create Better Characters

  1. If you’re writing about a homeless person, imagine yourself at a time when you were completely vulnerable. Use the angst and pain, both emotional and physical, of your own experience and draw on these emotions for your homeless character.
  2. If you’re writing about a character who behaves cruelly or without remorse, remember a time when you acted against your own values. What motivated you? What did you feel afterwards? Exploring these questions can help you understand the choices people make, even when their actions are difficult to understand.
  3. If you’re writing about an optimistic person, remember a time when you believed that anything was possible. Immerse yourself in that memory. How did you feel? How did you behave? Use those details to bring your character’s optimism to life.

Rachel Ballon, author of Breathing Life Into Your Characters, explains how writers can use sensory memories to explore their characters’ emotions: ‘To engage in method writing, you need to target a sensory memory from the past in which you felt similar emotions that you want your fictional character to experience. By tapping into your memory with all of your senses, you will retrieve emotions that are always with you, but not available without relaxation and visualisation.’

Method writing is just another way to develop empathy for the characters you create. By looking within, we discover the raw material needed to create characters with internal struggles, just like we have.

If you want to convey warmth and empathy, or distance and detachment, draw on your own experiences. Remember a time when you comforted someone who was grieving. Or perhaps you were the person who needed comfort.

Authors And Characters

Your best characters reside in you – in the best and the worst parts of yourself. You need to tap into this rich internal treasure trove and use it to develop complex fictional people.

We all have different sides to our personalities. I call these ‘sub-characters’ or ‘sub-personalities’. They are the parts of ourselves that emerge in different situations and relationships. How many can you recognise in yourself?

Sub-Personalities To Use In Method Writing

  1. Amazon woman – capable, independent.
  2. Big shot – wealthy, insistent, self-important.
  3. Critic – never satisfied, negative.
  4. Dictator – pushes others into doing things they don’t want to do.
  5. Femme fatale – seductive, alluring.
  6. Hunk – a macho stud, a ladies’ man.
  7. Joker – entertaining, mischievous.
  8. Judge – censors, evaluates.
  9. Little princess – spoiled, demanding.
  10. Little professor – an intelligent child who looks for approval through academic achievement.
  11. Madonna – caretaker.
  12. Martyr – self-sacrificing.
  13. People-pleaser – needs constant approval.
  14. Perfect child – always obeys.
  15. Perfectionist – wants everything to be just right.
  16. Pygmalion – a makeover artist.
  17. Rebel – nonconformist, rule-breaker.
  18. Rescuer – always tries to save others.
  19. Victim – wants to be rescued.
  20. Vulnerable little child – defenceless.
  21. Wallflower – shy, insecure.
  22. Warrior – fights off enemies.
  23. Wise old man or woman – represents inner wisdom.
  24. Witch – unpredictable, mysterious.

We are made up of parts that are contradictory or complementary. Some parts of us resist change, while others seek new challenges. This manifests in the parts of us that are resistant to change or the taking of risks. If you want to meet your own worst enemy, look in the mirror. The same is true of your characters.

Use these sub-characters to explore different parts of yourself for your method writing.

We Can Be Better Writers

We adapt our masks to our environments. We may present different sides of ourselves at work, with friends, or at home. As you recognise these shifts as part of human behaviour, you can create characters who respond to their own circumstances in equally complex ways.

So, use your memories together with sensory details and write characters who are believable. You can start by making a sensory list about a memory:

I see:
I taste:
I touch:
I smell:
I hear:

Fill in each section with details from your memory. Then consider how you can use those details for your character’s feelings and reactions.

Examples: Using Sensory Memories In Fiction

  1. In Marcel Proust’s In Search of Lost Time, the narrator eats a madeleine dipped in tea and is suddenly transported back to childhood. The flavour unlocks memories of his aunt and the place where he grew up, bringing the past vividly back to life. What writers can learn: A sensory detail can do more than describe a scene. It can trigger a memory, reveal a character’s past, or bring buried emotions to the surface.
  2. In C. S. Lewis’s The Lion, the Witch and the Wardrobe, Edmund is tempted by Turkish Delight offered by the White Witch. His craving for more shows his weakness and makes him easier to manipulate. What writers can learn: Sensory details can reveal a character’s desires and weaknesses without explaining them directly.

The Last Word

Creating convincing characters takes careful observation, imagination, and an understanding of human behaviour. Method writing encourages authors to draw on their own memories, emotions, sensory experiences, and the different roles they play in life. By adapting these experiences and heightening certain traits, writers can create complex, believable characters whose struggles and choices feel authentic rather than stereotyped or one-dimensional.

The post How To Use Method Writing To Create Better Characters appeared first on Writers Write.

Read the whole story
alvinashcraft
4 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Which Cable Reaches the Database? A Sunday Puzzle

1 Share

Four cables cross behind a rack. Which cable reaches the database? Follow it without lifting your finger.

There is a moment in every troubleshooting call when someone says, 'The application talks straight to the database.' Sometimes that is true. Sometimes there is a cache, a proxy or a service in the middle, and the sentence skipped the interesting part.

Today's picture is a small path-finding game. Four cables leave the boxes marked A, B, C and D. On the right are DATABASE, CACHE, LOG and MONITOR. A crossing is not a junction. Keep following the same coloured cable through the crossing and name the letter that reaches DATABASE. If you are viewing this on a phone, turn it sideways if you prefer. The lines are thick on purpose.

Do not guess from where a cable begins. The paths bend. I would trace one at a time, starting at the label on the left, and stop when it reaches a box on the right. You can check your answer in the next section.

Four thick, differently coloured cables run from A through D on the left. Only one cable reaches the database on the right.

Which Cable Reaches the Database: The Answer

C reaches DATABASE. A goes to LOG, B goes to MONITOR, and D goes to CACHE. The coloured paths cross, but none splits or merges. That is why following the cable is different from looking at the most direct line across the page.

If you traced A and then jumped to C at the central crossing, you found the intended trap. It is easy to treat two touching marks as a connection. In the finished diagram each cable has its own continuous colour and a white edge at crossings so that the path can be checked rather than guessed.

Real systems have more than four tidy cables, but the habit still holds. When a request is slow, draw or verify the path it actually takes. Where does the application send the call? What sits between it and SQL Server? Is the delay on the network, in a service, or in the query itself?

The point is not to blame the network. The point is to find the right path before choosing a fix. For today, the reward is smaller: you can tell the database cable from the monitoring cable without crawling under anyone's desk.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.

First appeared on Which Cable Reaches the Database? A Sunday Puzzle

Read the whole story
alvinashcraft
4 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Python 3.15.0 added to actions/python-versions

1 Share

Python 3.15.0 added to actions/python-versions

Bit of a niche link, but I've been waiting for this for a couple of days - I even told ChatGPT to check for it:

Clone https://github.com/actions/python-versions and git pull once an hour until they add the stable 3.15 - then tell me about it

Now that this has landed, you can add "3.15" to a GitHub Actions testing matrix to run tests against the new Python 3.15.0 release.

Tags: github, python, github-actions, chatgpt

Read the whole story
alvinashcraft
4 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Plinth! My first arcade-style game.

1 Share

I just shipped Plinth, a small one-tap arcade game for Android. You stand on a column, a new column rises next to you, and you tap to stop it, ideally at your height. If you stop it too high, the extra gets sliced off, so every column after that is shorter. Stop it too low and you fall.

👉 Get Plinth on Google Play · plinth-mobile.web.app

It's built with Flutter and Flame. Here's the story!

Faking 3D to promote performance

Plinth looks 3D, but it's plain 2D canvas drawing. Every column is a box in isometric projection: three filled polygons (top, left side, right side) computed from grid coordinates.

The only real trick is draw order. Boxes further "back" have to be painted first, so each frame I sort everything by gx + gy and paint back to front (the painter's algorithm). The player gets drawn last, except when falling into a gap, where it slots into the sort so the columns in front correctly cover it.

Game feel is a pile of tiny things

The first playable version worked but felt dead. What fixed it was a slew of small touches, none of which were too hard to implement...

  • Manipulating the character on the character: a little crouch before a hop, a stretch in the air, a squash on landing.
  • A rising chime for perfect stops that climbs a scale with your streak, so a streak of perfects sounds like a melody.
  • Screen shake and debris when a column gets sliced.
  • A "NEW BEST!" moment mid-run whenever you beat your previous best score, complete with confetti.

All of the sound effects were generated with a short Python + numpy script (sine waves, envelopes, some filtered noise).

Syncing coins across devices without a backend

I wanted coins and unlocks to follow players between phones, without running a server. Google Play Games' Saved Games stores a blob per player for free, so I only needed a merge strategy for when a local copy and the cloud copy disagree.

A plain "take the max coins" merge is wrong: spend coins on one phone, sync an older copy, and you get the coins back. Instead, coins are stored as per-device running totals of earned and spent:

Each device only ever increases its own counters, so merging is just "take the max per device". Owned items merge as a union.

The rejection that taught me to test release builds

My first production submission was rejected: "Plinth keeps stopping." It had never crashed for me once. Here is where I used Claude Code to find a quick fix.

The cause: release builds run R8 (code shrinking), debug builds don't. The ads SDK pulls in an old version of WorkManager, which uses Room, which finds its generated database class by name at startup. R8 renamed it, so the app crashed before drawing a single frame:

Failed to create an instance of androidx.work.impl.WorkDatabase

The fix was a keep rule plus a newer WorkManager:

# android/app/proguard-rules.pro
-keep class * extends androidx.room.RoomDatabase { <init>(); }
// android/app/build.gradle.kts
dependencies {
    implementation("androidx.work:work-runtime:2.11.2")
}

The real lesson: before every upload, install a release build fresh on an emulator and actually play it. flutter run in debug mode tells you nothing about R8.

While testing that, I found a second problem: on a phone with no Google account signed in (like many review devices), my startup code triggered the interactive Play Games sign-in, which opened Google's full account login screen. Now the app only silently checks sign-in status at launch, and the interactive flow lives behind a "Sign in" button on the leaderboard.

Two small gotchas worth knowing

  • AdMob's app-ads.txt check vs Firebase Hosting. firebase init offers a single-page-app rewrite that sends every unknown URL to index.html with a 200 status. That means /app-ads.txt "exists" but returns HTML, and AdMob reports a mismatch. Use real files with cleanUrls and no catch-all rewrite.
  • The consent form is not optional in the EU and UK. Google's UMP SDK ships inside google_mobile_ads. Request consent before initializing ads, and add a "Privacy options" entry so players can change their choice later.

Monetization: rewarded only

Every ad in Plinth is opt-in: continue a run once, double your coins, or earn coins in the shop. No banners and no interstitials. It earns less per player than forced ads would, but I'd rather people keep playing than bounce off an ad between every run.

Try it

Plinth is free on Android: Google Play. If you give it a go, I'd love to hear your best score, and any feedback on how it feels. And if you're building something similar in Flutter and Flame, ask away in the comments.

Read the whole story
alvinashcraft
4 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Creating a Windows Service using .NET and OpenMSI

1 Share

In this article, you'll create a .NET Worker Service, configure it to run as a Windows Service, package it using OpenMSI, and generate a Windows Installer (MSI) that automatically registers and starts the service during installation.

Our Windows Service Example

Prerequisites

Before starting, ensure you have:

  • Visual Studio 2022 or later
  • .NET 8 SDK or later
  • Windows 10/11

First things first, let's create a .NET Worker Service application that will generate the executable associated with the Windows Service we want to deploy.

On Visual Studio startup window click on 'Create a new project' then search for 'worker' template and select the C# option:

Visual Studio start up window

Let's be creative and name our application as 'WindowsServiceExample':

Worker service selection

Click on 'Next' then click on 'Create' in the next dialog.

Worker service project creation

With our project created we now want to make it Windows specific so we can change the service name displayed in Windows Service console programatically. Open the NuGet package manager clicking with a right click over the project and click on 'Packages' in the context menu, then search and add the 'Microsoft.Extensions.Hosting.WindowsServices' NuGet package in 'Browse' tab.

Windows Services package

Change the initial Program.cs file so it looks like this:

namespace WindowsServiceExample
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var builder = Host
                .CreateDefaultBuilder(args)
                .UseWindowsService(options =>
                {
                    options.ServiceName = "WindowsServiceExample";
                })
                .ConfigureServices(services => {
                    services.AddHostedService<Worker>();
                });

            var host = builder.Build();
            host.Run();
        }
    }
}

The UseWindowsService extension integrates the worker application with the Windows Service Control Manager (SCM). The ServiceName value is the internal service name used by Windows when registering and managing the service.

The next step is configuring a publish profile so we can easily publish our application files. Right click on 'WindowsServiceExample' project and click on 'Publish', select the 'Folder' option then click 'Next' and 'Finish' in the next dialog.

Publish dialog

Now configure the publish profile settings clicking on 'Show all settings', in 'Profile settings' dialog set the application to be 'Self-contained' so the application includes the .NET runtime and does not require .NET to be installed on the target machine. Also, configure the application to target 'win-x64' runtime (Windows 64 bits). Click on 'Save' and publish the application.

Profile settings

The initial logic present in Worker.cs is good enough for this example, so we are done with our application, it is time to work on our installer.

Creating the Installer using OpenMSI

We will use OpenMSI to create our installer (don't worry, OpenMSI is free for non commercial and Open Source projects).

OpenMSI is a .NET tool, that means you can install it running:

dotnet tool install openmsi --global

Once the installation finishes, it is time to initialize the installer files using OpenMSI, to do that in the same directory of WindowsServiceExample.csproj file run:

openmsi init 

This command will prompt some information about the package and application:

Init prompts

Once finished, the installer package files are created, the only one we need to edit is msi-package.yaml to configure the 'package' and 'services' sections so it looks like this:

# yaml-language-server: $schema=https://openmsi.dev/schemas/openmsi-package-v1.schema.json
package:
  productName: WindowsServiceExample
  manufacturer: John Doe
  description: A simple Windows Service example
  version: 1.0.0
  productCode: fdb96b96-8b1c-4021-b9f4-3cd19cc8e67e
  upgradeCode: d9e86ff3-9a68-4b86-b351-860c65a4290b
  productIconSource: msi-package\assets\demoappmulti.ico

dialogs:
  - source: msi-package

assets:
  - name: OpenMSI_BmpTopBanner
    source: msi-package\assets\top-banner-370x44.bmp
  - name: OpenMSI_BmpBackground
    source: msi-package\assets\background-370x270.bmp
  - name: OpenMSI_IcoInfo
    source: msi-package\assets\icon-info.ico
  - name: OpenMSI_IcoWarning
    source: msi-package\assets\icon-warn.ico
  - name: OpenMSI_BmpFolderNew
    source: msi-package\assets\folder-new.bmp
  - name: OpenMSI_BmpFolderUp
    source: msi-package\assets\folder-up.bmp

files:
  - source: bin\release\net10.0\publish\win-x64
    installFolder: true

services:
  - name: WindowsServiceExample
    displayName: Windows Service Example
    description: A simple Windows Service example
    start: auto
    account: LocalSystem
    executable: WindowsServiceExample.exe

Here a summary describing the services section in more detail:

Property Description
name Internal service identifier
displayName Displayed in Services.msc
description Service description shown in Windows
start Startup type (auto, manual, disabled)
account Service execution account
executable Executable registered as the service

For simplicity this example runs under LocalSystem. Production services should use the least privileged account possible, such as LocalService, NetworkService, or a dedicated service account.

Now we just have to run:

openmsi build

OpenMSI build output

At this point you can open the Windows Service Console (services.msc) and verify the installed service:

Installation process

Or you can execute:

Get-Service WindowsServiceExample

Common Questions

  • Does the service start automatically?
  • Does it stop during uninstall?
  • Is it removed during uninstall?

OpenMSI automatically generates the Windows Installer service entries required to install, start, stop, and remove the service during the installation/removal lifecycle.

Troubleshooting

The service does not appear in Services.msc

Verify that the executable path specified in executable matches the published file name.

The service fails to start

Check Windows Event Viewer for startup errors.

MSI installs successfully but the service is not created

Ensure the services section is present in msi-package.yaml and has a valid name property.

References

Windows Service Example GitHub Repository
OpenMSI: Deploy on Windows with a modern, simple, and intuitive tool
Worker Services - .NET | Microsoft Learn

Read the whole story
alvinashcraft
5 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Introducing Microsoft-Decision-1 in Microsoft Foundry for decision and classification workloads

1 Share

Not every step in an AI application needs a large language model to generate a response. Many high-volume application steps are decisions: classify an input, select an option, assign a score, verify a condition, prioritize an item, or control a workflow. To suit these tasks, a new class of models have been developed to address these fast, structured, requests.

We are excited to be adding Microsoft-Decision-1 to the Foundry Models Catalog. Our newest, decision model for applications that need to choose among predefined options rather than generate open-ended text.

What are decision models?

As AI applications mature, the industry is moving beyond the idea that every model interaction needs to result in generated content. Developers are increasingly building systems composed of different models, tools, and application logic, each suited to a different part of the workload. Within those systems, many of the most frequent operations are not generation problems at all. They are decisions about what should happen next.

Decision models were designed for this emerging layer of the AI stack. Rather than producing an open-ended response, they evaluate a defined set of possibilities and return structured signals that an application can use to take action. That makes them particularly relevant as developers move toward more dynamic AI applications, where models need to work together and applications must continuously determine where requests should go, which actions should be taken, and when additional processing is needed.

For developers, this creates an opportunity to be more intentional about where and how different models are used. Instead of relying on a general-purpose generative model for every step, developers can match the model to the task, using generative and reasoning models where their capabilities are needed and decision models for focused, repeatable choices. The result is a more modular approach to AI application design, where generation, reasoning, and decision-making become complementary building blocks for creating intelligent systems.

What is Microsoft-Decision-1?

Now available in public preview, Microsoft-Decision-1 is a decision model built on Qwen3.5-9B and designed for applications that need to make fast, structured choices among predefined options. It brings a purpose-built decision capability to the Foundry Models catalog, giving developers another building block for designing AI applications where different steps may benefit from different types of models.

  • Built for predefined decisions. Microsoft-Decision-1 supports use cases such as agent controls, model routing, intent analysis, data labeling, AI judging, incident response routing, data validation, and content classification.
  • Structured for application logic. The model produces predefined answers and confidence signals that applications can use to select the next action or route uncertain results for further review.
  • Designed for lower-latency, lower-cost workflows. Microsoft-Decision-1 is intended for simple, repeatable, and time-sensitive decisions that do not require the generative capabilities or extended reasoning of a larger language model.

You can explore these capabilities in the Foundry Playground. This example below shows Microsoft-Decision-1 checking urgency, selecting a support team, and scoring priority for a customer request. 

Microsoft-Decision-1 in the Microsoft Foundry playground.

Microsoft-Decision-1 represents an area of continued model innovation at Microsoft. The team will rebase future iterations of the model on OpenAI models and Microsoft’s MAI models, bringing together advances from Microsoft’s own model portfolio with a model architecture purpose-built for decision-making. Over time, this work could create opportunities to further explore how Microsoft models can be specialized for the high-volume decisions that sit inside applications and agentic systems.

For developers, Microsoft-Decision-1 expands the choices available when building applications and agents with Foundry. Rather than using the same model for every step, developers can combine generative and reasoning models with a decision model and choose the capability that best fits each part of the workflow. That model diversity is increasingly important as AI applications evolve from single-model experiences into systems that coordinate specialized models, tools, and actions.

How developers are building with Microsoft-Decision-1

Enterprise applications make decisions throughout a workflow: identifying a customer’s intent, selecting a tool, routing an incident or checking whether a response meets specified criteria. For example, a support application could classify a request as a billing question, a technical issue or an account-access problem. An agent could evaluate a proposed response against a quality rubric and determine whether to accept it, revise it or request review.

If the player doesn’t load, open the video in a new window: Open video

 

These decisions can sit alongside generative and reasoning steps in the same application. A language model might draft a response, while Microsoft-Decision-1 evaluates it against defined criteria. With Microsoft-Decision-1 in the Foundry catalog, developers can explore decision workloads through the platform they use to discover and deploy models across various scenarios:

  • Classification: Assign inputs to defined categories, such as customer intents or feedback themes.
  • Routing: Select a model, tool, destination or workflow from a set of options.
  • Evaluation and verification: Assess responses or inputs against specified criteria.
  • Workflow control: Decide whether to continue, retry, stop or send a case for review.

A different model for a different kind of workload

For developers, decision models introduce a different way to think about optimization. An AI application may make thousands of small choices around a comparatively small number of complex generative or reasoning tasks. Running every one of those steps through the same general-purpose model can overlook an opportunity to optimize the system around the work each step actually needs to perform.

That pattern is showing up across Microsoft. Xbox Research used Microsoft-Decision-1 to categorize more than 10,000 pieces of open-ended feedback into researcher-defined themes, reporting quality competitive with GPT-5 while running 80–100 times faster. Other Microsoft teams have also evaluated the model for assessing Copilot response quality and supporting adaptive replanning in Microsoft Discovery.

These scenarios matter because they are not simply classification benchmarks. They are examples of decisions embedded inside larger applications. As AI architectures become more modular, developers can consider generation, reasoning, and decision-making as distinct workloads, then select models based on what each step actually requires.

For benchmark methodology, measured results and additional examples, read the Command Line blog here.

Putting Microsoft-Decision-1 to work

For tasks with predefined outcomes, evaluate Microsoft-Decision-1 using representative inputs and the quality, latency and cost requirements of your application. Compare decision accuracy, including ambiguous cases, latency under expected traffic and cost per completed decision. Where confidence estimates inform automation or review thresholds, validate their calibration on your own data.

Start with a decision in your application: The following Python example shows how to compare support-routing decisions with expected labels and measure request latency. Replace the illustrative messages and category definitions with examples from your own workload.

Before running: Deploy Microsoft-Decision-1 in your Microsoft Foundry subscription and configure FOUNDRY_BASE_URL and FOUNDRY_API_KEY. Set FOUNDRY_MODEL to the model or deployment identifier specified in the quickstart. Keep credentials outside the source code. Model requests incur applicable usage charges.

Integration note: Confirm the route and authentication header before running it against your deployment.

#!/usr/bin/env python3 """Classify support requests with Microsoft-Decision-1.""" import json import os import urllib.error import urllib.request from collections.abc import Mapping from statistics import median from time import perf_counter from typing import Any from azure.identity import DefaultAzureCredential OPTIONS = { "billing": "Charges, invoices, refunds, or subscription payments", "technical": "Software errors, bugs, or integration failures", "account": "Sign-in, password, or account-access problems", } EXAMPLES = [ ("I was charged twice.", "billing"), ("The integration crashes during checkout.", "technical"), ("I cannot sign in after resetting my password.", "account"), ] AZURE_ENDPOINT = os.environ["AZURE_ENDPOINT"].rstrip("/") DEPLOYMENT_NAME = os.environ["DEPLOYMENT_NAME"] TIMEOUT_SECONDS = 60 TOKEN_SCOPE = "https://cognitiveservices.azure.com/.default" CREDENTIAL = DefaultAzureCredential() class DecisionAPIError(RuntimeError): """Raised when the API can't return a valid classification.""" def read_choice( payload: Any, options: Mapping[str, str], ) -> str: if not isinstance(payload, dict): raise DecisionAPIError("The API returned an invalid response.") answers = payload.get("answers") if not isinstance(answers, dict): raise DecisionAPIError("The API returned no answers object.") answer = answers.get("team") if not isinstance(answer, dict) or answer.get("type") != "choice": raise DecisionAPIError("The API returned an invalid answer.") choice = answer.get("choice") if not isinstance(choice, str) or choice not in options: raise DecisionAPIError( f"The API selected an unsupported team: {choice!r}." ) return choice def predict( text: str, options: Mapping[str, str], ) -> str: if not text.strip(): raise ValueError("text must not be empty.") if len(options) < 2: raise ValueError("options must contain at least two choices.") body = json.dumps( { "model": DEPLOYMENT_NAME, "state": text, "questions": { "team": { "type": "choice", "instructions": ( "Which team should handle this customer support " "request? Select exactly one team based on the " "primary problem." ), "criteria": dict(options), } }, } ).encode("utf-8") access_token = CREDENTIAL.get_token(TOKEN_SCOPE).token request = urllib.request.Request( f"{AZURE_ENDPOINT}/providers/microsoft/v1/systemone", data=body, headers={ "Authorization": f"Bearer {access_token}", "Content-Type": "application/json", "Accept": "application/json", }, method="POST", ) try: with urllib.request.urlopen( request, timeout=TIMEOUT_SECONDS, ) as response: response_body = response.read() except urllib.error.HTTPError as exc: raise DecisionAPIError( f"The API returned HTTP {exc.code}." ) from exc except urllib.error.URLError as exc: raise DecisionAPIError( f"Couldn't reach the API: {exc.reason}." ) from exc try: payload = json.loads(response_body) except (json.JSONDecodeError, UnicodeDecodeError) as exc: raise DecisionAPIError( "The API returned invalid JSON." ) from exc return read_choice(payload, options) def main() -> None: correct = 0 latencies_ms = [] for text, expected in EXAMPLES: start = perf_counter() predicted = predict(text, OPTIONS) elapsed_ms = (perf_counter() - start) * 1000 correct += int(predicted == expected) latencies_ms.append(elapsed_ms) print( f"Expected={expected}, predicted={predicted}, " f"latency={elapsed_ms:.1f} ms" ) accuracy = correct / len(EXAMPLES) print(f"Accuracy: {accuracy:.1%}") print( "Median request latency: " f"{median(latencies_ms):.1f} ms" ) if __name__ == "__main__": main()

This small dataset illustrates the evaluation process. For meaningful results, use a larger, representative labeled dataset and inspect errors by category. The measured latency includes the client call and network time; sequential requests do not measure latency under production load. Assess cost and confidence calibration separately.

Your application defines the available options and resulting actions. Use evaluation results to determine where automation is appropriate and where additional validation or human review is needed.

Pricing

Model

Deployment Type

Input Tokens (#/1M)

Output tokens (#/1M)

Microsoft-Decision-1

US Datazone

$0.042

N/A

EU Datazone

$0.042

N/A

Get started

Explore Microsoft-Decision-1 in the Foundry catalog to make your first request. We look forward to seeing how developers use Microsoft-Decision-1 to bring structured decisions into their applications and agents through Microsoft Foundry.

Read the whole story
alvinashcraft
2 hours ago
reply
Pennsylvania, USA
Share this story
Delete
Next Page of Stories