mem0
mem0 copied to clipboard
Add Support for Customizing default_headers in Azure OpenAI
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
Hi @Dev-Khant, could you please help review the code when you have a moment? Thank you!
Hey @Dev-Khant, no problem! I’ve updated the documentation of the AzureOpenAI config page
@Zncl2222 Thanks for the contribution!!
@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?