Jump to content

OpenAI Integration 1.0.1

   (0 reviews)

1 Screenshot

What's New in Version 1.0.1

Released

Added missing Assistant_ListAssistants method. 

        [HookMethod("Assistant_ListAssistants")]
        public void Assistant_ListAssistants(int limit = 20, string order = "desc", string after = null, string before = null, Action<JObject> callback = null)
        {
            var url = "https://api.openai.com/v1/assistants";
            var queryParameters = new List<string>();

            if (limit != 20) queryParameters.Add($"limit={limit}");
            if (order != "desc") queryParameters.Add($"order={order}");
            if (!string.IsNullOrEmpty(after)) queryParameters.Add($"after={after}");
            if (!string.IsNullOrEmpty(before)) queryParameters.Add($"before={before}");

            if (queryParameters.Count > 0)
            {
                url += "?" + string.Join("&", queryParameters);
            }

            try
            {
                var webClient = new WebClient();
                webClient.Headers.Add("Content-Type", "application/json");
                webClient.Headers.Add("Authorization", $"Bearer {ApiKey}");
                webClient.Headers.Add("OpenAI-Beta", "assistants=v2");

                webClient.DownloadStringCompleted += (sender, e) =>
                {
                    if (e.Error != null)
                    {
                        HandleWebClientError(e.Error);
                        callback?.Invoke(null);
                        return;
                    }

                    try
                    {
                        var response = JObject.Parse(e.Result);
                        callback?.Invoke(response);
                    }
                    catch (Exception parseEx)
                    {
                        PrintError($"Error parsing API response: {parseEx.Message}");
                        callback?.Invoke(null);
                    }
                };

                if (!_uriCache.TryGetValue(url, out Uri uri))
                {
                    uri = new Uri(url);
                    _uriCache.Add(url, uri);
                }

                webClient.DownloadStringAsync(uri);
            }
            catch (Exception ex)
            {
                PrintError($"Error initiating API request: {ex.Message}");
                callback?.Invoke(null);
            }
        }

 


GOO_'s Collection

User Feedback

1.4m

Downloads

Total number of downloads.

6.9k

Customers

Total customers served.

102.2k

Files Sold

Total number of files sold.

2m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.