From 21642df361b3d8f12c611f427b945ad22181a311 Mon Sep 17 00:00:00 2001 From: Tarishi Jain Date: Mon, 27 Jan 2025 22:13:53 +0530 Subject: [PATCH] introduce open api config --- mem0/llms/litellm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mem0/llms/litellm.py b/mem0/llms/litellm.py index d5896ff80b..74f06027a2 100644 --- a/mem0/llms/litellm.py +++ b/mem0/llms/litellm.py @@ -1,4 +1,5 @@ import json +import os from typing import Dict, List, Optional try: @@ -16,7 +17,8 @@ def __init__(self, config: Optional[BaseLlmConfig] = None): if not self.config.model: self.config.model = "gpt-4o-mini" - + if not self.config.api_key: + self.config.api_key = os.environ["OPENAI_API_KEY"] def _parse_response(self, response, tools): """ Process the response based on whether tools are used or not. @@ -75,6 +77,7 @@ def generate_response( "temperature": self.config.temperature, "max_tokens": self.config.max_tokens, "top_p": self.config.top_p, + "api_key": self.config.api_key, } if response_format: params["response_format"] = response_format