updated tests, disabled send cache

This commit is contained in:
Paul Gauthier 2023-08-10 12:27:46 -03:00
parent 7eab7b54b8
commit 7924900bc4
2 changed files with 32 additions and 28 deletions

View file

@ -4,7 +4,8 @@ import json
import backoff
import openai
import requests
from diskcache import Cache
# from diskcache import Cache
from openai.error import (
APIConnectionError,
APIError,
@ -14,7 +15,8 @@ from openai.error import (
)
CACHE_PATH = "~/.aider.send.cache.v1"
CACHE = Cache(CACHE_PATH)
CACHE = None
# CACHE = Cache(CACHE_PATH)
@backoff.on_exception(
@ -53,12 +55,12 @@ def send_with_retries(model, messages, functions, stream):
# Generate SHA1 hash of kwargs and append it to chat_completion_call_hashes
hash_object = hashlib.sha1(key)
if not stream and key in CACHE:
if not stream and CACHE is not None and key in CACHE:
return hash_object, CACHE[key]
res = openai.ChatCompletion.create(**kwargs)
if not stream:
if not stream and CACHE is not None:
CACHE[key] = res
return hash_object, res