From 490de4e11917d1e64a4a2f8e53192a1b5339306c Mon Sep 17 00:00:00 2001 From: ZanSara Date: Mon, 16 Oct 2023 16:45:56 +0100 Subject: [PATCH] feat: add `_get_telemetry_data` to `GPTGenerator` (#5958) * add telemetry to pipelines 2.0 * only collect data if telemetry is on * reno * add downsampling * typing * manual tests * pylint * simplify code * Update haystack/preview/telemetry/__init__.py * look for _telemetry_data * rather index by component type * black * mypy * error handling * comment * add telemetry_data to gptgenerator * review feedback & small improvements * defaultdict * stray changes * try-catch * method instead of attribute * change attribute to method * fixes * remove print statements * lint * invert condition * always send the first event of the day * collect specs * track 2nd and 3rd events too * send first event and then max 1 event a minute * rename constant * black --- haystack/preview/components/generators/openai/gpt.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/haystack/preview/components/generators/openai/gpt.py b/haystack/preview/components/generators/openai/gpt.py index e5618f738e..fd9224376d 100644 --- a/haystack/preview/components/generators/openai/gpt.py +++ b/haystack/preview/components/generators/openai/gpt.py @@ -91,6 +91,12 @@ def __init__( self.streaming_callback = streaming_callback self.api_base_url = api_base_url + def _get_telemetry_data(self) -> Dict[str, Any]: + """ + Data that is sent to Posthog for usage analytics. + """ + return {"model": self.model_name} + def to_dict(self) -> Dict[str, Any]: """ Serialize this component to a dictionary.