File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 15
15
16
16
import pkg_resources
17
17
from posthog import Posthog
18
+ import requests
18
19
19
20
posthog = Posthog (
20
21
"phc_6cmXy4MEbLfNGezqGjuUTY8abLu0sAwtGzZFpQW97lc" , host = "https://app.posthog.com"
@@ -60,3 +61,29 @@ def send_telemetry(event_name, properties=None):
60
61
except :
61
62
# Non blocking
62
63
pass
64
+
65
+
66
+ def contribute_conversations (conversations ):
67
+ url = "https://api.openinterpreter.com/v0/conversations/contribute/"
68
+ version = pkg_resources .get_distribution ("open-interpreter" ).version
69
+
70
+ if conversations and len (conversations ) > 1 :
71
+ payload = {
72
+ "conversations" : [conv for sublist in conversations for conv in sublist ],
73
+ "oi_version" : version
74
+ }
75
+ else :
76
+ payload = {
77
+ "conversations" : [conversations [0 ]],
78
+ "oi_version" : version
79
+ }
80
+ try :
81
+ response = requests .post (url , json = payload )
82
+ if response .status_code != 200 :
83
+ print (f"Failed to contribute conversation: { response .status_code } { response .text } " )
84
+ return None
85
+ else :
86
+ print (f"Successfully contributed conversation!" )
87
+ except requests .RequestException as e :
88
+ print (f"Failed to contribute conversation: { e } " )
89
+ return None
You can’t perform that action at this time.
0 commit comments