From 7b8bd166a13c35df8ff729568a08565d0a0cbc1f Mon Sep 17 00:00:00 2001 From: Shroominic Date: Wed, 15 Nov 2023 09:34:34 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20Rename=20funcchain/settings.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- funcchain/settings.py | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 funcchain/settings.py diff --git a/funcchain/settings.py b/funcchain/settings.py new file mode 100644 index 0000000..a47c749 --- /dev/null +++ b/funcchain/settings.py @@ -0,0 +1,49 @@ +""" +Funcchain Settings: +Automatically loads environment variables from .env file +""" +from typing import Any, Optional + +from dotenv import load_dotenv +from langchain.chat_models.base import BaseChatModel +from langchain.schema.runnable import RunnableWithFallbacks +from pydantic_settings import BaseSettings + +load_dotenv("./.env") + + +class FuncchainSettings(BaseSettings): + # General + LLM: BaseChatModel | RunnableWithFallbacks | None = None + VERBOSE: bool = True + + # Prompt + MAX_TOKENS: int = 4096 + DEFAULT_SYSTEM_PROMPT: str = "You are a professional assistant solving tasks." + + # KEYS + OPENAI_API_KEY: Optional[str] = None + AZURE_API_KEY: Optional[str] = None + ANTHROPIC_API_KEY: Optional[str] = None + GOOGLE_API_KEY: Optional[str] = None + JINACHAT_API_KEY: Optional[str] = None + + # KWARGS + MODEL_NAME: str = "openai::gpt-3.5-turbo-1106" + MODEL_TEMPERATURE: float = 0.1 + MODEL_REQUEST_TIMEOUT: float = 210 + MODEL_VERBOSE: bool = False + + def model_kwargs(self) -> dict[str, Any]: + return { + "model_name": self.MODEL_NAME + if "::" not in self.MODEL_NAME + else self.MODEL_NAME.split("::")[1], + "temperature": self.MODEL_TEMPERATURE, + "verbose": self.VERBOSE, + "openai_api_key": self.OPENAI_API_KEY, + "max_tokens": self.MAX_TOKENS, + } + + +settings = FuncchainSettings()