pub struct ProxyBuilder { /* private fields */ }Expand description
A builder for Proxy
Implementations§
Source§impl ProxyBuilder
impl ProxyBuilder
Sourcepub fn with_database(self, database: Database) -> Self
pub fn with_database(self, database: Database) -> Self
Set the database with a pre-made adapter
Sourcepub fn with_sqlite_pool(self, pool: SqlitePool) -> Self
pub fn with_sqlite_pool(self, pool: SqlitePool) -> Self
Use this SQLite database
Sourcepub fn with_postgres_pool(self, pool: PgPool) -> Self
pub fn with_postgres_pool(self, pool: PgPool) -> Self
Use this PostgreSQL database pool
Sourcepub fn load_config_from_database(self, load: bool) -> Self
pub fn load_config_from_database(self, load: bool) -> Self
Load configuration for custom providers, aliases, and API keys from the database. If a database pool is provided, this defaults to true.
Sourcepub fn log_to_database(self, log: bool) -> Self
pub fn log_to_database(self, log: bool) -> Self
Enable or disable logging to the database. Logging requires with_database to have been
called.
Sourcepub fn with_config(self, config: ProxyConfig) -> Self
pub fn with_config(self, config: ProxyConfig) -> Self
Merge this configuration into the current one.
Sourcepub async fn with_config_from_path(
self,
path: &Path,
) -> Result<Self, Report<Error>>
pub async fn with_config_from_path( self, path: &Path, ) -> Result<Self, Report<Error>>
Read a configuration file from this path and merge it into the current configuration.
Sourcepub fn with_alias(self, alias: AliasConfig) -> Self
pub fn with_alias(self, alias: AliasConfig) -> Self
Add an AliasConfig to the Proxy
Sourcepub fn with_aliases(self, aliases: Vec<AliasConfig>) -> Self
pub fn with_aliases(self, aliases: Vec<AliasConfig>) -> Self
Add multiple AliasConfig objects to the Proxy
Sourcepub fn with_api_key(self, key: ApiKeyConfig) -> Self
pub fn with_api_key(self, key: ApiKeyConfig) -> Self
Add an ApiKeyConfig to the proxy
Sourcepub fn with_api_keys(self, keys: Vec<ApiKeyConfig>) -> Self
pub fn with_api_keys(self, keys: Vec<ApiKeyConfig>) -> Self
Add multiple ApiKeyConfig objects to the proxy
Sourcepub fn with_custom_provider(self, config: CustomProviderConfig) -> Self
pub fn with_custom_provider(self, config: CustomProviderConfig) -> Self
Add a custom provider to the list of providers
Sourcepub fn with_custom_providers(self, configs: Vec<CustomProviderConfig>) -> Self
pub fn with_custom_providers(self, configs: Vec<CustomProviderConfig>) -> Self
Add multiple custom providers to the list of providers
Sourcepub fn with_provider(self, provider: Arc<dyn ChatModelProvider>) -> Self
pub fn with_provider(self, provider: Arc<dyn ChatModelProvider>) -> Self
Add a precreated provider to the list of providers. This can be used to create your own custom providers that require capabilities not provided by the CustomProviderConfig.
Sourcepub fn with_openai(self, token: Option<String>) -> Self
pub fn with_openai(self, token: Option<String>) -> Self
Enable the OpenAI provider, if it was disabled by [without_default_providers]
Sourcepub fn with_anyscale(self, token: Option<String>) -> Self
pub fn with_anyscale(self, token: Option<String>) -> Self
Enable the Anyscale provider, if it was disabled by [without_default_providers]
Sourcepub fn with_anthropic(self, token: Option<String>) -> Self
pub fn with_anthropic(self, token: Option<String>) -> Self
Enable the Anthropic provider, if it was disabled by [without_default_providers]
Sourcepub fn with_aws_bedrock(self, client: Option<Client>) -> Self
pub fn with_aws_bedrock(self, client: Option<Client>) -> Self
Enable the AWS Bedrock provider, possibly passing a custom client.
Sourcepub fn with_deepinfra(self, token: Option<String>) -> Self
pub fn with_deepinfra(self, token: Option<String>) -> Self
Enable the DeepInfra provider, if it was disabled by [without_default_providers]
Sourcepub fn with_fireworks(self, token: Option<String>) -> Self
pub fn with_fireworks(self, token: Option<String>) -> Self
Enable the Fireworks provider, if it was disabled by [without_default_providers]
Sourcepub fn with_groq(self, token: Option<String>) -> Self
pub fn with_groq(self, token: Option<String>) -> Self
Enable the Groq provider, if it was disabled by [without_default_providers]
Sourcepub fn with_mistral(self, token: Option<String>) -> Self
pub fn with_mistral(self, token: Option<String>) -> Self
Enable the Mistral provider, if it was disabled by [without_default_providers]
Sourcepub fn with_together(self, token: Option<String>) -> Self
pub fn with_together(self, token: Option<String>) -> Self
Enable the Together provider, if it was disabled by [without_default_providers]
Sourcepub fn with_ollama(self, url: Option<String>) -> Self
pub fn with_ollama(self, url: Option<String>) -> Self
Enable the Ollama provider, if it was disabled by [without_default_providers]
Sourcepub fn without_default_providers(self) -> Self
pub fn without_default_providers(self) -> Self
Don’t load the default providers
Sourcepub fn user_agent(self, user_agent: impl Into<String>) -> Self
pub fn user_agent(self, user_agent: impl Into<String>) -> Self
Set the user agent that will be used for HTTP requests. This only applies if
with_client is not used.
Sourcepub fn with_client(self, client: Client) -> Self
pub fn with_client(self, client: Client) -> Self
Supply a custom reqwest::Client that the proxy will use to make requests.
Auto Trait Implementations§
impl Freeze for ProxyBuilder
impl !RefUnwindSafe for ProxyBuilder
impl Send for ProxyBuilder
impl Sync for ProxyBuilder
impl Unpin for ProxyBuilder
impl !UnwindSafe for ProxyBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request