Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: config editor #193

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

feat: config editor #193

wants to merge 7 commits into from

Conversation

MasterKenth
Copy link
Contributor

@MasterKenth MasterKenth commented Nov 19, 2024

Added ability to edit (some) settings in frontend; very cool 😎.
image

Not all settings are migrated from .env to db yet - only FIXED_PIN, OPENAI_API_KEY, BREVO_API_URL and BREVO_API_KEY right now. Migration requires changing a lot of code since settings fetching is now async/db-dependent.

BREAKING CHANGES

  • FIXED_PIN can no longer be None - instead a blank value '' means "disabled".
  • MAIL_CLIENT no longer does anything - instead Brevo is always used as long as BREVO_API_KEY is not blank ('').

@MasterKenth MasterKenth changed the title 🚧 Wip(config): edit config (env vars) in ui feat: config editor Nov 19, 2024
@@ -71,7 +72,9 @@ def create_menus() -> list:
*qa_menu(user_permissions=permissions),
*document_menu_items(user_permissions=permissions),
*assistant_menu(user_permissions=permissions),
*feedback_menu_items()]
*feedback_menu_items(),
*mock_menu(user_permissions=permissions),
Copy link
Contributor

@dannil76 dannil76 Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

behöver vi mock_menu? Togs bort för att säkra upp o skippa onödigt. :)


from pydantic import BaseModel

SettingsDict = Dict[str, bool | float | int | str] # Note: order of types is important!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vore fint att få veta varför? 👯‍♂️ :)

Comment on lines +34 to +35
console.log('Try setup settings')
await setup_settings()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting an error where setup_settings is called before project is created.

The error occurs when code is tested with clean DB (empty MongoDB).

Shuffling the order fixes the problem for me:

@asynccontextmanager
async def lifespan(_app: FastAPI):
    console.log('Try setup db')
    await setup_db()
    console.log('Try setup initial project')
    await setup_project()
    console.log('Try setup settings')
    await setup_settings()
    console.log('Try setup Sentry')
    await setup_sentry()
    console.log('Try setup file parser environment')
    await setup_file_parser()
    yield
    console.log('😴 Unmounting app ...')
    console.log('Shutting down Sentry')
    client = Hub.current.client
    if client is not None:
        client.close(timeout=2.0)

payload = BrevoPayload.model_validate(payload.model_dump())
settings_service = SettingsServiceFactory().get_service()
url = await settings_service.get_value(SettingKey.BREVO_API_URL)
key = await settings_service.get_value(SettingKey.BREVO_API_KEY)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

send_mail raises requests.exceptions.InvalidHeader: Header part (SecretStr('**********')) from ('api-key', SecretStr('**********')) must be of type str or bytes, not <class 'pydantic.types.SecretStr'>

Might be cause by my test environment. There is a value set for FIXED_PIN in my .env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants