This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get embeddings of an riddle / landmark answer | |
public async Task<IList<ReadOnlyMemory<float>>> GetEmbeddings(string answer) | |
{ | |
return await textEmbeddingGeneration.GenerateEmbeddingsAsync(new List<string> { answer }); | |
} | |
// Calculate Cosine Similarity between two answers | |
public async Task<double> CalculateSimilarity(IList<ReadOnlyMemory<float>> origEmbedding, string guessedAnswer) | |
{ | |
try |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<Riddle> GetRiddle() | |
{ | |
try | |
{ | |
string skPrompt = @"Ask an interesting new riddle with its answer in a below json format. It should only contain a JSON message and nothing else. It should not have anything racist, unethical or targeted to certain group of people. | |
{ | |
""Question"": """", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool SetSettingsToStorage(Settings settings) | |
{ | |
Preferences.Default.Set(nameof(settings.Model), settings.Model); | |
Preferences.Default.Set(nameof(settings.EndpointKey), settings.EndpointKey); | |
Preferences.Default.Set(nameof(settings.IsUseOpenAI), settings.IsUseOpenAI); | |
Preferences.Default.Set(nameof(settings.EndpointURL), settings.EndpointURL); | |
Preferences.Default.Set(nameof(settings.EmbeddingModel), settings.EmbeddingModel); | |
Preferences.Default.Set(nameof(settings.OrgId), settings.OrgId); | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<List<Country>> LoadCountries() | |
{ | |
try | |
{ | |
using var stream = await FileSystem.OpenAppPackageFileAsync("countries.json"); | |
using var reader = new StreamReader(stream); | |
var contents = reader.ReadToEnd(); | |
var countries = JsonSerializer.Deserialize<List<Country>>(contents); | |
return countries; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Simulator | |
{ | |
public class Simulator | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Simulator | |
{ | |
public class UserSimulator | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Azure.WebJobs; | |
using Microsoft.Azure.WebJobs.Extensions.Http; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.Logging; | |
using Newtonsoft.Json; | |
using System.Net.Http; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.Logging; | |
using ImmersiveReaderDemo.Models; | |
using Microsoft.IdentityModel.Clients.ActiveDirectory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task ProcessVABotAsync(ITurnContext<Microsoft.Bot.Schema.IMessageActivity> turnContext, CancellationToken cancellationToken) | |
{ | |
var token = await _botServices.VABotService.GetTokenAsync(); | |
using (var directLineClient = new DirectLineClient(token)) | |
{ | |
var conversation = await directLineClient.Conversations.StartConversationAsync(); | |
var conversationtId = conversation.ConversationId; | |
var response = await directLineClient.Conversations.PostActivityAsync(conversationtId, new Microsoft.Bot.Connector.DirectLine.Activity() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BotServices : IBotServices | |
{ | |
public BotServices(IConfiguration configuration) | |
{ | |
// Read the setting for cognitive services (LUIS, QnA) from the appsettings.json | |
// If includeApiResults is set to true, the full response from the LUIS api (LuisResult) | |
// will be made available in the properties collection of the RecognizerResult | |
VABotDispatch = new LuisRecognizer(new LuisApplication( | |
configuration["LuisAppId"], | |
configuration["LuisAPIKey"], |
NewerOlder