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
This commit is contained in:
ZanSara 2023-10-16 16:45:56 +01:00 committed by GitHub
parent 660f84e6ef
commit 490de4e119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,6 +91,12 @@ class GPTGenerator:
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.