csharp
private async void Send_Message(string message)
{
using (HttpClient client = new HttpClient())
{
var requestData = new
{
model = "llama3.2",
prompt = message,
stream = true
};
client.BaseAddress = new Uri("http://localhost:11434/api/generate");
string jsonRequest = JsonSerializer.Serialize(requestData);
var content = new StringContent(jsonRequest, System.Text.Encoding.UTF8, "application/json");
// Send post request to the model
HttpResponseMessage response = await client.PostAsync(client.BaseAddress, content);
response.EnsureSuccessStatusCode();
string jsonResponse = await response.Content.ReadAsStringAsync();
ApiResponse apiResponse = JsonSerializer.Deserialize<ApiResponse>(jsonResponse);
rtxtboxResponse.Document.Blocks.Add(new Paragraph(new Run(apiResponse.Response)));
}
}
csharp
private async void Send_Message(string message)
{
using (HttpClient client = new HttpClient())
{
var requestData = new
{
model = "llama3.2",
prompt = message,
stream = true
};
client.BaseAddress = new Uri("http://localhost:11434/api/generate");
string jsonRequest = JsonSerializer.Serialize(requestData);
var content = new StringContent(jsonRequest, System.Text.Encoding.UTF8, "application/json");
// Send post request to the model
HttpResponseMessage response = await client.PostAsync(client.BaseAddress, content);
response.EnsureSuccessStatusCode();
string jsonResponse = await response.Content.ReadAsStringAsync();
ApiResponse apiResponse = JsonSerializer.Deserialize<ApiResponse>(jsonResponse);
rtxtboxResponse.Document.Blocks.Add(new Paragraph(new Run(apiResponse.Response)));
}
}