From c80157a687397a38c7390ec3d7fee034b93db963 Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Thu, 6 Feb 2025 17:32:10 +0800 Subject: [PATCH] chore: support flex response layout (#1215) * chore: support flex response layout --- dev.env | 1 - libs/appflowy-ai-client/src/dto.rs | 3 ++- libs/client-api-test/src/user.rs | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/dev.env b/dev.env index c54d08cb..b08fced2 100644 --- a/dev.env +++ b/dev.env @@ -91,7 +91,6 @@ APPFLOWY_S3_ACCESS_KEY=${AWS_ACCESS_KEY} APPFLOWY_S3_SECRET_KEY=${AWS_SECRET} APPFLOWY_S3_BUCKET=appflowy #APPFLOWY_S3_REGION=us-east-1 -APPFLOWY_S3_PRESIGNED_URL_ENDPOINT=http://localhost/minio-api # AppFlowy Cloud Mailer # Note that smtps (TLS) is always required, even for ports other than 465 diff --git a/libs/appflowy-ai-client/src/dto.rs b/libs/appflowy-ai-client/src/dto.rs index 43f9c70a..58397d7f 100644 --- a/libs/appflowy-ai-client/src/dto.rs +++ b/libs/appflowy-ai-client/src/dto.rs @@ -44,11 +44,12 @@ pub struct ResponseFormat { #[derive(Clone, Debug, Default, Serialize_repr, Deserialize_repr)] #[repr(u8)] pub enum OutputLayout { - #[default] Paragraph = 0, BulletList = 1, NumberedList = 2, SimpleTable = 3, + #[default] + Flex = 4, } #[derive(Clone, Debug, Default, Serialize_repr, Deserialize_repr, Eq, PartialEq)] diff --git a/libs/client-api-test/src/user.rs b/libs/client-api-test/src/user.rs index 7ea854ea..bab8716c 100644 --- a/libs/client-api-test/src/user.rs +++ b/libs/client-api-test/src/user.rs @@ -2,6 +2,7 @@ use crate::client::{localhost_client, LOCALHOST_GOTRUE}; use crate::log::setup_log; use client_api::Client; use lazy_static::lazy_static; +use tokio::sync::OnceCell; use uuid::Uuid; lazy_static! { @@ -12,7 +13,6 @@ lazy_static! { password: std::env::var("GOTRUE_ADMIN_PASSWORD").unwrap_or("password".to_string()), } }; - static ref ADMIN_SIGN_IN_MUTEX: tokio::sync::Mutex<()> = tokio::sync::Mutex::new(()); } #[derive(Clone, Debug)] @@ -25,20 +25,20 @@ pub fn generate_unique_email() -> String { format!("user_{}@appflowy.io", Uuid::new_v4()) } -pub async fn admin_user_client() -> Client { - let admin_client = localhost_client(); - #[cfg(target_arch = "wasm32")] - { - let msg = format!("{}", admin_client); - web_sys::console::log_1(&msg.into()); - } +static ADMIN_USER_CLIENT: OnceCell = OnceCell::const_new(); - let _guard = ADMIN_SIGN_IN_MUTEX.lock().await; - let _is_new = admin_client - .sign_in_password(&ADMIN_USER.email, &ADMIN_USER.password) +pub async fn admin_user_client() -> Client { + ADMIN_USER_CLIENT + .get_or_init(|| async { + let client = localhost_client(); + client + .sign_in_password(&ADMIN_USER.email, &ADMIN_USER.password) + .await + .expect("Failed to sign in admin user"); + client + }) .await - .unwrap(); - admin_client + .clone() } pub async fn generate_unique_registered_user() -> User {