4bb968fadb
Signed-off-by: Douwe M Osinga <douwe@sidewalklabs.com> Signed-off-by: Douwe Osinga <douwe.osinga@gmail.com> Co-authored-by: Douwe M Osinga <douwe@sidewalklabs.com>
62 lines
1.5 KiB
Rust
62 lines
1.5 KiB
Rust
use super::api_client::TlsConfig;
|
|
use anyhow::Result;
|
|
use futures::future::BoxFuture;
|
|
pub use goose_providers::conversation::token_usage::{
|
|
CostSource, DraftStats, ProviderStats, ProviderUsage, Usage,
|
|
};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
pub use goose_providers::api_client::{
|
|
DEFAULT_CONNECT_TIMEOUT_SECS, DEFAULT_PROVIDER_TIMEOUT_SECS,
|
|
};
|
|
|
|
use crate::config::ExtensionConfig;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
pub use goose_providers::base::*;
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum ProviderType {
|
|
Preferred,
|
|
Builtin,
|
|
Declarative,
|
|
Custom,
|
|
}
|
|
|
|
pub(crate) fn current_working_dir() -> PathBuf {
|
|
std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."))
|
|
}
|
|
|
|
pub trait ProviderDef: ProviderDescriptor + Send + Sync {
|
|
type Provider: Provider + 'static;
|
|
|
|
fn from_env(
|
|
extensions: Vec<ExtensionConfig>,
|
|
tls_config: Option<TlsConfig>,
|
|
) -> BoxFuture<'static, Result<Self::Provider>>
|
|
where
|
|
Self: Sized;
|
|
|
|
fn from_env_with_working_dir(
|
|
extensions: Vec<ExtensionConfig>,
|
|
_working_dir: PathBuf,
|
|
tls_config: Option<TlsConfig>,
|
|
) -> BoxFuture<'static, Result<Self::Provider>>
|
|
where
|
|
Self: Sized,
|
|
{
|
|
Self::from_env(extensions, tls_config)
|
|
}
|
|
|
|
fn from_env_with_default_model(
|
|
extensions: Vec<ExtensionConfig>,
|
|
tls_config: Option<TlsConfig>,
|
|
) -> BoxFuture<'static, Result<Self::Provider>>
|
|
where
|
|
Self: Sized,
|
|
{
|
|
Self::from_env(extensions, tls_config)
|
|
}
|
|
}
|