mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-01-01 17:09:59 +01:00
collect telemetry and ask user for feedback
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
# main.py
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
from helpers.Project import Project
|
||||
|
||||
from utils.arguments import get_arguments
|
||||
from utils.exit import exit_gpt_pilot
|
||||
from logger.logger import logger
|
||||
from database.database import database_exists, create_database, tables_exist, create_tables
|
||||
|
||||
@@ -28,8 +31,13 @@ def init():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = init()
|
||||
|
||||
# TODO get checkpoint from database and fill the project with it
|
||||
project = Project(args)
|
||||
project.start()
|
||||
try:
|
||||
args = init()
|
||||
project = Project(args)
|
||||
project.start()
|
||||
except KeyboardInterrupt:
|
||||
exit_gpt_pilot()
|
||||
except Exception as e:
|
||||
exit_gpt_pilot()
|
||||
finally:
|
||||
sys.exit(0)
|
||||
|
||||
51
pilot/utils/exit.py
Normal file
51
pilot/utils/exit.py
Normal file
@@ -0,0 +1,51 @@
|
||||
# exit.py
|
||||
import os
|
||||
import hashlib
|
||||
import requests
|
||||
|
||||
from utils.questionary import get_user_feedback
|
||||
|
||||
|
||||
def send_telemetry(path_id):
|
||||
# Prepare the telemetry data
|
||||
telemetry_data = {
|
||||
"pathId": path_id,
|
||||
"event": "pilot-exit"
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.post("https://api.pythagora.io/telemetry", json=telemetry_data)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as err:
|
||||
print(f"Failed to send telemetry data: {err}")
|
||||
|
||||
|
||||
def send_feedback(feedback, path_id):
|
||||
"""Send the collected feedback to the endpoint."""
|
||||
# Prepare the feedback data (you can adjust the structure as per your backend needs)
|
||||
feedback_data = {
|
||||
"pathId": path_id,
|
||||
"data": feedback,
|
||||
"event": "pilot-feedback"
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.post("https://api.pythagora.io/telemetry", json=feedback_data)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as err:
|
||||
print(f"Failed to send feedback data: {err}")
|
||||
|
||||
|
||||
def get_path_id():
|
||||
# Calculate the SHA-256 hash of the installation directory
|
||||
installation_directory = os.path.abspath(os.path.join(os.getcwd(), ".."))
|
||||
return hashlib.sha256(installation_directory.encode()).hexdigest()
|
||||
|
||||
|
||||
def exit_gpt_pilot():
|
||||
path_id = get_path_id()
|
||||
send_telemetry(path_id)
|
||||
|
||||
feedback = get_user_feedback()
|
||||
if feedback: # only send if user provided feedback
|
||||
send_feedback(feedback, path_id)
|
||||
@@ -37,3 +37,10 @@ def styled_text(project, question):
|
||||
print('\n\n', end='')
|
||||
|
||||
return response
|
||||
|
||||
|
||||
def get_user_feedback():
|
||||
config = {
|
||||
'style': custom_style,
|
||||
}
|
||||
return questionary.text("Thank you for trying GPT-Pilot. Please give us your feedback or just press ENTER to exit: ", **config).unsafe_ask()
|
||||
|
||||
Reference in New Issue
Block a user