usingvarclient=newHammingAIClient(apiKey);// List all datasets in the workspace.varresponse=awaitclient.Datasets.ListDatasetsAsync();Console.WriteLine($"Found {response.Datasets!.Count} datasets.");foreach(vardatasetinresponse.Datasets){Console.WriteLine($"- {dataset.Id}: {dataset.Name}");}
Voice Agent Testing
Shows how to run a voice agent test and retrieve experiment results.
usingvarclient=newHammingAIClient(apiKey);varagentId=Environment.GetEnvironmentVariable("HAMMING_AGENT_ID")is{Length:>0}agentValue?agentValue:thrownewAssertInconclusiveException("HAMMING_AGENT_ID environment variable is not found.");vardatasetId=Environment.GetEnvironmentVariable("HAMMING_DATASET_ID")is{Length:>0}datasetValue?datasetValue:thrownewAssertInconclusiveException("HAMMING_DATASET_ID environment variable is not found.");vartoNumber=Environment.GetEnvironmentVariable("HAMMING_TO_NUMBER")is{Length:>0}numberValue?numberValue:thrownewAssertInconclusiveException("HAMMING_TO_NUMBER environment variable is not found.");// Start a voice agent test run with the specified dataset scenarios.varrunResponse=awaitclient.VoiceAgents.RunVoiceAgentAsync(agentId:agentId,toNumber:toNumber,datasetId:datasetId);Console.WriteLine($"Voice Experiment ID: {runResponse.VoiceExperimentId}");// Check the status of the voice experiment.varstatusResponse=awaitclient.VoiceAgents.GetVoiceExperimentAsync(voiceExperimentId:runResponse.VoiceExperimentId!);Console.WriteLine($"Status: {statusResponse.Status}");// Retrieve call results once the experiment finishes.varcallsResponse=awaitclient.VoiceAgents.GetVoiceExperimentCallsAsync(voiceExperimentId:runResponse.VoiceExperimentId!);Console.WriteLine($"Calls: {callsResponse.Calls!.Count}");foreach(varcallincallsResponse.Calls){Console.WriteLine($"- Call {call.Id}: scoring={call.ScoringStatus}, duration={call.DurationMs}ms");}
Prompts
Shows how to list and retrieve prompts with their content.
1 2 3 4 5 6 7 8 910111213141516171819202122
usingvarclient=newHammingAIClient(apiKey);// List all prompts in the workspace.varpromptsList=awaitclient.Prompts.ListPromptsAsync();Console.WriteLine($"Found {promptsList.Prompts!.Count} prompts.");// Get a specific prompt by slug to see its content.if(promptsList.Prompts.Count>0){varslug=promptsList.Prompts[0].Slug!;varpromptResponse=awaitclient.Prompts.GetPromptAsync(slug:slug);varpromptValue=promptResponse.Prompt!.Value;Console.WriteLine($"Prompt slug: {promptValue.Value1?.Slug}");if(promptValue.Value2?.Contentisnotnull){Console.WriteLine($"Model: {promptValue.Value2.Content.LanguageModel}");Console.WriteLine($"Messages: {promptValue.Value2.Content.ChatMessages?.Count ?? 0}");}}
AIFunction Tools
Shows how to use HammingAI as MEAI AIFunction tools with any IChatClient.
1 2 3 4 5 6 7 8 910
usingvarclient=newHammingAIClient(apiKey);// Create AIFunction tools for use with any IChatClient.varrunTestTool=client.AsRunVoiceAgentTestTool();vargetStatusTool=client.AsGetVoiceExperimentStatusTool();vargetCallsTool=client.AsGetVoiceExperimentCallsTool();varlistDatasetsTool=client.AsListDatasetsTool();// Pass these tools to any IChatClient via ChatOptions.Tools.Console.WriteLine($"Available tools: {runTestTool.Name}, {getStatusTool.Name}, {getCallsTool.Name}, {listDatasetsTool.Name}");