collab: Setup database for LLM service (#15882)
This PR puts the initial infrastructure for the LLM service's database in place. The LLM service will be using a separate Postgres database, with its own set of migrations. Currently we only connect to the database in development, as we don't yet have the database setup for the staging/production environments. Release Notes: - N/A
This commit is contained in:
parent
a64906779b
commit
7f6d0919c9
25 changed files with 627 additions and 74 deletions
30
crates/collab/src/llm/db/tests/provider_tests.rs
Normal file
30
crates/collab/src/llm/db/tests/provider_tests.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::llm::db::LlmDatabase;
|
||||
use crate::test_both_llm_dbs;
|
||||
|
||||
test_both_llm_dbs!(
|
||||
test_initialize_providers,
|
||||
test_initialize_providers_postgres,
|
||||
test_initialize_providers_sqlite
|
||||
);
|
||||
|
||||
async fn test_initialize_providers(db: &Arc<LlmDatabase>) {
|
||||
let initial_providers = db.list_providers().await.unwrap();
|
||||
assert_eq!(initial_providers, vec![]);
|
||||
|
||||
db.initialize_providers().await.unwrap();
|
||||
|
||||
// Do it twice, to make sure the operation is idempotent.
|
||||
db.initialize_providers().await.unwrap();
|
||||
|
||||
let providers = db.list_providers().await.unwrap();
|
||||
|
||||
let provider_names = providers
|
||||
.into_iter()
|
||||
.map(|provider| provider.name)
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(provider_names, vec!["anthropic".to_string()]);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue