Open yarmoliq opened 2 days ago
Hi. When our application is deployed on aws, the .CompleteChatAsync method stops working. Locally everything works fine. The timeout is configured
public class OpenAiService { private readonly string apiKey = ConfigurationManager.AppSettings["openai.apikey"]; private readonly string model = ConfigurationManager.AppSettings["openai.model"]; private readonly float temperature = Convert.ToSingle(ConfigurationManager.AppSettings["openai.temperature"]); private readonly int timeout = Convert.ToInt32(ConfigurationManager.AppSettings["openai.timeout"]); private ChatClient client; public OpenAiService() { var options = new OpenAIClientOptions() { NetworkTimeout = TimeSpan.FromSeconds(timeout), }; client = new ChatClient(model, apiKey, options); ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11; ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12; } public async Task<string> SendRequestToOpenAiAsync(OpenAI.Chat.ChatMessage[] messages) { try { var completion = await client.CompleteChatAsync(messages); return completion.Value.Content[0].Text; } catch (Exception ex) { Log.SaveLog($"OPENAI request error occurred:"); Log.SaveLog(ex.Message + ex.StackTrace + ex.Source); return null; } } }
but still no exceptions at all. The application just freezes.
When switched to .CompleteChat, everything starts working when deployed.
2024/06/28 09:21:19 Running start turn for turn 145163 2024/06/28 09:21:21 1 2024/06/28 09:21:26 2 2024/06/28 09:21:26 Finished running start turn for turn 145163 2024/06/28 09:21:27 Successfully sent email *** after changing CompleteChat to CompleteChatAsync 2024/06/28 09:23:47 Running start turn for turn 145163 2024/06/28 09:23:49 1
Hi. When our application is deployed on aws, the .CompleteChatAsync method stops working. Locally everything works fine. The timeout is configured
but still no exceptions at all. The application just freezes.
When switched to .CompleteChat, everything starts working when deployed.