Skip to content

Commit

Permalink
chore: HuggingFaceLocalGenerator telemetry (#6070)
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

* review feedback & small improvements

* defaultdict

* stray changes

* try-catch

* method instead of attribute

* 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

* add telemetry details to HuggingFaceLocalGenerator

* add test

* check if the model is a string

---------

Co-authored-by: Stefano Fiorucci <[email protected]>
  • Loading branch information
ZanSara and anakin87 authored Oct 16, 2023
1 parent 6b09792 commit 22a24c8
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ def __init__(
self.generation_kwargs = generation_kwargs
self.pipeline = None

def _get_telemetry_data(self) -> Dict[str, Any]:
"""
Data that is sent to Posthog for usage analytics.
"""
if isinstance(self.pipeline_kwargs["model"], str):
return {"model": self.pipeline_kwargs["model"]}
return {"model": f"[object of type {type(self.pipeline_kwargs['model'])}]"}

def warm_up(self):
if self.pipeline is None:
self.pipeline = pipeline(**self.pipeline_kwargs)
Expand Down

0 comments on commit 22a24c8

Please sign in to comment.