From c4674fc98f6be6139767fd84cb9ac96a31998f8b Mon Sep 17 00:00:00 2001 From: Siddhesh Agarwal Date: Thu, 31 Oct 2024 20:39:24 +0530 Subject: [PATCH] recommended changes --- README.md | 2 +- examples/simple_memory.py | 2 +- simplemind/settings.py | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 66c09f3..3910082 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ First, authenticate your API keys by setting them in the environment variables: $ export OPENAI_API_KEY="sk-..." ``` -This pattern lets you keep your API keys private and out of your codebase. Other supported environment variables: `ANTHROPIC_API_KEY`, `XAI_API_KEY`, and `GROQ_API_KEY`. +This pattern allows you to keep your API keys private and out of your codebase. Other supported environment variables: `ANTHROPIC_API_KEY`, `XAI_API_KEY`, and `GROQ_API_KEY`. Next, import Simplemind and start using it: diff --git a/examples/simple_memory.py b/examples/simple_memory.py index c2974da..a0d119e 100644 --- a/examples/simple_memory.py +++ b/examples/simple_memory.py @@ -1,7 +1,7 @@ from _context import sm -class SimpleMemoryPlugin(sm.BasePlugin): +class SimpleMemoryPlugin: def __init__(self): self.memories = [ "the earth has fictionally beeen destroyed.", diff --git a/simplemind/settings.py b/simplemind/settings.py index b0acf98..1c35347 100644 --- a/simplemind/settings.py +++ b/simplemind/settings.py @@ -1,8 +1,19 @@ -from typing import Optional, Union +from typing import Literal, Optional, Union from pydantic import Field, SecretStr, field_validator from pydantic_settings import BaseSettings, SettingsConfigDict +logging_level = Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] + + +class LoggingConfig(BaseSettings): + """The class that holds all the logging settings for the application.""" + + enabled: bool = Field(False, description="Enable logging") + level: logging_level = Field("INFO", description="The logging level") + + model_config = SettingsConfigDict(extra="forbid") + class Settings(BaseSettings): """The class that holds all the API keys for the application.""" @@ -23,6 +34,7 @@ class Settings(BaseSettings): model_config = SettingsConfigDict( env_file=".env", env_file_encoding="utf-8", case_sensitive=True, extra="ignore" ) + logging: LoggingConfig = LoggingConfig() @field_validator("*", mode="before") @classmethod