chore: support explain text (#1213)

This commit is contained in:
Nathan.fooo 2025-02-06 12:56:15 +08:00 committed by GitHub
parent fdb7d62d0c
commit a7dff1b7d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 34 additions and 7 deletions

View File

@ -104,6 +104,7 @@ jobs:
sed -i "s|AI_AWS_SECRET_ACCESS_KEY=.*|AI_AWS_SECRET_ACCESS_KEY=${{ secrets.LOCAL_AI_AWS_SECRET_ACCESS_KEY }}|" .env sed -i "s|AI_AWS_SECRET_ACCESS_KEY=.*|AI_AWS_SECRET_ACCESS_KEY=${{ secrets.LOCAL_AI_AWS_SECRET_ACCESS_KEY }}|" .env
sed -i 's|AI_APPFLOWY_HOST=.*|AI_APPFLOWY_HOST=http://localhost|' .env sed -i 's|AI_APPFLOWY_HOST=.*|AI_APPFLOWY_HOST=http://localhost|' .env
sed -i 's|APPFLOWY_WEB_URL=.*|APPFLOWY_WEB_URL=http://localhost:3000|' .env sed -i 's|APPFLOWY_WEB_URL=.*|APPFLOWY_WEB_URL=http://localhost:3000|' .env
sed -i 's|.*APPFLOWY_S3_PRESIGNED_URL_ENDPOINT=.*|APPFLOWY_S3_PRESIGNED_URL_ENDPOINT=http://localhost/minio-api|' .env
shell: bash shell: bash
- name: Update Nginx Configuration - name: Update Nginx Configuration

View File

@ -147,6 +147,7 @@ pub enum CompletionType {
MakeShorter = 3, MakeShorter = 3,
MakeLonger = 4, MakeLonger = 4,
ContinueWriting = 5, ContinueWriting = 5,
Explain = 6,
} }
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]

View File

@ -5,6 +5,28 @@ use appflowy_ai_client::dto::{
ResponseFormat, ResponseFormat,
}; };
#[tokio::test]
async fn completion_explain_test() {
let client = appflowy_ai_client();
let params = CompleteTextParams {
text: "Snowboarding".to_string(),
completion_type: Some(CompletionType::Explain),
custom_prompt: None,
metadata: Some(CompletionMetadata {
object_id: uuid::Uuid::new_v4().to_string(),
workspace_id: Some(uuid::Uuid::new_v4().to_string()),
rag_ids: None,
}),
format: ResponseFormat::default(),
};
let stream = client
.stream_completion_text(params, "gpt-4o-mini")
.await
.unwrap();
let text = collect_stream_text(stream).await;
assert!(!text.is_empty());
}
#[tokio::test] #[tokio::test]
async fn completion_image_test() { async fn completion_image_test() {
let client = appflowy_ai_client(); let client = appflowy_ai_client();

View File

@ -90,6 +90,13 @@ impl AwsS3BucketClientImpl {
.map_or(url.clone(), |presigned| { .map_or(url.clone(), |presigned| {
url.replace(&self.endpoint, presigned) url.replace(&self.endpoint, presigned)
}); });
trace!(
"generated presigned url: {}, public presigned url:{}, endpoint:{}, presigned_url_endpoint:{:?}",
url,
public_url,
self.endpoint,
self.presigned_url_endpoint
);
Ok(public_url) Ok(public_url)
} }

View File

@ -193,10 +193,6 @@ async fn upload_file(
.await? .await?
.presigned_url; .presigned_url;
// if url.contains("http://minio:9000") {
// url = url.replace("http://minio:9000", "http://localhost/minio");
// }
if let Some(secs) = upload_after_secs { if let Some(secs) = upload_after_secs {
tokio::time::sleep(Duration::from_secs(secs)).await; tokio::time::sleep(Duration::from_secs(secs)).await;
} }
@ -215,9 +211,9 @@ async fn import_notion_zip_until_complete(name: &str) -> (TestClient, String) {
// Uncomment the following lines to use the predicated upload file API. // Uncomment the following lines to use the predicated upload file API.
// Currently, we use `upload_file` to send a file to appflowy_worker, which then // Currently, we use `upload_file` to send a file to appflowy_worker, which then
// processes the upload task. // processes the upload task.
// let file_path = PathBuf::from(format!("tests/workspace/asset/{name}")); let file_path = PathBuf::from(format!("tests/workspace/asset/{name}"));
// client.api_client.import_file(&file_path).await.unwrap(); client.api_client.import_file(&file_path).await.unwrap();
upload_file(&client, name, None).await.unwrap(); // upload_file(&client, name, None).await.unwrap();
let default_workspace_id = client.workspace_id().await; let default_workspace_id = client.workspace_id().await;