chore: adjust redis env (#1003)
This commit is contained in:
parent
3799966f12
commit
fd98351473
|
|
@ -24,6 +24,7 @@ env:
|
||||||
LOCALHOST_URL: http://localhost
|
LOCALHOST_URL: http://localhost
|
||||||
LOCALHOST_WS: ws://localhost/ws/v1
|
LOCALHOST_WS: ws://localhost/ws/v1
|
||||||
APPFLOWY_REDIS_URI: redis://redis:6379
|
APPFLOWY_REDIS_URI: redis://redis:6379
|
||||||
|
APPFLOWY_AI_REDIS_URL: redis://redis:6379
|
||||||
LOCALHOST_GOTRUE: http://localhost/gotrue
|
LOCALHOST_GOTRUE: http://localhost/gotrue
|
||||||
POSTGRES_PASSWORD: password
|
POSTGRES_PASSWORD: password
|
||||||
DATABASE_URL: postgres://postgres:password@localhost:5432/postgres
|
DATABASE_URL: postgres://postgres:password@localhost:5432/postgres
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@ APPFLOWY_AI_OPENAI_API_KEY=
|
||||||
APPFLOWY_AI_SERVER_PORT=5001
|
APPFLOWY_AI_SERVER_PORT=5001
|
||||||
APPFLOWY_AI_SERVER_HOST=ai
|
APPFLOWY_AI_SERVER_HOST=ai
|
||||||
APPFLOWY_AI_DATABASE_URL=postgresql+psycopg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
|
APPFLOWY_AI_DATABASE_URL=postgresql+psycopg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
|
||||||
|
APPFLOWY_AI_REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT}
|
||||||
APPFLOWY_LOCAL_AI_TEST_ENABLED=false
|
APPFLOWY_LOCAL_AI_TEST_ENABLED=false
|
||||||
|
|
||||||
# AppFlowy Indexer
|
# AppFlowy Indexer
|
||||||
|
|
|
||||||
1
dev.env
1
dev.env
|
|
@ -113,6 +113,7 @@ APPFLOWY_AI_OPENAI_API_KEY=
|
||||||
APPFLOWY_AI_SERVER_PORT=5001
|
APPFLOWY_AI_SERVER_PORT=5001
|
||||||
APPFLOWY_AI_SERVER_HOST=localhost
|
APPFLOWY_AI_SERVER_HOST=localhost
|
||||||
APPFLOWY_AI_DATABASE_URL=postgresql+psycopg://postgres:password@postgres:5432/postgres
|
APPFLOWY_AI_DATABASE_URL=postgresql+psycopg://postgres:password@postgres:5432/postgres
|
||||||
|
APPFLOWY_AI_REDIS_URL=redis://redis:6379
|
||||||
APPFLOWY_LOCAL_AI_TEST_ENABLED=false
|
APPFLOWY_LOCAL_AI_TEST_ENABLED=false
|
||||||
|
|
||||||
# AppFlowy Indexer
|
# AppFlowy Indexer
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ services:
|
||||||
- LOCAL_AI_AWS_SECRET_ACCESS_KEY=${LOCAL_AI_AWS_SECRET_ACCESS_KEY}
|
- LOCAL_AI_AWS_SECRET_ACCESS_KEY=${LOCAL_AI_AWS_SECRET_ACCESS_KEY}
|
||||||
- APPFLOWY_AI_SERVER_PORT=${APPFLOWY_AI_SERVER_PORT}
|
- APPFLOWY_AI_SERVER_PORT=${APPFLOWY_AI_SERVER_PORT}
|
||||||
- APPFLOWY_AI_DATABASE_URL=${APPFLOWY_AI_DATABASE_URL}
|
- APPFLOWY_AI_DATABASE_URL=${APPFLOWY_AI_DATABASE_URL}
|
||||||
- APPFLOWY_AI_REDIS_URL=${APPFLOWY_REDIS_URI}
|
- APPFLOWY_AI_REDIS_URL=${APPFLOWY_AI_REDIS_URL}
|
||||||
|
|
||||||
appflowy_worker:
|
appflowy_worker:
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ services:
|
||||||
- OPENAI_API_KEY=${APPFLOWY_AI_OPENAI_API_KEY}
|
- OPENAI_API_KEY=${APPFLOWY_AI_OPENAI_API_KEY}
|
||||||
- APPFLOWY_AI_SERVER_PORT=${APPFLOWY_AI_SERVER_PORT}
|
- APPFLOWY_AI_SERVER_PORT=${APPFLOWY_AI_SERVER_PORT}
|
||||||
- APPFLOWY_AI_DATABASE_URL=${APPFLOWY_AI_DATABASE_URL}
|
- APPFLOWY_AI_DATABASE_URL=${APPFLOWY_AI_DATABASE_URL}
|
||||||
|
- APPFLOWY_AI_REDIS_URL=${APPFLOWY_AI_REDIS_URL}
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,7 @@ services:
|
||||||
- OPENAI_API_KEY=${APPFLOWY_AI_OPENAI_API_KEY}
|
- OPENAI_API_KEY=${APPFLOWY_AI_OPENAI_API_KEY}
|
||||||
- APPFLOWY_AI_SERVER_PORT=${APPFLOWY_AI_SERVER_PORT}
|
- APPFLOWY_AI_SERVER_PORT=${APPFLOWY_AI_SERVER_PORT}
|
||||||
- APPFLOWY_AI_DATABASE_URL=${APPFLOWY_AI_DATABASE_URL}
|
- APPFLOWY_AI_DATABASE_URL=${APPFLOWY_AI_DATABASE_URL}
|
||||||
|
- APPFLOWY_AI_REDIS_URL=${APPFLOWY_AI_REDIS_URL}
|
||||||
|
|
||||||
appflowy_worker:
|
appflowy_worker:
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
|
|
|
||||||
|
|
@ -25,15 +25,21 @@ pub struct DocumentIndexer {
|
||||||
ai_client: AppFlowyAIClient,
|
ai_client: AppFlowyAIClient,
|
||||||
tokenizer: Arc<CoreBPE>,
|
tokenizer: Arc<CoreBPE>,
|
||||||
embedding_model: EmbeddingModel,
|
embedding_model: EmbeddingModel,
|
||||||
|
use_tiktoken: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DocumentIndexer {
|
impl DocumentIndexer {
|
||||||
pub fn new(ai_client: AppFlowyAIClient) -> Arc<Self> {
|
pub fn new(ai_client: AppFlowyAIClient) -> Arc<Self> {
|
||||||
let tokenizer = tiktoken_rs::cl100k_base().unwrap();
|
let tokenizer = tiktoken_rs::cl100k_base().unwrap();
|
||||||
|
let use_tiktoken = get_env_var("APPFLOWY_AI_CONTENT_SPLITTER_TIKTOKEN", "false")
|
||||||
|
.parse::<bool>()
|
||||||
|
.unwrap_or(false);
|
||||||
|
|
||||||
Arc::new(Self {
|
Arc::new(Self {
|
||||||
ai_client,
|
ai_client,
|
||||||
tokenizer: Arc::new(tokenizer),
|
tokenizer: Arc::new(tokenizer),
|
||||||
embedding_model: EmbeddingModel::TextEmbedding3Small,
|
embedding_model: EmbeddingModel::TextEmbedding3Small,
|
||||||
|
use_tiktoken,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -62,6 +68,7 @@ impl Indexer for DocumentIndexer {
|
||||||
CollabType::Document,
|
CollabType::Document,
|
||||||
&self.embedding_model,
|
&self.embedding_model,
|
||||||
self.tokenizer.clone(),
|
self.tokenizer.clone(),
|
||||||
|
self.use_tiktoken,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
},
|
},
|
||||||
|
|
@ -136,11 +143,8 @@ async fn create_embedding(
|
||||||
collab_type: CollabType,
|
collab_type: CollabType,
|
||||||
embedding_model: &EmbeddingModel,
|
embedding_model: &EmbeddingModel,
|
||||||
tokenizer: Arc<CoreBPE>,
|
tokenizer: Arc<CoreBPE>,
|
||||||
|
use_tiktoken: bool,
|
||||||
) -> Result<Vec<AFCollabEmbeddingParams>, AppError> {
|
) -> Result<Vec<AFCollabEmbeddingParams>, AppError> {
|
||||||
let use_tiktoken = get_env_var("APPFLOWY_AI_CONTENT_SPLITTER_TIKTOKEN", "false")
|
|
||||||
.parse::<bool>()
|
|
||||||
.unwrap_or(false);
|
|
||||||
|
|
||||||
let split_contents = if use_tiktoken {
|
let split_contents = if use_tiktoken {
|
||||||
let max_tokens = embedding_model.default_dimensions() as usize;
|
let max_tokens = embedding_model.default_dimensions() as usize;
|
||||||
if content.len() < 500 {
|
if content.len() < 500 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue