Skip to content

Commit 1caf369

Browse files
committed
frontend/jupyter/llm: add Assistant dialog to markdown cells
1 parent 177f37a commit 1caf369

24 files changed

+1007
-155
lines changed

src/packages/frontend/account/i18n-selector.tsx

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44
*/
55

66
/*
7-
Basically a drop-down to change the langauge (i18n localization)
7+
Basically a drop-down to change the language (i18n localization)
88
*/
99

1010
import { DownOutlined } from "@ant-design/icons";
11-
import { Button, Dropdown, MenuProps, Modal, Space, Tooltip } from "antd";
11+
import {
12+
Button,
13+
Dropdown,
14+
MenuProps,
15+
Modal,
16+
Select,
17+
SelectProps,
18+
Space,
19+
Tooltip,
20+
} from "antd";
1221
import { SizeType } from "antd/es/config-provider/SizeContext";
1322
import { useState } from "react";
1423
import { defineMessage, useIntl } from "react-intl";
@@ -54,6 +63,50 @@ Thank you for your patience and understanding as we work to make our application
5463
description: "Content of translation information modal",
5564
});
5665

66+
interface LanguageSelectorProps
67+
extends Omit<SelectProps, "options" | "onChange"> {
68+
value?: string;
69+
onChange?: (language: string) => void;
70+
}
71+
72+
/**
73+
* A reusable language selector component for translation purposes.
74+
*/
75+
export function LanguageSelector({
76+
value,
77+
onChange,
78+
...props
79+
}: LanguageSelectorProps) {
80+
const intl = useIntl();
81+
82+
let availableLocales = Object.keys(LOCALIZATIONS) as Locale[];
83+
84+
const options = availableLocales.map((locale) => {
85+
const localization = LOCALIZATIONS[locale];
86+
const other =
87+
locale === value
88+
? localization.name
89+
: intl.formatMessage(localization.trans);
90+
return {
91+
value: locale,
92+
label: `${localization.flag} ${localization.native} (${other})`,
93+
};
94+
});
95+
96+
return (
97+
<Select
98+
value={value}
99+
onChange={onChange}
100+
options={options}
101+
placeholder="Select a language..."
102+
showSearch
103+
optionFilterProp="label"
104+
popupMatchSelectWidth={false}
105+
{...props}
106+
/>
107+
);
108+
}
109+
57110
export function I18NSelector(props: Readonly<Props>) {
58111
const { isWide = true, size, confirm = false } = props;
59112

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// number of characters we send to an LLM for context
2-
export const CUTOFF = 3000;
2+
export const CUTOFF = 5000;
33

44
// this came from ./create-chat, but for all frame types
55
export const AI_ASSIST_TAG = "code-editor";

src/packages/frontend/i18n/trans/ar_EG.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,8 @@
634634
"jupyter.cell-buttonbar-menu.paste-cell-below": "لصق الخلية أدناه",
635635
"jupyter.cell-buttonbar-menu.paste-clipboard": "لصق من الحافظة",
636636
"jupyter.cell-buttonbar-menu.split-cell": "قسّم الخلية عند المؤشر",
637-
"jupyter.cell-buttonbr.format-button.label": "تنسيق",
638-
"jupyter.cell-buttonbr.format-button.tooltip": "نسّق هذا الكود ليبدو جميلاً",
637+
"jupyter.cell-buttonbar.format-button.label": "تنسيق",
638+
"jupyter.cell-buttonbar.format-button.tooltip": "نسّق هذا الكود ليبدو جميلاً",
639639
"jupyter.commands.cell_toolbar_attachments.label": "شريط أدوات المرفقات",
640640
"jupyter.commands.cell_toolbar_attachments.menu": "المرفقات",
641641
"jupyter.commands.cell_toolbar_create_assignment.label": "إنشاء واجب باستخدام NBgrader",
@@ -822,6 +822,15 @@
822822
"jupyter.llm.cell-tool.actions.explain.label": "اشرح",
823823
"jupyter.llm.cell-tool.actions.improve.descr": "حسّن الشيفرة في تلك الخلية",
824824
"jupyter.llm.cell-tool.actions.improve.label": "تحسين",
825+
"jupyter.llm.cell-tool.actions.md.ask.descr": "اطرح سؤالًا مخصصًا حول هذه الخلية مع سياق اختياري من الخلايا المحيطة.",
826+
"jupyter.llm.cell-tool.actions.md.document.descr": "اكتب ملخصًا حول جميع الخلايا في السياق",
827+
"jupyter.llm.cell-tool.actions.md.document.label": "توثيق",
828+
"jupyter.llm.cell-tool.actions.md.formulize.descr": "أضف صيغًا رياضية لجعل النص أكثر قابلية للقراءة للعلماء.",
829+
"jupyter.llm.cell-tool.actions.md.formulize.label": "إضافة صيغ",
830+
"jupyter.llm.cell-tool.actions.md.proofread.descr": "تحسين اللغة، إصلاح الأخطاء الإملائية والنحوية.",
831+
"jupyter.llm.cell-tool.actions.md.proofread.label": "تدقيق",
832+
"jupyter.llm.cell-tool.actions.md.translate-text.descr": "ترجمة محتوى النص إلى لغة بشرية أخرى.",
833+
"jupyter.llm.cell-tool.actions.md.translate-text.label": "ترجمة",
825834
"jupyter.llm.cell-tool.actions.modify.descr": "عدل الكود في الخلية",
826835
"jupyter.llm.cell-tool.actions.modify.label": "تعديل",
827836
"jupyter.llm.cell-tool.actions.translate.descr": "ترجمة الشيفرة في تلك الخلية إلى لغة أخرى باستخدام الذكاء الاصطناعي.",
@@ -831,16 +840,21 @@
831840
"jupyter.llm.cell-tool.assistant.title": "استخدم مساعد الذكاء الاصطناعي على هذه الخلية",
832841
"jupyter.llm.cell-tool.bugfix.label": "خلل",
833842
"jupyter.llm.cell-tool.bugfix.placeholder": "صف المشكلة التي تحتاج إلى إصلاحها...",
843+
"jupyter.llm.cell-tool.document.label": "تركيز",
844+
"jupyter.llm.cell-tool.document.placeholder": "على ماذا يجب أن تركز الوثائق؟ (اختياري)",
834845
"jupyter.llm.cell-tool.explain.description": "كيف تشرح الشيفرة؟ إما {summary} عالي المستوى أو {step_by_step} تفسيرات.",
835846
"jupyter.llm.cell-tool.explain.step-by-step": "خطوة بخطوة",
836847
"jupyter.llm.cell-tool.explain.summary": "ملخص",
837848
"jupyter.llm.cell-tool.explanation.ask": "اطرح أي سؤال حول الكود في هذه الخلية. سيقوم نموذج اللغة بتحليل الكود وتقديم إجابة بناءً على سؤالك المحدد.",
838849
"jupyter.llm.cell-tool.explanation.bugfix": "اشرح مشكلة الكود في الخلية وسيحاول النموذج اللغوي المحدد إصلاحها. عادةً، سيخبرك إذا وجد مشكلة ويشرحها لك.",
839850
"jupyter.llm.cell-tool.explanation.document": "سيقوم نموذج اللغة بإضافة سطور التوثيق إلى الكود في الخلية.",
840851
"jupyter.llm.cell-tool.explanation.explain": "سيتم إرسال الكود في الخلية إلى النموذج اللغوي المحدد. سيوضح لك الكود بلغة بسيطة.",
852+
"jupyter.llm.cell-tool.explanation.formulize": "سيضيف نموذج اللغة الصيغ الرياضية المناسبة باستخدام ترميز LaTeX لجعل النص أكثر وضوحًا للعلماء.",
841853
"jupyter.llm.cell-tool.explanation.improve": "سيقوم نموذج اللغة المحدد بتحليل الشفرة واقتراح تحسينات. احذر، فالنتائج لا يُضمن أن تكون صحيحة، وقد تسبب مشاكل طفيفة – راجعها بعناية.",
842854
"jupyter.llm.cell-tool.explanation.modify": "سيقوم نموذج اللغة بتعديل الكود وفقًا للتعليمات المعطاة. اختر أحد النماذج وقم بتعديله، أو ابتكر تعليمات خاصة بك!",
855+
"jupyter.llm.cell-tool.explanation.proofread": "سيقوم نموذج اللغة بمراجعة نص الماركداون، وتصحيح الأخطاء الإملائية والنحوية مع تحسين الوضوح وسهولة القراءة.",
843856
"jupyter.llm.cell-tool.explanation.translate": "سيحاول نموذج اللغة ترجمة الكود في الخلية إلى لغة برمجة أخرى. قد لا يعمل الناتج على الإطلاق - ولكن إذا كنت أكثر دراية بلغة الهدف المختارة، فقد تجد من الأسهل فهم ما يحدث!",
857+
"jupyter.llm.cell-tool.explanation.translate-text": "سيقوم نموذج اللغة بترجمة نصوص الماركداون إلى اللغة المحددة مع الحفاظ على التنسيق والهيكل.",
844858
"jupyter.llm.cell-tool.footer.info": "إرسال هذه الرسالة إلى {model} سيبدأ محادثة في <A>إطار الدردشة الجانبية</A>. سيرد نموذج اللغة ويمكنك متابعة المحادثة في نفس الموضوع.",
845859
"jupyter.llm.cell-tool.improve.label": "تحسين",
846860
"jupyter.llm.cell-tool.improve.placeholder": "سرعة التنفيذ، القابلية للقراءة، …",

src/packages/frontend/i18n/trans/de_DE.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,8 @@
634634
"jupyter.cell-buttonbar-menu.paste-cell-below": "Zelle darunter einfügen",
635635
"jupyter.cell-buttonbar-menu.paste-clipboard": "Aus Zwischenablage einfügen",
636636
"jupyter.cell-buttonbar-menu.split-cell": "Zelle am Cursor teilen",
637-
"jupyter.cell-buttonbr.format-button.label": "Format",
638-
"jupyter.cell-buttonbr.format-button.tooltip": "Formatieren Sie diesen Code, damit er gut aussieht",
637+
"jupyter.cell-buttonbar.format-button.label": "Format",
638+
"jupyter.cell-buttonbar.format-button.tooltip": "Formatieren Sie diesen Code, damit er gut aussieht",
639639
"jupyter.commands.cell_toolbar_attachments.label": "Werkzeugleiste für Anhänge",
640640
"jupyter.commands.cell_toolbar_attachments.menu": "Anhänge",
641641
"jupyter.commands.cell_toolbar_create_assignment.label": "Aufgabe mit NBgrader erstellen",
@@ -822,6 +822,15 @@
822822
"jupyter.llm.cell-tool.actions.explain.label": "Erklären",
823823
"jupyter.llm.cell-tool.actions.improve.descr": "Verbessern des Codes in dieser Zelle.",
824824
"jupyter.llm.cell-tool.actions.improve.label": "Verbessern",
825+
"jupyter.llm.cell-tool.actions.md.ask.descr": "Stellen Sie eine benutzerdefinierte Frage zu dieser Zelle mit optionalem Kontext aus den umliegenden Zellen.",
826+
"jupyter.llm.cell-tool.actions.md.document.descr": "Schreiben Sie eine Zusammenfassung über alle Zellen im Kontext",
827+
"jupyter.llm.cell-tool.actions.md.document.label": "Dokumentieren",
828+
"jupyter.llm.cell-tool.actions.md.formulize.descr": "Fügen Sie mathematische Formeln hinzu, um den Text für Wissenschaftler lesbarer zu machen.",
829+
"jupyter.llm.cell-tool.actions.md.formulize.label": "Formeln hinzufügen",
830+
"jupyter.llm.cell-tool.actions.md.proofread.descr": "Sprache verbessern, Rechtschreib- und Grammatikfehler beheben.",
831+
"jupyter.llm.cell-tool.actions.md.proofread.label": "Korrekturlesen",
832+
"jupyter.llm.cell-tool.actions.md.translate-text.descr": "Übersetze den Textinhalt in eine andere menschliche Sprache.",
833+
"jupyter.llm.cell-tool.actions.md.translate-text.label": "Übersetzen",
825834
"jupyter.llm.cell-tool.actions.modify.descr": "Ändern des Codes in der Zelle",
826835
"jupyter.llm.cell-tool.actions.modify.label": "Ändern",
827836
"jupyter.llm.cell-tool.actions.translate.descr": "Übersetze den Code in dieser Zelle in eine andere Sprache mit KI.",
@@ -831,16 +840,21 @@
831840
"jupyter.llm.cell-tool.assistant.title": "AI-Assistent für diese Zelle verwenden",
832841
"jupyter.llm.cell-tool.bugfix.label": "Fehler",
833842
"jupyter.llm.cell-tool.bugfix.placeholder": "Beschreiben Sie das zu behebende Problem…",
843+
"jupyter.llm.cell-tool.document.label": "Fokus",
844+
"jupyter.llm.cell-tool.document.placeholder": "Worauf sollte die Dokumentation fokussieren? (optional)",
834845
"jupyter.llm.cell-tool.explain.description": "Wie erklärt man den Code? Entweder eine hochrangige {summary} oder {step_by_step} Erklärungen.",
835846
"jupyter.llm.cell-tool.explain.step-by-step": "Schritt-für-Schritt",
836847
"jupyter.llm.cell-tool.explain.summary": "Zusammenfassung",
837848
"jupyter.llm.cell-tool.explanation.ask": "Stellen Sie jede Frage zum Code in dieser Zelle. Das Sprachmodell wird den Code analysieren und basierend auf Ihrer spezifischen Frage eine Antwort geben.",
838849
"jupyter.llm.cell-tool.explanation.bugfix": "Erklären Sie das Problem des Codes in der Zelle, und das ausgewählte Sprachmodell wird versuchen, es zu beheben. Normalerweise wird es Ihnen mitteilen, ob es ein Problem gefunden hat und es Ihnen erklären.",
839850
"jupyter.llm.cell-tool.explanation.document": "Das Sprachmodell wird Dokumentationszeilen zum Code in der Zelle hinzufügen.",
840851
"jupyter.llm.cell-tool.explanation.explain": "Der Code in der Zelle wird an das ausgewählte Sprachmodell gesendet. Es wird den Code in einfacher Sprache erklären.",
852+
"jupyter.llm.cell-tool.explanation.formulize": "Das Sprachmodell wird geeignete mathematische Formeln unter Verwendung der LaTeX-Notation hinzufügen, um den Text für Wissenschaftler lesbarer zu machen.",
841853
"jupyter.llm.cell-tool.explanation.improve": "Das ausgewählte Sprachmodell wird den Code analysieren und Verbesserungen vorschlagen. Beachten Sie, dass die Ergebnisse nicht garantiert korrekt sind und subtile Probleme verursachen können – überprüfen Sie sie sorgfältig.",
842854
"jupyter.llm.cell-tool.explanation.modify": "Das Sprachmodell wird den Code gemäß den gegebenen Anweisungen ändern. Wählen Sie eine der Vorlagen aus und passen Sie sie an, oder denken Sie sich eigene Anweisungen aus!",
855+
"jupyter.llm.cell-tool.explanation.proofread": "Das Sprachmodell wird den Markdown-Text korrigieren, indem es Rechtschreib- und Grammatikfehler behebt und gleichzeitig Klarheit und Lesbarkeit verbessert.",
843856
"jupyter.llm.cell-tool.explanation.translate": "Das Sprachmodell wird versuchen, den Code in der Zelle in eine andere Programmiersprache zu übersetzen. Das Ergebnis könnte überhaupt nicht funktionieren – aber wenn du mit der ausgewählten Zielsprache vertrauter bist, findest du es vielleicht einfacher zu verstehen, was vor sich geht!",
857+
"jupyter.llm.cell-tool.explanation.translate-text": "Das Sprachmodell wird den Markdown-Text in die ausgewählte Sprache übersetzen, während Formatierung und Struktur beibehalten werden.",
844858
"jupyter.llm.cell-tool.footer.info": "Das Übermitteln dieser Nachricht an {model} wird einen Chat im <A>Seiten-Chat-Fenster</A> starten. Das Sprachmodell antwortet und Sie können das Gespräch im selben Thread fortsetzen.",
845859
"jupyter.llm.cell-tool.improve.label": "Verbesserung",
846860
"jupyter.llm.cell-tool.improve.placeholder": "Ausführungsgeschwindigkeit, Lesbarkeit, …",

src/packages/frontend/i18n/trans/es_ES.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,8 @@
634634
"jupyter.cell-buttonbar-menu.paste-cell-below": "Pegar Celda Abajo",
635635
"jupyter.cell-buttonbar-menu.paste-clipboard": "Pegar desde el portapapeles",
636636
"jupyter.cell-buttonbar-menu.split-cell": "Dividir Celda en el Cursor",
637-
"jupyter.cell-buttonbr.format-button.label": "Formato",
638-
"jupyter.cell-buttonbr.format-button.tooltip": "Formatea este código para que se vea bien",
637+
"jupyter.cell-buttonbar.format-button.label": "Formato",
638+
"jupyter.cell-buttonbar.format-button.tooltip": "Formatea este código para que se vea bien",
639639
"jupyter.commands.cell_toolbar_attachments.label": "Barra de herramientas de adjuntos",
640640
"jupyter.commands.cell_toolbar_attachments.menu": "Adjuntos",
641641
"jupyter.commands.cell_toolbar_create_assignment.label": "Crear Tarea Usando NBgrader",
@@ -822,6 +822,15 @@
822822
"jupyter.llm.cell-tool.actions.explain.label": "Explicar",
823823
"jupyter.llm.cell-tool.actions.improve.descr": "Mejora el código en esa celda.",
824824
"jupyter.llm.cell-tool.actions.improve.label": "Mejorar",
825+
"jupyter.llm.cell-tool.actions.md.ask.descr": "Haz una pregunta personalizada sobre esta celda con contexto opcional de las celdas circundantes.",
826+
"jupyter.llm.cell-tool.actions.md.document.descr": "Escribe un resumen sobre todas las celdas en el contexto",
827+
"jupyter.llm.cell-tool.actions.md.document.label": "Documentar",
828+
"jupyter.llm.cell-tool.actions.md.formulize.descr": "Añadir fórmulas matemáticas para hacer el texto más comprensible para los científicos.",
829+
"jupyter.llm.cell-tool.actions.md.formulize.label": "Agregar fórmulas",
830+
"jupyter.llm.cell-tool.actions.md.proofread.descr": "Mejorar el idioma, corregir errores de ortografía y gramática.",
831+
"jupyter.llm.cell-tool.actions.md.proofread.label": "Corregir pruebas",
832+
"jupyter.llm.cell-tool.actions.md.translate-text.descr": "Traduce el contenido del texto a otro idioma humano.",
833+
"jupyter.llm.cell-tool.actions.md.translate-text.label": "Traducir",
825834
"jupyter.llm.cell-tool.actions.modify.descr": "Modifica el código en la celda",
826835
"jupyter.llm.cell-tool.actions.modify.label": "Modificar",
827836
"jupyter.llm.cell-tool.actions.translate.descr": "Traduce el código en esa celda a otro idioma usando AI.",
@@ -831,16 +840,21 @@
831840
"jupyter.llm.cell-tool.assistant.title": "Usar asistente de IA en esta celda",
832841
"jupyter.llm.cell-tool.bugfix.label": "Error",
833842
"jupyter.llm.cell-tool.bugfix.placeholder": "Describe el problema para solucionar…",
843+
"jupyter.llm.cell-tool.document.label": "Enfocar",
844+
"jupyter.llm.cell-tool.document.placeholder": "¿En qué debería centrarse la documentación? (opcional)",
834845
"jupyter.llm.cell-tool.explain.description": "Cómo explicar el código? Ya sea un {summary} de alto nivel o explicaciones {step_by_step}.",
835846
"jupyter.llm.cell-tool.explain.step-by-step": "Paso-a-paso",
836847
"jupyter.llm.cell-tool.explain.summary": "Resumen",
837848
"jupyter.llm.cell-tool.explanation.ask": "Haz cualquier pregunta sobre el código en esta celda. El modelo de lenguaje analizará el código y proporcionará una respuesta basada en tu pregunta específica.",
838849
"jupyter.llm.cell-tool.explanation.bugfix": "Explica el problema del código en la celda y el modelo de lenguaje seleccionado intentará solucionarlo. Normalmente, te dirá si encontró un problema y te lo explicará.",
839850
"jupyter.llm.cell-tool.explanation.document": "El modelo de lenguaje añadirá líneas de documentación al código en la celda",
840851
"jupyter.llm.cell-tool.explanation.explain": "El código en la celda se enviará al modelo de lenguaje seleccionado. Te explicará el código en lenguaje sencillo.",
852+
"jupyter.llm.cell-tool.explanation.formulize": "El modelo de lenguaje añadirá fórmulas matemáticas apropiadas usando notación LaTeX para hacer el texto más legible para los científicos.",
841853
"jupyter.llm.cell-tool.explanation.improve": "El modelo de lenguaje seleccionado analizará el código y sugerirá mejoras. Tenga en cuenta que los resultados no están garantizados para ser correctos, ni podrían causar problemas sutiles, así que revíselos cuidadosamente.",
842854
"jupyter.llm.cell-tool.explanation.modify": "El modelo de lenguaje modificará el código según las instrucciones dadas. Elige una de las plantillas y modifícala, ¡o crea tus propias instrucciones!",
855+
"jupyter.llm.cell-tool.explanation.proofread": "El modelo de lenguaje revisará el texto en markdown, corrigiendo errores ortográficos y gramaticales mientras mejora la claridad y legibilidad.",
843856
"jupyter.llm.cell-tool.explanation.translate": "El modelo de lenguaje intentará traducir el código en la celda a otro lenguaje de programación. El resultado podría no funcionar en absoluto, pero si estás más familiarizado con el lenguaje de destino seleccionado, ¡podrías encontrarlo más fácil de entender lo que está pasando!",
857+
"jupyter.llm.cell-tool.explanation.translate-text": "El modelo de lenguaje traducirá el texto markdown al idioma seleccionado mientras conserva el formato y la estructura.",
844858
"jupyter.llm.cell-tool.footer.info": "Enviar este mensaje a {model} iniciará un chat en el <A>marco de chat lateral</A>. El modelo de lenguaje responderá y podrás continuar la conversación en el mismo hilo.",
845859
"jupyter.llm.cell-tool.improve.label": "Mejora",
846860
"jupyter.llm.cell-tool.improve.placeholder": "velocidad de ejecución, legibilidad, …",

0 commit comments

Comments
 (0)