mirror of
https://github.com/SilasMarvin/lsp-ai.git
synced 2024-08-15 23:30:34 +03:00
fix: visibilty warnings
This commit is contained in:
parent
12900c0ebf
commit
b594d03e48
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub type Kwargs = HashMap<String, Value>;
|
||||
pub(crate) type Kwargs = HashMap<String, Value>;
|
||||
|
||||
const fn max_requests_per_second_default() -> f32 {
|
||||
1.
|
||||
@ -79,7 +79,7 @@ pub enum ValidMemoryBackend {
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum ValidModel {
|
||||
pub(crate) enum ValidModel {
|
||||
#[cfg(feature = "llama_cpp")]
|
||||
#[serde(rename = "llama_cpp")]
|
||||
LLaMACPP(LLaMACPP),
|
||||
@ -97,13 +97,13 @@ pub enum ValidModel {
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ChatMessage {
|
||||
pub role: String,
|
||||
pub content: String,
|
||||
pub(crate) struct ChatMessage {
|
||||
pub(crate) role: String,
|
||||
pub(crate) content: String,
|
||||
}
|
||||
|
||||
impl ChatMessage {
|
||||
pub fn new(role: String, content: String) -> Self {
|
||||
pub(crate) fn new(role: String, content: String) -> Self {
|
||||
Self {
|
||||
role,
|
||||
content,
|
||||
@ -115,10 +115,10 @@ impl ChatMessage {
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct FIM {
|
||||
pub start: String,
|
||||
pub middle: String,
|
||||
pub end: String,
|
||||
pub(crate) struct FIM {
|
||||
pub(crate) start: String,
|
||||
pub(crate) middle: String,
|
||||
pub(crate) end: String,
|
||||
}
|
||||
|
||||
const fn max_crawl_memory_default() -> u64 {
|
||||
@ -131,13 +131,13 @@ const fn max_crawl_file_size_default() -> u64 {
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Crawl {
|
||||
pub(crate) struct Crawl {
|
||||
#[serde(default = "max_crawl_file_size_default")]
|
||||
pub max_file_size: u64,
|
||||
pub(crate) max_file_size: u64,
|
||||
#[serde(default = "max_crawl_memory_default")]
|
||||
pub max_crawl_memory: u64,
|
||||
pub(crate) max_crawl_memory: u64,
|
||||
#[serde(default)]
|
||||
pub all_files: bool,
|
||||
pub(crate) all_files: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
@ -149,18 +149,18 @@ pub struct PostgresMLEmbeddingModel {
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct PostgresML {
|
||||
pub database_url: Option<String>,
|
||||
pub crawl: Option<Crawl>,
|
||||
pub(crate) struct PostgresML {
|
||||
pub(crate) database_url: Option<String>,
|
||||
pub(crate) crawl: Option<Crawl>,
|
||||
#[serde(default)]
|
||||
pub splitter: ValidSplitter,
|
||||
pub embedding_model: Option<PostgresMLEmbeddingModel>,
|
||||
pub(crate) splitter: ValidSplitter,
|
||||
pub(crate) embedding_model: Option<PostgresMLEmbeddingModel>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Default)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct FileStore {
|
||||
pub crawl: Option<Crawl>,
|
||||
pub(crate) struct FileStore {
|
||||
pub(crate) crawl: Option<Crawl>,
|
||||
}
|
||||
|
||||
impl FileStore {
|
||||
@ -265,11 +265,12 @@ pub struct Gemini {
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct Anthropic {
|
||||
pub(crate) struct Anthropic {
|
||||
// The auth token env var name
|
||||
pub auth_token_env_var_name: Option<String>,
|
||||
pub auth_token: Option<String>,
|
||||
// The completions endpoint
|
||||
#[allow(dead_code)]
|
||||
pub completions_endpoint: Option<String>,
|
||||
// The chat endpoint
|
||||
pub chat_endpoint: Option<String>,
|
||||
@ -295,7 +296,7 @@ pub struct Completion {
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct ValidConfig {
|
||||
pub memory: ValidMemoryBackend,
|
||||
pub(crate) memory: ValidMemoryBackend,
|
||||
pub models: HashMap<String, ValidModel>,
|
||||
pub completion: Option<Completion>,
|
||||
}
|
||||
@ -308,8 +309,8 @@ pub struct ValidClientParams {
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Config {
|
||||
pub config: ValidConfig,
|
||||
pub client_params: ValidClientParams,
|
||||
pub(crate) config: ValidConfig,
|
||||
pub(crate) client_params: ValidClientParams,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
|
@ -12,7 +12,7 @@ pub struct Crawl {
|
||||
}
|
||||
|
||||
impl Crawl {
|
||||
pub fn new(crawl_config: config::Crawl, config: Config) -> Self {
|
||||
pub(crate) fn new(crawl_config: config::Crawl, config: Config) -> Self {
|
||||
Self {
|
||||
crawl_config,
|
||||
config,
|
||||
|
@ -4,28 +4,28 @@ use serde_json::Value;
|
||||
|
||||
use crate::config;
|
||||
|
||||
pub enum Generation {}
|
||||
pub(crate) enum Generation {}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct GenerationParams {
|
||||
pub(crate) struct GenerationParams {
|
||||
// This field was "mixed-in" from TextDocumentPositionParams
|
||||
#[serde(flatten)]
|
||||
pub text_document_position: TextDocumentPositionParams,
|
||||
pub(crate) text_document_position: TextDocumentPositionParams,
|
||||
// The model key to use
|
||||
pub model: String,
|
||||
pub(crate) model: String,
|
||||
#[serde(default)]
|
||||
// Args are deserialized by the backend using them
|
||||
pub parameters: Value,
|
||||
pub(crate) parameters: Value,
|
||||
// Parameters for post processing
|
||||
#[serde(default)]
|
||||
pub post_process: config::PostProcess,
|
||||
pub(crate) post_process: config::PostProcess,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct GenerateResult {
|
||||
pub generated_text: String,
|
||||
pub(crate) struct GenerateResult {
|
||||
pub(crate) generated_text: String,
|
||||
}
|
||||
|
||||
impl lsp_types::request::Request for Generation {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use lsp_types::{ProgressToken, TextDocumentPositionParams};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub enum GenerationStream {}
|
||||
pub(crate) enum GenerationStream {}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@ -15,9 +15,9 @@ pub struct GenerationStreamParams {
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct GenerationStreamResult {
|
||||
pub generated_text: String,
|
||||
pub partial_result_token: ProgressToken,
|
||||
pub(crate) struct GenerationStreamResult {
|
||||
pub(crate) generated_text: String,
|
||||
pub(crate) partial_result_token: ProgressToken,
|
||||
}
|
||||
|
||||
impl lsp_types::request::Request for GenerationStream {
|
||||
|
@ -1,2 +1,2 @@
|
||||
pub mod generation;
|
||||
pub mod generation_stream;
|
||||
pub(crate) mod generation;
|
||||
pub(crate) mod generation_stream;
|
||||
|
@ -17,12 +17,12 @@ use crate::{
|
||||
use super::{ContextAndCodePrompt, FIMPrompt, MemoryBackend, MemoryRunParams, Prompt, PromptType};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct AdditionalFileStoreParams {
|
||||
pub(crate) struct AdditionalFileStoreParams {
|
||||
build_tree: bool,
|
||||
}
|
||||
|
||||
impl AdditionalFileStoreParams {
|
||||
pub fn new(build_tree: bool) -> Self {
|
||||
pub(crate) fn new(build_tree: bool) -> Self {
|
||||
Self { build_tree }
|
||||
}
|
||||
}
|
||||
@ -47,7 +47,7 @@ impl File {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FileStore {
|
||||
pub(crate) struct FileStore {
|
||||
params: AdditionalFileStoreParams,
|
||||
file_map: Mutex<HashMap<String, File>>,
|
||||
accessed_files: Mutex<IndexSet<String>>,
|
||||
@ -55,7 +55,10 @@ pub struct FileStore {
|
||||
}
|
||||
|
||||
impl FileStore {
|
||||
pub fn new(mut file_store_config: config::FileStore, config: Config) -> anyhow::Result<Self> {
|
||||
pub(crate) fn new(
|
||||
mut file_store_config: config::FileStore,
|
||||
config: Config,
|
||||
) -> anyhow::Result<Self> {
|
||||
let crawl = file_store_config
|
||||
.crawl
|
||||
.take()
|
||||
@ -72,7 +75,7 @@ impl FileStore {
|
||||
Ok(s)
|
||||
}
|
||||
|
||||
pub fn new_with_params(
|
||||
pub(crate) fn new_with_params(
|
||||
mut file_store_config: config::FileStore,
|
||||
config: Config,
|
||||
params: AdditionalFileStoreParams,
|
||||
@ -192,7 +195,7 @@ impl FileStore {
|
||||
Ok((rope, cursor_index))
|
||||
}
|
||||
|
||||
pub fn get_characters_around_position(
|
||||
pub(crate) fn get_characters_around_position(
|
||||
&self,
|
||||
position: &TextDocumentPositionParams,
|
||||
characters: usize,
|
||||
@ -216,7 +219,7 @@ impl FileStore {
|
||||
Ok(rope_slice.to_string())
|
||||
}
|
||||
|
||||
pub fn build_code(
|
||||
pub(crate) fn build_code(
|
||||
&self,
|
||||
position: &TextDocumentPositionParams,
|
||||
prompt_type: PromptType,
|
||||
@ -272,15 +275,18 @@ impl FileStore {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn file_map(&self) -> &Mutex<HashMap<String, File>> {
|
||||
pub(crate) fn file_map(&self) -> &Mutex<HashMap<String, File>> {
|
||||
&self.file_map
|
||||
}
|
||||
|
||||
pub fn contains_file(&self, uri: &str) -> bool {
|
||||
pub(crate) fn contains_file(&self, uri: &str) -> bool {
|
||||
self.file_map.lock().contains_key(uri)
|
||||
}
|
||||
|
||||
pub fn position_to_byte(&self, position: &TextDocumentPositionParams) -> anyhow::Result<usize> {
|
||||
pub(crate) fn position_to_byte(
|
||||
&self,
|
||||
position: &TextDocumentPositionParams,
|
||||
) -> anyhow::Result<usize> {
|
||||
let file_map = self.file_map.lock();
|
||||
let uri = position.text_document.uri.to_string();
|
||||
let file = file_map
|
||||
|
@ -6,7 +6,7 @@ use serde_json::Value;
|
||||
|
||||
use crate::config::{Config, ValidMemoryBackend};
|
||||
|
||||
pub mod file_store;
|
||||
pub(crate) mod file_store;
|
||||
mod postgresml;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@ -16,9 +16,9 @@ pub enum PromptType {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MemoryRunParams {
|
||||
pub is_for_chat: bool,
|
||||
pub max_context: usize,
|
||||
pub(crate) struct MemoryRunParams {
|
||||
pub(crate) is_for_chat: bool,
|
||||
pub(crate) max_context: usize,
|
||||
}
|
||||
|
||||
impl From<&Value> for MemoryRunParams {
|
||||
|
@ -84,7 +84,7 @@ async fn split_and_upsert_file(
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct PostgresML {
|
||||
pub(crate) struct PostgresML {
|
||||
config: Config,
|
||||
postgresml_config: config::PostgresML,
|
||||
file_store: Arc<FileStore>,
|
||||
@ -240,12 +240,7 @@ impl PostgresML {
|
||||
})
|
||||
.collect();
|
||||
if let Err(e) = task_collection
|
||||
.delete_documents(
|
||||
json!({
|
||||
"$or": delete_or_statements
|
||||
})
|
||||
.into(),
|
||||
)
|
||||
.delete_documents(json!({ "$or": delete_or_statements }).into())
|
||||
.await
|
||||
.context("PGML - error deleting documents")
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ use crate::{
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PromptRequest {
|
||||
pub(crate) struct PromptRequest {
|
||||
position: TextDocumentPositionParams,
|
||||
prompt_type: PromptType,
|
||||
params: Value,
|
||||
@ -21,7 +21,7 @@ pub struct PromptRequest {
|
||||
}
|
||||
|
||||
impl PromptRequest {
|
||||
pub fn new(
|
||||
pub(crate) fn new(
|
||||
position: TextDocumentPositionParams,
|
||||
prompt_type: PromptType,
|
||||
params: Value,
|
||||
@ -37,13 +37,13 @@ impl PromptRequest {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FilterRequest {
|
||||
pub(crate) struct FilterRequest {
|
||||
position: TextDocumentPositionParams,
|
||||
tx: tokio::sync::oneshot::Sender<String>,
|
||||
}
|
||||
|
||||
impl FilterRequest {
|
||||
pub fn new(
|
||||
pub(crate) fn new(
|
||||
position: TextDocumentPositionParams,
|
||||
tx: tokio::sync::oneshot::Sender<String>,
|
||||
) -> Self {
|
||||
@ -51,7 +51,7 @@ impl FilterRequest {
|
||||
}
|
||||
}
|
||||
|
||||
pub enum WorkerRequest {
|
||||
pub(crate) enum WorkerRequest {
|
||||
FilterText(FilterRequest),
|
||||
Prompt(PromptRequest),
|
||||
DidOpenTextDocument(DidOpenTextDocumentParams),
|
||||
@ -115,7 +115,7 @@ fn do_run(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run(
|
||||
pub(crate) fn run(
|
||||
memory_backend: Box<dyn MemoryBackend + Send + Sync>,
|
||||
rx: std::sync::mpsc::Receiver<WorkerRequest>,
|
||||
) {
|
||||
|
@ -8,14 +8,14 @@ pub struct TextSplitter {
|
||||
}
|
||||
|
||||
impl TextSplitter {
|
||||
pub fn new(config: config::TextSplitter) -> Self {
|
||||
pub(crate) fn new(config: config::TextSplitter) -> Self {
|
||||
Self {
|
||||
chunk_size: config.chunk_size,
|
||||
splitter: text_splitter::TextSplitter::new(config.chunk_size),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_with_chunk_size(chunk_size: usize) -> Self {
|
||||
pub(crate) fn new_with_chunk_size(chunk_size: usize) -> Self {
|
||||
Self {
|
||||
chunk_size,
|
||||
splitter: text_splitter::TextSplitter::new(chunk_size),
|
||||
|
@ -6,14 +6,14 @@ use crate::{config, memory_backends::file_store::File, utils::parse_tree};
|
||||
|
||||
use super::{text_splitter::TextSplitter, ByteRange, Chunk, Splitter};
|
||||
|
||||
pub struct TreeSitter {
|
||||
pub(crate) struct TreeSitter {
|
||||
chunk_size: usize,
|
||||
splitter: TreeSitterCodeSplitter,
|
||||
text_splitter: TextSplitter,
|
||||
}
|
||||
|
||||
impl TreeSitter {
|
||||
pub fn new(config: config::TreeSitter) -> anyhow::Result<Self> {
|
||||
pub(crate) fn new(config: config::TreeSitter) -> anyhow::Result<Self> {
|
||||
let text_splitter = TextSplitter::new_with_chunk_size(config.chunk_size);
|
||||
Ok(Self {
|
||||
chunk_size: config.chunk_size,
|
||||
|
@ -30,15 +30,15 @@ const fn temperature_default() -> f32 {
|
||||
|
||||
// NOTE: We cannot deny unknown fields as the provided parameters may contain other fields relevant to other processes
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct AnthropicRunParams {
|
||||
pub(crate) struct AnthropicRunParams {
|
||||
system: String,
|
||||
messages: Vec<ChatMessage>,
|
||||
#[serde(default = "max_tokens_default")]
|
||||
pub max_tokens: usize,
|
||||
pub(crate) max_tokens: usize,
|
||||
#[serde(default = "top_p_default")]
|
||||
pub top_p: f32,
|
||||
pub(crate) top_p: f32,
|
||||
#[serde(default = "temperature_default")]
|
||||
pub temperature: f32,
|
||||
pub(crate) temperature: f32,
|
||||
}
|
||||
|
||||
pub struct Anthropic {
|
||||
@ -56,11 +56,11 @@ struct AnthropicChatResponse {
|
||||
error: Option<Value>,
|
||||
#[serde(default)]
|
||||
#[serde(flatten)]
|
||||
pub other: HashMap<String, Value>,
|
||||
pub(crate) other: HashMap<String, Value>,
|
||||
}
|
||||
|
||||
impl Anthropic {
|
||||
pub fn new(config: config::Anthropic) -> Self {
|
||||
pub(crate) fn new(config: config::Anthropic) -> Self {
|
||||
Self { config }
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ const fn max_tokens_default() -> usize {
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
struct Part {
|
||||
pub text: String,
|
||||
pub(crate) text: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
|
Loading…
Reference in New Issue
Block a user