Skip to content

Commit

Permalink
🚚 Rename funcchain/settings.py
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Nov 15, 2023
1 parent 29bd605 commit 7b8bd16
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions funcchain/settings.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 7b8bd16

Please sign in to comment.