mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-05 12:21:52 +00:00
fix: prevent telemetry from leaking sensitive info
Prevent sensitive information from being logged in telemetry output by assigning SecretStr type to sensitive fields. API keys, password from KV store are now covered. All providers have been converted. Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
parent
8dc9fd6844
commit
c4cb6aa8d9
53 changed files with 121 additions and 109 deletions
|
@ -5,7 +5,7 @@
|
|||
# the root directory of this source tree.
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, SecretStr
|
||||
|
||||
from llama_stack.core.datatypes import Api
|
||||
|
||||
|
@ -13,7 +13,7 @@ from .config import BraintrustScoringConfig
|
|||
|
||||
|
||||
class BraintrustProviderDataValidator(BaseModel):
|
||||
openai_api_key: str
|
||||
openai_api_key: SecretStr
|
||||
|
||||
|
||||
async def get_provider_impl(
|
||||
|
|
|
@ -17,7 +17,7 @@ from autoevals.ragas import (
|
|||
ContextRelevancy,
|
||||
Faithfulness,
|
||||
)
|
||||
from pydantic import BaseModel
|
||||
from pydantic import BaseModel, SecretStr
|
||||
|
||||
from llama_stack.apis.datasetio import DatasetIO
|
||||
from llama_stack.apis.datasets import Datasets
|
||||
|
@ -152,9 +152,9 @@ class BraintrustScoringImpl(
|
|||
raise ValueError(
|
||||
'Pass OpenAI API Key in the header X-LlamaStack-Provider-Data as { "openai_api_key": <your api key>}'
|
||||
)
|
||||
self.config.openai_api_key = provider_data.openai_api_key
|
||||
self.config.openai_api_key = SecretStr(provider_data.openai_api_key)
|
||||
|
||||
os.environ["OPENAI_API_KEY"] = self.config.openai_api_key
|
||||
os.environ["OPENAI_API_KEY"] = self.config.openai_api_key.get_secret_value()
|
||||
|
||||
async def score_batch(
|
||||
self,
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
# the root directory of this source tree.
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, Field, SecretStr
|
||||
|
||||
|
||||
class BraintrustScoringConfig(BaseModel):
|
||||
openai_api_key: str | None = Field(
|
||||
openai_api_key: SecretStr | None = Field(
|
||||
default=None,
|
||||
description="The OpenAI API Key",
|
||||
)
|
||||
|
|
|
@ -64,7 +64,9 @@ class ConsoleSpanProcessor(SpanProcessor):
|
|||
for key, value in event.attributes.items():
|
||||
if key.startswith("__") or key in ["message", "severity"]:
|
||||
continue
|
||||
logger.info(f"[dim]{key}[/dim]: {value}")
|
||||
|
||||
str_value = str(value)
|
||||
logger.info(f"[dim]{key}[/dim]: {str_value}")
|
||||
|
||||
def shutdown(self) -> None:
|
||||
"""Shutdown the processor."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue