fix: 🐛 fix telemetry bug
This commit is contained in:
parent
972f38d725
commit
042bc5ac76
3 changed files with 21 additions and 7 deletions
|
|
@ -285,6 +285,7 @@ class Autopilot(ContinueBaseModel):
|
|||
async def edit_step_at_index(self, user_input: str, index: int):
|
||||
step_to_rerun = self.history.timeline[index].step.copy()
|
||||
step_to_rerun.user_input = user_input
|
||||
step_to_rerun.description = user_input
|
||||
|
||||
# Halt the agent's currently running jobs (delete them)
|
||||
while len(self.history.timeline) > index:
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ DEFAULT_MAX_TIME = 120.0
|
|||
class HuggingFaceInferenceAPI(LLM):
|
||||
model: str
|
||||
hf_token: str
|
||||
self_hosted_url: str = None
|
||||
|
||||
max_context_length: int = 2048
|
||||
verify_ssl: Optional[bool] = None
|
||||
|
|
@ -49,7 +50,9 @@ class HuggingFaceInferenceAPI(LLM):
|
|||
self, prompt: str, with_history: List[ChatMessage] = None, **kwargs
|
||||
):
|
||||
"""Return the completion of the text with the given temperature."""
|
||||
API_URL = f"https://api-inference.huggingface.co/models/{self.model}"
|
||||
API_URL = (
|
||||
self.base_url or f"https://api-inference.huggingface.co/models/{self.model}"
|
||||
)
|
||||
headers = {"Authorization": f"Bearer {self.hf_token}"}
|
||||
|
||||
response = requests.post(
|
||||
|
|
|
|||
|
|
@ -15,22 +15,28 @@ POSTHOG_API_KEY = "phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs"
|
|||
|
||||
class PostHogLogger:
|
||||
unique_id: str = "NO_UNIQUE_ID"
|
||||
allow_anonymous_telemetry: bool = True
|
||||
allow_anonymous_telemetry: bool = False
|
||||
posthog: Posthog = None
|
||||
|
||||
def __init__(self, api_key: str):
|
||||
self.api_key = api_key
|
||||
|
||||
# The personal API key is necessary only if you want to use local evaluation of feature flags.
|
||||
self.posthog = Posthog(self.api_key, host="https://app.posthog.com")
|
||||
|
||||
def setup(self, unique_id: str, allow_anonymous_telemetry: bool):
|
||||
self.unique_id = unique_id or "NO_UNIQUE_ID"
|
||||
self.allow_anonymous_telemetry = allow_anonymous_telemetry or True
|
||||
self.allow_anonymous_telemetry = allow_anonymous_telemetry or False
|
||||
|
||||
# Capture initial event
|
||||
self.capture_event("session_start", {"os": os.name})
|
||||
|
||||
def capture_event(self, event_name: str, event_properties: Any):
|
||||
"""Safely capture event. Telemetry should never be the reason Continue doesn't work"""
|
||||
try:
|
||||
self._capture_event(event_name, event_properties)
|
||||
except Exception as e:
|
||||
print(f"Failed to capture event: {e}")
|
||||
pass
|
||||
|
||||
def _capture_event(self, event_name: str, event_properties: Any):
|
||||
# logger.debug(
|
||||
# f"Logging to PostHog: {event_name} ({self.unique_id}, {self.allow_anonymous_telemetry}): {event_properties}")
|
||||
telemetry_path = os.path.expanduser("~/.continue/telemetry.log")
|
||||
|
|
@ -60,11 +66,15 @@ class PostHogLogger:
|
|||
if os.path.exists(server_version_file):
|
||||
with open(server_version_file, "r") as f:
|
||||
event_properties["server_version"] = f.read()
|
||||
|
||||
|
||||
# Add operating system
|
||||
event_properties["os"] = os.name
|
||||
|
||||
# Send event to PostHog
|
||||
if self.posthog is None:
|
||||
# The personal API key is necessary only if you want to use local evaluation of feature flags.
|
||||
self.posthog = Posthog(self.api_key, host="https://app.posthog.com")
|
||||
|
||||
self.posthog.capture(self.unique_id, event_name, event_properties)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue