Skip to content

Commit

Permalink
add input/output
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbozarth committed Nov 6, 2024
1 parent 7778998 commit c37e36e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
13 changes: 11 additions & 2 deletions src/service/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,20 @@ export async function postFeedback(
model_id?: string,
prompt_id?: string,
positive_feedback?: boolean,
comment?: string
comment?: string,
input?: string,
output?: string
): Promise<IFeedbackResponse> {
return await requestAPI('feedback', {
method: 'POST',
body: JSON.stringify({ model_id, prompt_id, positive_feedback, comment })
body: JSON.stringify({
model_id,
prompt_id,
positive_feedback,
comment,
input,
output
})
}).then(async response => {
if (response.ok) {
return await response.json();
Expand Down
9 changes: 7 additions & 2 deletions src/service/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,19 @@ async function promptPromise(
response.results.map(results => items.push(results.generated_text));
return {
items,
prompt_id: response.prompt_id
prompt_id: response.prompt_id,
input: requestText
};
}
);
}

export async function autoComplete(text: string): Promise<ICompletionReturn> {
const emptyReturn: ICompletionReturn = { items: [], prompt_id: '' };
const emptyReturn: ICompletionReturn = {
items: [],
prompt_id: '',
input: ''
};

return await checkAPIToken()
.then(async () => {
Expand Down
9 changes: 6 additions & 3 deletions src/service/feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ export function getFeedbackStatusBarWidget() {
export function getFeedback(prompt: boolean = true) {
const model_id = getCurrentModel()?._id;
const prompt_id = prompt ? lastPrompt?.prompt_id : undefined;
const prompt_text = prompt ? lastPrompt?.items[0] : undefined;
const prompt_input = prompt ? lastPrompt?.input : undefined;
const prompt_output = prompt ? lastPrompt?.items[0] : undefined;

const dialog = new Dialog({
title: 'Qiskit Code Assistant Feedback',
body: getFeedbackBodyWidget(prompt_text),
body: getFeedbackBodyWidget(prompt_output),
buttons: [Dialog.cancelButton(), Dialog.okButton({ label: 'Submit' })],
focusNodeSelector: '.jp-qiskit-code-assistant-feedback-form textarea'
});
Expand All @@ -90,7 +91,9 @@ export function getFeedback(prompt: boolean = true) {
model_id,
prompt_id,
toBool(result.value?.positive_feedback),
result.value?.comment
result.value?.comment,
prompt_input,
prompt_output
).then((response: IFeedbackResponse) => {
Notification.info(`Qiskit Code Assistant:\n${response['message']}`, {
autoClose: 5000
Expand Down
3 changes: 3 additions & 0 deletions src/utils/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,12 @@ export interface IFeedbackResponse {
export interface ICompletionReturn {
items: string[];
prompt_id: string;
input: string;
}

export interface IFeedbackForm {
positive_feedback?: string;
comment?: string;
input?: string;
output?: string;
}

0 comments on commit c37e36e

Please sign in to comment.