From c491f1a5608bbd8a999d5703fb033f1a4813c44b Mon Sep 17 00:00:00 2001 From: "Nathan.fooo" <86001920+appflowy@users.noreply.github.com> Date: Sun, 12 May 2024 21:02:28 +0800 Subject: [PATCH] chore: fix ci (#549) * chore: fix ci --- .github/workflows/integration_test.yml | 2 +- deploy.env | 2 +- docker-compose-ci.yml | 2 +- docker-compose-dev.yml | 2 +- docker-compose.yml | 2 +- .../tests/chat_test/completion_test.rs | 9 ++++----- .../tests/index_test/index_search_test.rs | 2 +- libs/appflowy-ai-client/tests/main.rs | 6 ++++++ libs/appflowy-ai-client/tests/row_test/summarize_test.rs | 5 +++-- nginx/nginx.conf | 6 +++--- 10 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index ca21d632..e184228d 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -63,7 +63,7 @@ jobs: matrix: include: - test_service: "appflowy_cloud" - test_cmd: "--workspace --exclude appflowy-history" + test_cmd: "--workspace --exclude appflowy-history appflowy-ai-client" - test_service: "appflowy_history" test_cmd: "-p appflowy-history" steps: diff --git a/deploy.env b/deploy.env index 12055165..3dc44717 100644 --- a/deploy.env +++ b/deploy.env @@ -108,7 +108,7 @@ CLOUDFLARE_TUNNEL_TOKEN= # AppFlowy AI APPFLOWY_AI_OPENAI_API_KEY= -APPFLOWY_AI_SERVER_HOST=appflowy_ai +APPFLOWY_AI_SERVER_HOST=ai APPFLOWY_AI_SERVER_PORT=5001 # AppFlowy History diff --git a/docker-compose-ci.yml b/docker-compose-ci.yml index cb3c355c..82a619ec 100644 --- a/docker-compose-ci.yml +++ b/docker-compose-ci.yml @@ -135,7 +135,7 @@ services: - ADMIN_FRONTEND_GOTRUE_URL=${ADMIN_FRONTEND_GOTRUE_URL:-http://gotrue:9999} - ADMIN_FRONTEND_APPFLOWY_CLOUD_URL=${ADMIN_FRONTEND_APPFLOWY_CLOUD_URL:-http://appflowy_cloud:8000} - appflowy_ai: + ai: restart: on-failure image: appflowyinc/appflowy_ai:${APPFLOWY_AI_VERSION:-latest} ports: diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index 1e13fc74..e0ad889f 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -101,7 +101,7 @@ services: volumes: - ./docker/pgadmin/servers.json:/pgadmin4/servers.json - appflowy_ai: + ai: restart: on-failure image: appflowyinc/appflowy_ai:${APPFLOWY_AI_VERSION:-latest} ports: diff --git a/docker-compose.yml b/docker-compose.yml index ca79ed59..6a84767b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -130,7 +130,7 @@ services: - ADMIN_FRONTEND_GOTRUE_URL=${ADMIN_FRONTEND_GOTRUE_URL:-http://gotrue:9999} - ADMIN_FRONTEND_APPFLOWY_CLOUD_URL=${ADMIN_FRONTEND_APPFLOWY_CLOUD_URL:-http://appflowy_cloud:8000} - appflowy_ai: + ai: restart: on-failure image: appflowyinc/appflowy_ai:${APPFLOWY_AI_VERSION:-latest} ports: diff --git a/libs/appflowy-ai-client/tests/chat_test/completion_test.rs b/libs/appflowy-ai-client/tests/chat_test/completion_test.rs index df7b6dd8..060c0a2f 100644 --- a/libs/appflowy-ai-client/tests/chat_test/completion_test.rs +++ b/libs/appflowy-ai-client/tests/chat_test/completion_test.rs @@ -1,9 +1,9 @@ -use appflowy_ai_client::client::AppFlowyAIClient; +use crate::appflowy_ai_client; use appflowy_ai_client::dto::CompletionType; #[tokio::test] async fn continue_writing_test() { - let client = AppFlowyAIClient::new("http://localhost:5001"); + let client = appflowy_ai_client(); let resp = client .completion_text("I feel hungry", CompletionType::ContinueWriting) .await @@ -14,7 +14,7 @@ async fn continue_writing_test() { #[tokio::test] async fn improve_writing_test() { - let client = AppFlowyAIClient::new("http://localhost:5001"); + let client = appflowy_ai_client(); let resp = client .completion_text( "I fell tired because i sleep not very well last night", @@ -29,8 +29,7 @@ async fn improve_writing_test() { } #[tokio::test] async fn make_text_shorter_text() { - let client = AppFlowyAIClient::new("http://localhost:5001"); - + let client = appflowy_ai_client(); let resp = client .completion_text( "I have an immense passion and deep-seated affection for Rust, a modern, multi-paradigm, high-performance programming language that I find incredibly satisfying to use due to its focus on safety, speed, and concurrency", diff --git a/libs/appflowy-ai-client/tests/index_test/index_search_test.rs b/libs/appflowy-ai-client/tests/index_test/index_search_test.rs index 1d77ac04..a8f5425b 100644 --- a/libs/appflowy-ai-client/tests/index_test/index_search_test.rs +++ b/libs/appflowy-ai-client/tests/index_test/index_search_test.rs @@ -3,7 +3,7 @@ use appflowy_ai_client::dto::{CollabType, Document, SearchDocumentsRequest}; #[tokio::test] async fn index_search() { - let client = AppFlowyAIClient::new("http://localhost:5001"); + let client = appflowy_ai_client(); client .index_documents(&[ diff --git a/libs/appflowy-ai-client/tests/main.rs b/libs/appflowy-ai-client/tests/main.rs index a400583c..dc148b45 100644 --- a/libs/appflowy-ai-client/tests/main.rs +++ b/libs/appflowy-ai-client/tests/main.rs @@ -1,4 +1,10 @@ +use appflowy_ai_client::client::AppFlowyAIClient; + mod chat_test; mod row_test; // mod index_test; + +pub fn appflowy_ai_client() -> AppFlowyAIClient { + AppFlowyAIClient::new("http://localhost:5001") +} diff --git a/libs/appflowy-ai-client/tests/row_test/summarize_test.rs b/libs/appflowy-ai-client/tests/row_test/summarize_test.rs index 6697c72d..f13554bc 100644 --- a/libs/appflowy-ai-client/tests/row_test/summarize_test.rs +++ b/libs/appflowy-ai-client/tests/row_test/summarize_test.rs @@ -1,9 +1,10 @@ -use appflowy_ai_client::client::AppFlowyAIClient; +use crate::appflowy_ai_client; + use serde_json::json; #[tokio::test] async fn summarize_row_test() { - let client = AppFlowyAIClient::new("http://localhost:5001"); + let client = appflowy_ai_client(); let json = json!({"name": "Jack", "age": 25, "city": "New York"}); let result = client diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 60a4c2e2..65063ffa 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -93,9 +93,9 @@ http { } # AppFlowy AI - location /appflowy_ai/ { - proxy_pass http://appflowy_ai:5001; - proxy_set_header Host $http_host; + location /ai { + proxy_pass http://ai:5001; + proxy_set_header Host $host; proxy_pass_request_headers on; }