Skip to content

User study bugfix #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions code4me-server/src/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import annotations
import os, time, random, json, uuid, glob, torch, traceback
import os, time, random, json, uuid, torch, traceback

from enum import Enum
from typing import List, Tuple
Expand Down Expand Up @@ -68,7 +68,7 @@ def autocomplete_v2():
log_context = f'{request_json["prefix"][-10:]}•{request_json["suffix"][:5]}'
current_app.logger.warning(f'{log_filter} {log_context} \t{filter_type} {[v[:10] for v in predictions.values()]}')

verify_token = uuid.uuid4().hex if not should_filter else ''
verify_token = uuid.uuid4().hex
prompt_survey = should_prompt_survey(user_uuid) if not should_filter else False

store_completion_request(user_uuid, verify_token, {
Expand Down Expand Up @@ -182,7 +182,9 @@ def predict_model(model: Model) -> List[str]:

verify_token = uuid.uuid4().hex

with open(f"data/{user_token}-{verify_token}.json", "w+") as f:
user_dir = os.path.join("data", user_token)
os.makedirs(user_dir, exist_ok=True)
with open(os.path.join(user_dir, f"{verify_token}.json"), "w+") as f:
f.write(json.dumps({
"completionTimestamp": datetime.now().isoformat(),
"triggerPoint": values["triggerPoint"],
Expand All @@ -199,9 +201,8 @@ def predict_model(model: Model) -> List[str]:
"rightContext": right_context if store_context else None
}))

# # # TODO: disabled surveys temporarily, as we are currently looking through >1M files on every request.
# n_suggestions = len(glob.glob(f"data/{user_token}*.json"))
# survey = n_suggestions >= 100 and n_suggestions % 50 == 0
n_suggestions = len(os.listdir(user_dir))
survey = n_suggestions >= 100 and n_suggestions % 50 == 0
survey = False

return response({
Expand Down Expand Up @@ -230,7 +231,7 @@ def verify():
return res

verify_token = values["verifyToken"]
file_path = f"data/{user_token}-{verify_token}.json"
file_path = os.path.join("data", user_token, f"{verify_token}.json")
if not os.path.exists(file_path):
return response({
"error": "Invalid verify token"
Expand Down
2 changes: 1 addition & 1 deletion code4me-server/src/query_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class Filter(enum.Enum):
JOINT_H = 'joint_h'
JOINT_A = 'joint_a'

no_filter = lambda request_json: True
no_filter = lambda request_json: False
logres = Logres(coef, intercept)
set_all_seeds() # just in case
context_filter = MyPipeline( device=DEVICE, task='text-classification',
Expand Down
2 changes: 1 addition & 1 deletion code4me-vsc-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Language model code completion.",
"author": "Code4Me",
"license": "Apache-2.0",
"version": "1.1.0",
"version": "1.1.1",
"categories": [
"Machine Learning",
"Programming Languages",
Expand Down
4 changes: 2 additions & 2 deletions code4me-vsc-plugin/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function activate(context: vscode.ExtensionContext) {

start(context).then(disposable => {
context.subscriptions.push(disposable);
console.log('Code4me Activated!')
console.log(`Code4Me Activated! v${CODE4ME_VERSION}`)
})
}

Expand Down Expand Up @@ -362,12 +362,12 @@ class CompletionItemProvider implements vscode.CompletionItemProvider {
item.detail = '\u276E\uff0f\u276f' // Added the Logo here instead
item.documentation = 'Completion from ' + model

item.shownTimes = [new Date().toISOString()];
item.command = {
command: 'verifyInsertion',
title: 'Verify Insertion',
arguments: [prediction, position, document, verifyToken, this.uuid, item.shownTimes, () => {this.setIdleTrigger()}]
};
item.shownTimes = [new Date().toISOString()];

// This is useful if you want to see what's exactly going on with the range and prefix modifications
// I use • to denote the cursor position
Expand Down