🚸 allow toggling telemetry from vscode settings

This commit is contained in:
Nate Sesti 2023-10-20 15:28:11 -07:00
parent 6a18830887
commit 6fa9599bc7
4 changed files with 48 additions and 0 deletions

View file

@ -61,6 +61,11 @@
"type": "boolean",
"default": false,
"description": "If you are manually running the Continue server, you should update the Server URL and check this box. This will stop Continue from attempting to remove your server and download a new version."
},
"continue.telemetryEnabled": {
"type": "boolean",
"default": true,
"description": "Continue collects anonymous usage data, cleaned of PII, to help us improve the product for our users. Read more at https://continue.dev/docs/telemetry."
}
}
},

View file

@ -215,6 +215,16 @@ class IdeProtocolClient {
vscode.commands.executeCommand("workbench.action.reloadWindow");
}
});
const telemetryEnabled = vscode.workspace
.getConfiguration("continue")
.get<boolean>("telemetryEnabled");
if (
typeof telemetryEnabled !== "undefined" &&
telemetryEnabled !== null
) {
this.setTelemetryEnabled(telemetryEnabled);
}
}
});
}
@ -418,6 +428,10 @@ class IdeProtocolClient {
);
}
async setTelemetryEnabled(enabled: boolean) {
this.messenger?.send("setTelemetryEnabled", { enabled });
}
async showDiff(filepath: string, replacement: string, step_index: number) {
await diffManager.writeDiff(filepath, replacement, step_index);
}

View file

@ -47,6 +47,22 @@ def template_alpaca_messages(msgs: List[Dict[str, str]]) -> str:
return prompt
def phind_template_messages(msgs: List[Dict[str, str]]) -> str:
prompt = ""
if msgs[0]["role"] == "system":
prompt += f"### System Prompt\n{msgs[0]['content']}\n\n"
msgs.pop(0)
for msg in msgs:
prompt += "### User Message\n" if msg["role"] == "user" else "### Assistant\n"
prompt += f"{msg['content']}\n"
prompt += "### Assistant\n"
return prompt
def raw_input_template(msgs: List[Dict[str, str]]) -> str:
return msgs[-1]["content"]

View file

@ -292,6 +292,8 @@ class IdeProtocolServer(AbstractIdeProtocolServer):
self.onFilesRenamed(data["old_filepaths"], data["new_filepaths"])
elif message_type == "fileSaved":
self.onFileSaved(data["filepath"], data["contents"])
elif message_type == "setTelemetryEnabled":
self.onTelemetryEnabledChanged(data["enabled"])
else:
raise ValueError("Unknown message type", message_type)
@ -324,6 +326,17 @@ class IdeProtocolServer(AbstractIdeProtocolServer):
"setSuggestionsLocked", {"filepath": filepath, "locked": locked}
)
def onTelemetryEnabledChanged(self, enabled: bool):
if autopilot := self.__get_autopilot():
async def change_telemetry():
await autopilot.set_config_attr(
["allow_anonymous_telemetry"], "True" if enabled else "False"
)
await autopilot.continue_sdk.load()
create_async_task(change_telemetry(), self.on_error)
async def getSessionId(self):
new_session = await asyncio.wait_for(
self.session_manager.new_session(self, self.session_id), timeout=5