Skip to content

Commit

Permalink
use generic configuration for provider
Browse files Browse the repository at this point in the history
  • Loading branch information
aprxi committed Sep 15, 2024
1 parent 6adfbed commit fc2344c
Show file tree
Hide file tree
Showing 13 changed files with 239 additions and 311 deletions.
3 changes: 1 addition & 2 deletions lumni/src/apps/builtin/llm/prompt/src/chat/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ pub use lumni::Timestamp;
pub use model::{ModelIdentifier, ModelSpec};
use serde::{Deserialize, Serialize};
pub use settings::{
DatabaseConfigurationItem, MaskMode, ProviderConfig, ProviderConfigOptions,
UserProfile, UserProfileDbHandler,
DatabaseConfigurationItem, MaskMode, UserProfile, UserProfileDbHandler,
};
pub use store::ConversationDatabase;

Expand Down
10 changes: 0 additions & 10 deletions lumni/src/apps/builtin/llm/prompt/src/chat/db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ CREATE TABLE configuration (
FOREIGN KEY (encryption_key_id) REFERENCES encryption_keys(id)
);

CREATE TABLE provider_configs (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
provider_type TEXT NOT NULL,
model_identifier TEXT,
additional_settings TEXT, -- JSON string
encryption_key_id INTEGER NOT NULL,
FOREIGN KEY (encryption_key_id) REFERENCES encryption_keys(id)
);

CREATE TABLE encryption_keys (
id INTEGER PRIMARY KEY,
file_path TEXT NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ impl UserProfileDbHandler {
section: &str,
) -> Result<Vec<DatabaseConfigurationItem>, ApplicationError> {
let mut db = self.db.lock().await;

db.process_queue_with_result(|tx| {
let mut stmt = tx
.prepare(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ mod content_operations;
mod encryption_operations;
mod generic;
mod profile;
mod provider;
use std::path::PathBuf;
use std::sync::Arc;

pub use generic::DatabaseConfigurationItem;
use lumni::api::error::{ApplicationError, EncryptionError};
use lumni::api::error::ApplicationError;
pub use profile::UserProfile;
pub use provider::{ProviderConfig, ProviderConfigOptions};
use rusqlite::params;
use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
use tokio::sync::Mutex as TokioMutex;

Expand Down
232 changes: 0 additions & 232 deletions lumni/src/apps/builtin/llm/prompt/src/chat/db/settings/provider.rs

This file was deleted.

2 changes: 1 addition & 1 deletion lumni/src/apps/builtin/llm/prompt/src/tui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub use window::{
use super::chat::db::{
Conversation, ConversationDatabase, ConversationDbHandler, ConversationId,
ConversationStatus, DatabaseConfigurationItem, MaskMode, ModelSpec,
ProviderConfig, ProviderConfigOptions, UserProfile, UserProfileDbHandler,
UserProfile, UserProfileDbHandler,
};
use super::chat::{
App, ChatSessionManager, NewConversation, ThreadedChatSession,
Expand Down
6 changes: 3 additions & 3 deletions lumni/src/apps/builtin/llm/prompt/src/tui/modals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use super::{
ApplicationError, ChatSessionManager, Conversation, ConversationDbHandler,
ConversationEvent, ConversationId, ConversationStatus,
DatabaseConfigurationItem, KeyTrack, MaskMode, ModalEvent, ModelServer,
ModelSpec, ProviderConfig, ProviderConfigOptions, ReadDocument,
ServerTrait, SimpleString, TextLine, ThreadedChatSession, UserEvent,
UserProfile, UserProfileDbHandler, WindowMode, SUPPORTED_MODEL_ENDPOINTS,
ModelSpec, ReadDocument, ServerTrait, SimpleString, TextLine,
ThreadedChatSession, UserEvent, UserProfile, UserProfileDbHandler,
WindowMode, SUPPORTED_MODEL_ENDPOINTS,
};

#[derive(Debug, Clone, PartialEq)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl ListItemTrait for ProviderConfig {
}

fn id(&self) -> i64 {
self.id.unwrap_or(0)
self.id
}

fn with_new_name(&self, new_name: String) -> Self {
Expand All @@ -170,3 +170,24 @@ impl ListItemTrait for ProviderConfig {
"Provider"
}
}

impl ListItemTrait for DatabaseConfigurationItem {
fn name(&self) -> &str {
&self.name
}

fn id(&self) -> i64 {
self.id
}

fn with_new_name(&self, new_name: String) -> Self {
DatabaseConfigurationItem {
name: new_name,
..self.clone()
}
}

fn item_type() -> &'static str {
"Configuration"
}
}
Loading

0 comments on commit fc2344c

Please sign in to comment.