Last active
February 23, 2024 13:57
-
-
Save bjoerntx/bd16d03c73b7c71a022d7d4420be1c47 to your computer and use it in GitHub Desktop.
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 static string GetAnswer(string chunk, string question) | |
{ | |
// create a prompt | |
string prompt = $"```{chunk}```Your source is the information above. What is the answer to the following question? ```{question}```"; | |
// create a request object | |
Request apiRequest = new Request | |
{ | |
Messages = new[] | |
{ | |
new RequestMessage | |
{ | |
Role = "system", | |
Content = "You should help to find an answer to a question in a document." | |
}, | |
new RequestMessage | |
{ | |
Role = "user", | |
Content = prompt | |
} | |
} | |
}; | |
// get the response | |
if (GetResponse(apiRequest) is Response response) | |
{ | |
// return the answer | |
return response.Choices[0].Message.Content; | |
} | |
// return null if the response is null | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment