You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
return`The new cell should do the following:\n\n${prompt}`;
724
+
}
725
+
697
726
functiongetInput({
698
727
frameActions,
699
728
prompt,
@@ -703,23 +732,33 @@ function getInput({
703
732
}: GetInputProps): {
704
733
input: string;
705
734
system: string;
735
+
history: Message[];
706
736
}{
707
737
if(!prompt?.trim()){
708
-
return{input: "",system: ""};
738
+
return{input: "",system: "",history: []};
709
739
}
710
740
if(frameActions.current==null){
711
741
console.warn(
712
742
"Unable to create cell due to frameActions not being defined.",
713
743
);
714
-
return{input: "",system: ""};
744
+
return{input: "",system: "",history: []};
715
745
}
716
746
constprevCode=prevCodeContents
717
-
? `\n\nThe context after which to insert the cells is:\n\n<context>\n${prevCodeContents}\n\</context>`
747
+
? `The context after which to insert the cells is:\n\n<context>\n${prevCodeContents}\n\</context>\n\n`
718
748
: "";
719
749
750
+
consthistory: Message[]=[
751
+
{role: "user",content: getInputPrompt("Show the value of foo.")},
752
+
{
753
+
role: "assistant",
754
+
content: `This is the value of foo:\n\n\`\`\`${lang}\nprint(foo)\n\`\`\``,
755
+
},
756
+
];
757
+
720
758
return{
721
-
input: `Create a new code cell for a Jupyter Notebook.\n\nKernel: "${kernel_name}".\n\nProgramming language: "${lang}".\n\The entire code cell must be in a single code block. Enclose this block in triple backticks. Do not say what the output will be. Add comments as code comments. ${prevCode}\n\nThe new cell should do the following:\n\n${prompt}`,
722
-
system: `Return a single code block in the language "${lang}". Be brief.`,
759
+
input: `${prevCode}${getInputPrompt(prompt)}`,
760
+
history,
761
+
system: `Create one or more code cells in a Jupyter Notebook.\n\nKernel: "${kernel_name}".\n\nProgramming language: "${lang}".\n\nEach code cell must be wrapped in triple backticks. Do not say what the output will be. Be brief.`,
0 commit comments