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
// 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 |
OlderNewer