Skip to content

Commit

Permalink
feat: add _get_telemetry_data to GPTGenerator (#5958)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ZanSara authored Oct 16, 2023
1 parent 660f84e commit 490de4e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions haystack/preview/components/generators/openai/gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 490de4e

Please sign in to comment.