Need to mock open AI usage in VectorMemory tests. It's using openAI embeddings. Works locally with key in environment
______________________________ test_delete_vector ______________________________
mock_memory = <ix.memory.tests.mock_vector_memory.MockMemory object at 0x7f6d8f43f6d0>
def test_delete_vector(mock_memory):
> mock_memory.add_vector(key="key1", text="text1")
ix/memory/tests/test_mock_vector_memory.py:54:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
ix/memory/plugin.py:71: in add_vector
vector = get_embeddings(text)
ix/memory/plugin.py:14: in get_embeddings
response = openai.Embedding.create(input=[text], model="text-embedding-ada-002")
/usr/local/lib/python3.11/site-packages/openai/api_resources/embedding.py:33: in create
response = super().create(*args, **kwargs)
/usr/local/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py:149: in create
) = cls.__prepare_create_request(
/usr/local/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py:106: in __prepare_create_request
requestor = api_requestor.APIRequestor(
/usr/local/lib/python3.11/site-packages/openai/api_requestor.py:130: in __init__
self.api_key = key or util.default_api_key()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def default_api_key() -> str:
if openai.api_key_path:
with open(openai.api_key_path, "rt") as k:
api_key = k.read().strip()
if not api_key.startswith("sk-"):
raise ValueError(f"Malformed API key in {openai.api_key_path}.")
return api_key
elif openai.api_key is not None:
return openai.api_key
else:
> raise openai.error.AuthenticationError(
"No API key provided. You can set your API key in code using 'openai.api_key = <API-KEY>', or you can set the environment variable OPENAI_API_KEY=<API-KEY>). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = <PATH>'. You can generate API keys in the OpenAI web interface. See https://onboard.openai.com/ for details, or email support@openai.com if you have any questions."
)
E openai.error.AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key = <API-KEY>', or you can set the environment variable OPENAI_API_KEY=<API-KEY>). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = <PATH>'. You can generate API keys in the OpenAI web interface. See https://onboard.openai.com/ for details, or email support@openai.com if you have any questions.
/usr/local/lib/python3.11/site-packages/openai/util.py:186: AuthenticationError
Need to mock open AI usage in VectorMemory tests. It's using openAI embeddings. Works locally with key in environment