IntelliFiller ChatGPT addon

You can use chatgpt 4 with this patch on the addon after downloading:

--- a/99999999/data_request.py
+++ b/99999999/data_request.py
@@ -9,6 +9,8 @@
 sys.path.append(vendor_dir)
 import openai
 
+import time;
+from openai import error
 
 
 from html import unescape
@@ -38,10 +40,23 @@ def send_prompt_to_openai(prompt):
     try:
         print("Request to ChatGPT: ", prompt)
         openai.api_key = config['apiKey']
-        response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": prompt}], max_tokens=2000)
-        print("Response from ChatGPT", response)
-        return response.choices[0].message.content.strip()
+
+        def try_call():
+            # gpt-3.5-turbo
+            # gpt-4o-mini, faster, cheaper, more precise, https://openai.com/api/pricing/
+            response = openai.ChatCompletion.create(model="gpt-4o-mini", messages=[{"role": "user", "content": prompt}], max_tokens=2000)
+            print("Response from ChatGPT", response)
+            return response.choices[0].message.content.strip()
+
+        maximum = 300
+        while maximum > 0:
+            maximum -= 1
+            try:
+                return try_call()
+
+            except error.RateLimitError as e:
+                time.sleep(1.0)  # gpt-4o is has a token limit
 
     except Exception as e:
-        showWarning(f"An error occurred while processing the note: {str(e)}")
+        print(f"An error occurred while processing the note: {str(e)}", file=sys.stderr)
         return None
1 Like