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

Add Support for Customizing default_headers in Azure OpenAI #1925

Merged
merged 3 commits into from
Oct 19, 2024

Conversation

Zncl2222
Copy link
Contributor

@Zncl2222 Zncl2222 commented Sep 28, 2024

Description

Add support for customizing the default_headers in AzureOpenAI

Fixes #1924

Type of change

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

How Has This Been Tested?

Simply adding default_headers in azure_kwargs

import os
from mem0 import Memory

os.environ["LLM_AZURE_OPENAI_API_KEY"] = "your-api-key"
os.environ["LLM_AZURE_DEPLOYMENT"] = "your-deployment-name"
os.environ["LLM_AZURE_ENDPOINT"] = "your-api-base-url"
os.environ["LLM_AZURE_API_VERSION"] = "version-to-use"

config = {
    "llm": {
        "provider": "azure_openai",
        "config": {
            "model": "your-deployment-name",
            "temperature": 0.1,
            "max_tokens": 2000,
             "azure_kwargs" : {
                  "azure_deployment" : "",
                  "api_version" : "",
                  "azure_endpoint" : "",
                  "api_key" : ""
                  "default_headers": {
                      "Authorization": "xxxx",
                      "CustomHeader": "xxxx",
                   }
              }
        }
    }
}

m = Memory.from_config(config)
m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"})
  • Unit Test

Checklist:

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

Maintainer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed

@CLAassistant
Copy link

CLAassistant commented Sep 28, 2024

CLA assistant check
All committers have signed the CLA.

@Zncl2222
Copy link
Contributor Author

Hi @Dev-Khant, could you please help review the code when you have a moment? Thank you!

Copy link
Member

@Dev-Khant Dev-Khant left a comment

Choose a reason for hiding this comment

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

Hey apologies for late review, but can you please also update the doc page for showing this change?

@Zncl2222
Copy link
Contributor Author

Hey @Dev-Khant, no problem! I’ve updated the documentation of the AzureOpenAI config page

@Dev-Khant
Copy link
Member

@Zncl2222 Thanks for the contribution!!

@Dev-Khant Dev-Khant merged commit ff7761a into mem0ai:main Oct 19, 2024
5 checks passed
@Zncl2222 Zncl2222 deleted the feature/AzureOpenAI branch October 20, 2024 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Support for Customizing default_headers in Azure OpenAI
3 participants