Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Key roller #1106

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

palandovalex
Copy link
Contributor

Please describe the purpose of this pull request.
I added key roller fitch.
Now, in credential it can bee added multiple api keys, like this:

credentials = MemGPTCredentials(openai_key = 'sk-first,sk-second')
print(credentials.openai_key)
print(credentials.openai_key)

Output will be:
sk-first
sk-second

this can be critically necessary to prevent the "rate limit error".

Backward compatability:

credentials = MemGPTCredentials(openai_keys = 'sk-first'))
print(credentials.openai_key)
print(credentials.openai_key)

sk-first
sk-first

How to test

How can we test your PR during review? What commands should we run? What outcomes should we expect?

Have you tested this PR?

I tested lib before changes an after. Errors are identical:

============================================= short test summary info =============================================
FAILED tests/test_autogen_integration.py::test_agent_groupchat - AssertionError: Script exited with code 1: Traceback (most recent call last):
FAILED tests/test_base_functions.py::test_archival - openai.PermissionDeniedError:
FAILED tests/test_different_embedding_size.py::test_create_user - openai.PermissionDeniedError:
FAILED tests/test_load_archival.py::test_load_directory[chroma-sqlite] - UnboundLocalError: local variable 'num_passages' referenced before assignment
FAILED tests/test_metadata_store.py::test_storage[sqlite] - UnboundLocalError: local variable 'add_default_presets' referenced before assignment
FAILED tests/test_openai_client.py::test_openai_assistant - openai.APIConnectionError: Connection error.
FAILED tests/test_storage.py::test_storage[recall_memory-sqlite] - openai.PermissionDeniedError:
FAILED tests/test_storage.py::test_storage[archival_memory-chroma] - openai.PermissionDeniedError:
FAILED tests/test_summarize.py::test_summarize - requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.openai.com/v1/chat/completions
ERROR tests/test_server.py::test_load_data - AssertionError: Missing PGVECTOR_TEST_DB_URL
ERROR tests/test_server.py::test_attach_source_to_agent - AssertionError: Missing PGVECTOR_TEST_DB_URL
ERROR tests/test_server.py::test_user_message - AssertionError: Missing PGVECTOR_TEST_DB_URL
ERROR tests/test_client.py::test_create_agent[client0] - KeyError: 'user_id'
ERROR tests/test_client.py::test_user_message[client0] - KeyError: 'user_id'
ERROR tests/test_client.py::test_create_agent[client1] - KeyError: 'user_id'
ERROR tests/test_client.py::test_user_message[client1] - KeyError: 'user_id'
ERROR tests/test_server.py::test_error_on_nonexistent_agent - AssertionError: Missing PGVECTOR_TEST_DB_URL
ERROR tests/test_server.py::test_save_archival_memory - AssertionError: Missing PGVECTOR_TEST_DB_URL
ERROR tests/test_server.py::test_get_recall_memory - AssertionError: Missing PGVECTOR_TEST_DB_URL
ERROR tests/test_server.py::test_get_archival_memory - AssertionError: Missing PGVECTOR_TEST_DB_URL
=================== 9 failed, 23 passed, 2 skipped, 20 warnings, 11 errors in 124.39s (0:02:04) ===================

Related issues or PRs
i added one feature request
I am sure that if it is possible to purchase two api keys, many people will be able to work around this problems:
#155
#125

Additional context
Add any other context or screenshots about the PR here.

@palandovalex palandovalex changed the title Key roller feat: Key roller Mar 6, 2024
Copy link
Owner

@cpacker cpacker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR @palandovalex

@sarahwooders - do you think it's better to handle key rolling (eg using multiple keys) via comma splits? Ideally the credentials data class supports multiple keys per section in a more native way, but not sure how this is usually handled in a config (comma delimiting sounds pretty reasonable).

@palandovalex
Copy link
Contributor Author

I've been thinking for quite a long time about how to combine conflicting conditions:
Minimal changes in the code, backward compatibility, and of course, the simplicity and naturalness of using useful functionality. I just haven't found any other normal way out except to use the already existing fields to store delimited key groups.

The only unfortunate thing is that we had to turn to "black magic", because getting the key in the entire library code occurs precisely as an access to a field, and not as a function call. If it were otherwise, it would probably be simpler.

Oh, by the way, thanks for starting to discuss fitch. I remembered to let users know that you can use multiple keys separated by commas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

None yet

2 participants