Enable runtime access to provider name (#5399)
This commit is contained in:
@@ -39,6 +39,8 @@ pub struct GoogleProvider {
|
||||
#[serde(skip)]
|
||||
api_client: ApiClient,
|
||||
model: ModelConfig,
|
||||
#[serde(skip)]
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl GoogleProvider {
|
||||
@@ -59,7 +61,11 @@ impl GoogleProvider {
|
||||
let api_client =
|
||||
ApiClient::new(host, auth)?.with_header("Content-Type", "application/json")?;
|
||||
|
||||
Ok(Self { api_client, model })
|
||||
Ok(Self {
|
||||
api_client,
|
||||
model,
|
||||
name: Self::metadata().name,
|
||||
})
|
||||
}
|
||||
|
||||
async fn post(&self, model_name: &str, payload: &Value) -> Result<Value, ProviderError> {
|
||||
@@ -86,6 +92,10 @@ impl Provider for GoogleProvider {
|
||||
)
|
||||
}
|
||||
|
||||
fn get_name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
|
||||
fn get_model_config(&self) -> ModelConfig {
|
||||
self.model.clone()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user