Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active February 23, 2024 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/bd16d03c73b7c71a022d7d4420be1c47 to your computer and use it in GitHub Desktop.
Save bjoerntx/bd16d03c73b7c71a022d7d4420be1c47 to your computer and use it in GitHub Desktop.
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