mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

Add Support for Customizing default_headers in Azure OpenAI

Open Zncl2222 opened this issue 1 year ago • 1 comments

Description

Add support for customizing the default_headers in AzureOpenAI

Fixes #1924

Type of change

  • [x] 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"})
  • [x] Unit Test

Checklist:

  • [x] My code follows the style guidelines of this project
  • [x] 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
  • [x] My changes generate no new warnings
  • [x] 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
  • [ ] Any dependent changes have been merged and published in downstream modules
  • [x] I have checked my code and corrected any misspellings

Maintainer Checklist

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

Zncl2222 avatar Sep 28 '24 10:09 Zncl2222

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Sep 28 '24 10:09 CLAassistant

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

Zncl2222 avatar Oct 15 '24 15:10 Zncl2222

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

Zncl2222 avatar Oct 18 '24 13:10 Zncl2222

@Zncl2222 Thanks for the contribution!!

Dev-Khant avatar Oct 19 '24 10:10 Dev-Khant

@Zncl2222 do you know if these headers will work for Azure OpenAI on your data to ground your data with Azure AI Search for RAG?

farzad528 avatar Jan 25 '25 21:01 farzad528