mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

Support API key in config for LiteLLM

Open Devanshusp opened this issue 1 year ago • 4 comments

Added support for specifying the API key via the configuration object (self.config.api_key) instead of relying solely on environment variables. This change provides more flexibility in managing API keys.

Description

This update adds the ability to set the API key directly in the configuration object (self.config.api_key), instead of being limited to using environment variables. This enhancement offers more flexibility for developers by allowing API keys to be managed within their application's configuration files. This change is especially beneficial for those who prefer or require configuration-based management for sensitive information.

Fixes #1746

Type of change

  • [x] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

The changes were tested by updating the configuration object to include the API key (self.config.api_key) and verifying that the application correctly uses this key for API calls.

  • [ ] Unit Test
  • [ ] Test Script

Checklist:

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] I have made corresponding changes to the documentation
  • [x] My changes generate no new warnings
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [x] New and existing unit tests pass locally with my changes
  • [x] Any dependent changes have been merged and published in downstream modules
  • [x] I have checked my code and corrected any misspellings

Maintainer Checklist

  • [x] closes #1746 (If this is linked to an issue, replace with the correct issue number)
  • [ ] Made sure Checks passed

Devanshusp avatar Aug 25 '24 03:08 Devanshusp

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 25 '24 03:08 CLAassistant

Hey @Devanshusp you will also have to make change in mem0/llms/litellm.py where api_key can either be accepted from config or from env variables.

Dev-Khant avatar Aug 27 '24 10:08 Dev-Khant

Hey @Devanshusp Are you working on this? I have left a comment.

Dev-Khant avatar Sep 13 '24 16:09 Dev-Khant

This should be good to go. If there is an api_key provided explicitly in config, it will go as api_key param to litellm. Else the provider keys from environment variables do go anyway.

memsranga avatar Sep 17 '24 03:09 memsranga

@Devanshusp, I am closing this issue as tests are failing, and it has also been stale. Please feel free to open a new PR.

Dev-Khant avatar Oct 08 '24 06:10 Dev-Khant