INNER CODE UNIT · Python

handle_configure_button

seratch/ChatGPT-in-Slack · main_prod.py:210

    def handle_configure_button(
        ack, body: dict, client: WebClient, context: BoltContext
    ):
        ack()
        client.views_open(
            trigger_id=body["trigger_id"],
            view=build_configure_modal(context),
        )

    def validate_api_key_registration(ack: Ack, view: dict, context: BoltContext):
        already_set_api_key = context.get("OPENAI_API_KEY")

        inputs = view["state"]["values"]
        # Try to get the API key value, but handle if the field is missing or empty
        api_key_input = inputs.get("api_key", {}).get("input", {}).get("value", None)
        # If not provided, use the already-set API key from context
        api_key = api_key_input if api_key_input else already_set_api_key
        model = inputs["model"]["input"]["selected_option"]["value"]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…