C#을 활용한 프리셋 API
이 예제 코드는 LaaS에서 preset API를 활용하는 방법을 설명합니다.
1. 배포된 프리셋 조회
- 배포된 프리셋의 정보를 조회 할 때 사용
using System;
using System.Net.Http;
using System.Threading.Tasks;
public class PresetInfoExample
{
private static readonly HttpClient client = new HttpClient();
public static async Task RequestPresetInfoAsync()
{
string project = "YOUR_PROJECT_CODE";
string apiKey = "YOUR_API_KEY";
string hash = "YOURE_PRESET_HASH";
// Set request URL
string laasPresetUrl = $"https://api-laas.wanted.co.kr/api/preset/{hash}";
// Set the headers
client.DefaultRequestHeaders.Add("project", project);
client.DefaultRequestHeaders.Add("apiKey", apiKey);
try
{
// Make the GET request
HttpResponseMessage response = await client.GetAsync(laasPresetUrl);
response.EnsureSuccessStatusCode();
// Print the response or handle it as needed
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response: " + responseBody);
}
catch (Exception e)
{
// Handle any exceptions
Console.WriteLine(e.ToString());
}
}
}
2. Chat 호출
- 배포된 프리셋을 사용하여 LLM의 chat API를 호출