Skip to content

Commit ab1e4fc

Browse files
committed
Extract token counts into a dedicated component and display them below the prompt field
- create a new UI component: 'TokenCounts'. Should accept props: token_count: {selected_files, prompt} and translation keys: 'selected files', 'prompt'. Place below Prompt Field. - these [Fragment] should live in a new file: main.ts - in `apps/editor/src/views/prompt/frontend/Main/MainView/MainView.tsx` use `apps/editor/src/utils/display-token-count.ts` - should be string [Fragment] - to `packages/ui/src/components/editor/prompt/TokenCounts/TokenCounts.tsx` add 'edit format', calculate count properly based on current 'edit format'. also make it optional so that it is only provided in 'edit' prompt type. - change order of items 'selected files','edit format','prompt' - render one under another with a checkbox in disabled state - render in a single row - leave checkpoint only on 'selected files' - place label and value in a separate div, with gap: 3px - fix class names in `packages/ui/src/components/editor/prompt/TokenCounts/TokenCounts.tsx` - merge 'edit format' token count into 'prompt' - from prompt field, remove token count - fix `packages/ui/src/components/editor/common/prompts/PromptField/PromptField.stories.tsx` - rename 'edit format' to 'edit format instructions' (in translations, file names, etc.) ├── apps │ └── editor │ └── src │ ├── constants │ │ └── edit-format-instructions.ts │ ├── i18n │ │ └── translations │ │ └── views │ │ └── prompt │ │ └── handlers │ │ └── select-edit-format-instructions.ts │ ├── utils │ │ └── display-token-count.ts │ └── views │ └── prompt │ ├── backend │ │ ├── message-handlers │ │ │ ├── handle-select-edit-format-instructions.ts │ │ │ └── index.ts │ │ └── prompt-view-provider.ts │ ├── frontend │ │ ├── Main │ │ │ ├── Main.tsx │ │ │ ├── MainView │ │ │ │ ├── MainView.tsx │ │ │ │ └── index.ts │ │ │ └── index.ts │ │ ├── Prompt.tsx │ │ └── i18n │ │ └── translations │ │ ├── actions.ts │ │ ├── configurations.ts │ │ ├── footer.ts │ │ ├── header.ts │ │ ├── home.ts │ │ ├── index.ts │ │ ├── main.ts │ │ ├── modals.ts │ │ ├── prompt-field.ts │ │ └── recent-donations.ts │ └── types │ └── messages.ts └── packages └── ui └── src └── components └── editor ├── common │ ├── Checkbox │ │ ├── Checkbox.module.scss │ │ ├── Checkbox.stories.tsx │ │ ├── Checkbox.tsx │ │ └── index.ts │ └── prompts │ └── PromptField │ ├── PromptField.module.scss │ ├── PromptField.stories.tsx │ └── PromptField.tsx └── prompt ├── Configurations │ ├── Configurations.module.scss │ ├── Configurations.stories.tsx │ ├── Configurations.tsx │ └── index.ts └── TokenCounts ├── TokenCounts.module.scss ├── TokenCounts.tsx └── index.ts
1 parent e64871a commit ab1e4fc

18 files changed

Lines changed: 469 additions & 354 deletions

File tree

‎apps/editor/src/i18n/translations/views/prompt/handlers/index.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { translations as delete_task } from './delete-task'
22
import { translations as hash_sign } from './hash-sign'
33
import { translations as make_api_call } from './make-api-call'
4-
import { translations as select_edit_format } from './select-edit-format'
4+
import { translations as select_edit_format_instructions } from './select-edit-format-instructions'
55
import { translations as voice_input } from './voice-input'
66
import { translations as copy_prompt } from './copy-prompt'
77
import { translations as handle_undo } from './handle-undo'
@@ -13,7 +13,7 @@ export const translations = {
1313
...delete_task,
1414
...hash_sign,
1515
...make_api_call,
16-
...select_edit_format,
16+
...select_edit_format_instructions,
1717
...voice_input,
1818
...copy_prompt,
1919
...handle_undo,
Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
export const translations = {
2+
'views.prompt.handlers.select-edit-format-instructions.items.whole': {
3+
en: 'Whole-File Overwrite',
4+
pl: 'Nadpisanie całego pliku',
5+
'zh-cn': '全文件覆盖',
6+
ja: 'ファイル全体の上書き',
7+
'zh-tw': '全檔案覆寫',
8+
de: 'Komplette Datei überschreiben',
9+
es: 'Sobrescribir archivo completo',
10+
fr: 'Remplacement de fichier entier',
11+
'pt-br': 'Substituição de arquivo inteiro',
12+
ru: 'Перезапись всего файла',
13+
ko: '전체 파일 덮어쓰기',
14+
it: "Sovrascrittura dell'intero file",
15+
tr: 'Tüm Dosyanın Üzerine Yaz',
16+
cs: 'Přepsání celého souboru',
17+
hu: 'Teljes fájl felülírása',
18+
bg: 'Презаписване на целия файл'
19+
},
20+
'views.prompt.handlers.select-edit-format-instructions.items.whole.description':
21+
{
22+
en: 'File contents regenerated fully',
23+
pl: 'Zawartość pliku generowana w całości',
24+
'zh-cn': '文件内容完全重新生成',
25+
ja: 'ファイル内容を完全に再生成',
26+
'zh-tw': '檔案內容完全重新生成',
27+
de: 'Dateiinhalt vollständig neu generiert',
28+
es: 'Contenido del archivo regenerado por completo',
29+
fr: 'Contenu du fichier entièrement régénéré',
30+
'pt-br': 'Conteúdo do arquivo totalmente regenerado',
31+
ru: 'Содержимое файла полностью создается заново',
32+
ko: '파일 내용이 완전히 다시 생성됨',
33+
it: 'Contenuto del file completamente rigenerato',
34+
tr: 'Dosya içeriği tamamen yeniden oluşturulur',
35+
cs: 'Obsah souboru kompletně znovu vygenerován',
36+
hu: 'Fájltartalom teljesen újragenerálva',
37+
bg: 'Съдържание на файла, напълно регенерирано'
38+
},
39+
'views.prompt.handlers.select-edit-format-instructions.items.whole.hint': {
40+
en: 'for complex edits',
41+
pl: 'dla skomplikowanych edycji',
42+
'zh-cn': '适用于复杂编辑',
43+
ja: '複雑な編集用',
44+
'zh-tw': '適用於複雜編輯',
45+
de: 'für komplexe Bearbeitungen',
46+
es: 'para ediciones complejas',
47+
fr: 'pour les modifications complexes',
48+
'pt-br': 'para edições complexas',
49+
ru: 'для сложных правок',
50+
ko: '복잡한 편집용',
51+
it: 'per modifiche complesse',
52+
tr: 'karmaşık düzenlemeler için',
53+
cs: 'pro složité úpravy',
54+
hu: 'összetett szerkesztésekhez',
55+
bg: 'за сложни редакции'
56+
},
57+
'views.prompt.handlers.select-edit-format-instructions.items.search-replace':
58+
{
59+
en: 'Search & Replace',
60+
pl: 'Wyszukaj i zamień',
61+
'zh-cn': '搜索并替换',
62+
ja: '検索して置換',
63+
'zh-tw': '搜尋並取代',
64+
de: 'Suchen & Ersetzen',
65+
es: 'Buscar y reemplazar',
66+
fr: 'Rechercher et remplacer',
67+
'pt-br': 'Buscar e Substituir',
68+
ru: 'Поиск и замена',
69+
ko: '검색 및 바꾸기',
70+
it: 'Cerca e sostituisci',
71+
tr: 'Bul ve Değiştir',
72+
cs: 'Hledat a nahradit',
73+
hu: 'Keresés és csere',
74+
bg: 'Търсене и заместване'
75+
},
76+
'views.prompt.handlers.select-edit-format-instructions.items.search-replace.description':
77+
{
78+
en: 'Snippets within <<<<<<<, =======, >>>>>>> delimiters',
79+
pl: 'Fragmenty wewnątrz ograniczników <<<<<<<, =======, >>>>>>>',
80+
'zh-cn': '<<<<<<<, =======, >>>>>>> 分隔符内的代码片段',
81+
ja: '<<<<<<<, =======, >>>>>>> 区切り文字内のスニペット',
82+
'zh-tw': '<<<<<<<, =======, >>>>>>> 分隔符號內的程式碼片段',
83+
de: 'Snippets innerhalb der Trennzeichen <<<<<<<, =======, >>>>>>>',
84+
es: 'Fragmentos dentro de delimitadores <<<<<<<, =======, >>>>>>>',
85+
fr: 'Extraits entre les délimiteurs <<<<<<<, =======, >>>>>>>',
86+
'pt-br': 'Trechos dentro dos delimitadores <<<<<<<, =======, >>>>>>>',
87+
ru: 'Фрагменты внутри разделителей <<<<<<<, =======, >>>>>>>',
88+
ko: '<<<<<<<, =======, >>>>>>> 구분 기호 내의 스니펫',
89+
it: "Frammenti all'interno dei delimitatori <<<<<<<, =======, >>>>>>>",
90+
tr: '<<<<<<<, =======, >>>>>>> sınırlayıcıları içindeki kod parçacıkları',
91+
cs: 'Úryvky uvnitř oddělovačů <<<<<<<, =======, >>>>>>>',
92+
hu: 'Kódrészletek a <<<<<<<, =======, >>>>>>> elválasztók között',
93+
bg: 'Откъси в рамките на разделителите <<<<<<<, =======, >>>>>>>'
94+
},
95+
'views.prompt.handlers.select-edit-format-instructions.items.search-replace.hint':
96+
{
97+
en: 'general purpose',
98+
pl: 'ogólnego przeznaczenia',
99+
'zh-cn': '通用',
100+
ja: '汎用',
101+
'zh-tw': '通用',
102+
de: 'Allzweck',
103+
es: 'propósito general',
104+
fr: 'usage général',
105+
'pt-br': 'uso geral',
106+
ru: 'общего назначения',
107+
ko: '다목적',
108+
it: 'uso generale',
109+
tr: 'genel amaçlı',
110+
cs: 'obecné použití',
111+
hu: 'általános célú',
112+
bg: 'общо предназначение'
113+
},
114+
'views.prompt.handlers.select-edit-format-instructions.items.diff': {
115+
en: 'Unified Diff',
116+
pl: 'Zunifikowany Diff',
117+
'zh-cn': '统一差异 (Unified Diff)',
118+
ja: 'Unified Diff',
119+
'zh-tw': '統一差異 (Unified Diff)',
120+
de: 'Unified Diff',
121+
es: 'Diff unificado',
122+
fr: 'Diff unifié',
123+
'pt-br': 'Diff Unificado',
124+
ru: 'Унифицированный Diff',
125+
ko: '통합 Diff (Unified Diff)',
126+
it: 'Diff unificato',
127+
tr: 'Birleşik Diff (Unified Diff)',
128+
cs: 'Unified Diff',
129+
hu: 'Egyesített Diff',
130+
bg: 'Обединен Diff (Unified Diff)'
131+
},
132+
'views.prompt.handlers.select-edit-format-instructions.items.diff.description':
133+
{
134+
en: 'Addition (+) and deletion (-) markers with 3 lines of context',
135+
pl: 'Znaczniki dodania (+) i usunięcia (-) z 3 liniami kontekstu',
136+
'zh-cn': '包含 3 行上下文的添加 (+) 和删除 (-) 标记',
137+
ja: '3行のコンテキストを含む追加(+)と削除(-)のマーカー',
138+
'zh-tw': '包含 3 行上下文的新增 (+) 與刪除 (-) 標記',
139+
de: 'Hinzufügungs- (+) und Löschungs- (-) Markierungen mit 3 Zeilen Kontext',
140+
es: 'Marcadores de adición (+) y eliminación (-) con 3 líneas de contexto',
141+
fr: "Marqueurs d'ajout (+) et de suppression (-) avec 3 lignes de contexte",
142+
'pt-br':
143+
'Marcadores de adição (+) e exclusão (-) com 3 linhas de contexto',
144+
ru: 'Маркеры добавления (+) и удаления (-) с 3 строками контекста',
145+
ko: '3줄의 컨텍스트가 포함된 추가(+) 및 삭제(-) 마커',
146+
it: 'Marcatori di aggiunta (+) ed eliminazione (-) con 3 righe di contesto',
147+
tr: '3 satır bağlam ile ekleme (+) ve silme (-) işaretleri',
148+
cs: 'Značky pro přidání (+) a smazání (-) se 3 řádky kontextu',
149+
hu: 'Hozzáadás (+) és törlés (-) jelölők 3 sornyi kontextussal',
150+
bg: 'Маркери за добавяне (+) и изтриване (-) с 3 реда контекст'
151+
},
152+
'views.prompt.handlers.select-edit-format-instructions.items.diff.hint': {
153+
en: 'general purpose',
154+
pl: 'ogólnego przeznaczenia',
155+
'zh-cn': '通用',
156+
ja: '汎用',
157+
'zh-tw': '通用',
158+
de: 'Allzweck',
159+
es: 'propósito general',
160+
fr: 'usage général',
161+
'pt-br': 'uso geral',
162+
ru: 'общего назначения',
163+
ko: '다목적',
164+
it: 'uso generale',
165+
tr: 'genel amaçlı',
166+
cs: 'obecné použití',
167+
hu: 'általános célú',
168+
bg: 'общо предназначение'
169+
},
170+
'views.prompt.handlers.select-edit-format-instructions.items.truncated': {
171+
en: 'Ellipsis truncations',
172+
pl: 'Skrócenie za pomocą wielokropka',
173+
'zh-cn': '省略号截断',
174+
ja: '省略記号による切り捨て',
175+
'zh-tw': '省略號截斷',
176+
de: 'Auslassungspunkte (Truncations)',
177+
es: 'Truncamiento con elipsis',
178+
fr: 'Troncature par points de suspension',
179+
'pt-br': 'Truncamento por elipse',
180+
ru: 'Усечение с многоточием',
181+
ko: '줄임표 자르기',
182+
it: 'Troncamenti con ellissi',
183+
tr: 'Üç nokta ile kesilmeler',
184+
cs: 'Zkrácení výpustkou',
185+
hu: 'Csonkítás ellipszissel',
186+
bg: 'Съкращения с многоточие'
187+
},
188+
'views.prompt.handlers.select-edit-format-instructions.items.truncated.description':
189+
{
190+
en: 'File contents with unchanged parts commented-out',
191+
pl: 'Zawartość pliku z zakomentowanymi niezmienionymi fragmentami',
192+
'zh-cn': '文件内容,未更改的部分被注释掉',
193+
ja: '変更されていない部分がコメントアウトされたファイルの内容',
194+
'zh-tw': '檔案內容,未更改的部分被註解掉',
195+
de: 'Dateiinhalt mit auskommentierten unveränderten Teilen',
196+
es: 'Contenido del archivo con las partes no modificadas comentadas',
197+
fr: 'Contenu du fichier avec les parties inchangées commentées',
198+
'pt-br': 'Conteúdo do arquivo com as partes não alteradas comentadas',
199+
ru: 'Содержимое файла, в котором неизмененные части закомментированы',
200+
ko: '변경되지 않은 부분이 주석 처리된 파일 내용',
201+
it: 'Contenuto del file con le parti non modificate commentate',
202+
tr: 'Değişmeyen kısımları yorum satırı yapılmış dosya içeriği',
203+
cs: 'Obsah souboru se zakomentovanými nezměněnými částmi',
204+
hu: 'Fájltartalom kikommentált változatlan részekkel',
205+
bg: 'Съдържание на файла с коментирани непроменени части'
206+
},
207+
'views.prompt.handlers.select-edit-format-instructions.items.truncated.hint':
208+
{
209+
en: 'handy with local models',
210+
pl: 'przydatne przy modelach lokalnych',
211+
'zh-cn': '适用于本地模型',
212+
ja: 'ローカルモデルで便利',
213+
'zh-tw': '適用於本地模型',
214+
de: 'praktisch bei lokalen Modellen',
215+
es: 'práctico con modelos locales',
216+
fr: 'pratique avec les modèles locaux',
217+
'pt-br': 'útil com modelos locais',
218+
ru: 'удобно с локальными моделями',
219+
ko: '로컬 모델에서 유용함',
220+
it: 'utile con i modelli locali',
221+
tr: 'yerel modellerle kullanışlıdır',
222+
cs: 'užitečné u lokálních modelů',
223+
hu: 'hasznos helyi modellekkel',
224+
bg: 'удобно с локални модели'
225+
},
226+
'views.prompt.handlers.select-edit-format-instructions.placeholder': {
227+
en: 'Select edit format instructions',
228+
pl: 'Wybierz instrukcje formatu edycji',
229+
'zh-cn': '选择编辑格式',
230+
ja: '編集フォーマットを選択',
231+
'zh-tw': '選擇編輯格式',
232+
de: 'Bearbeitungsformat auswählen',
233+
es: 'Seleccionar formato de edición',
234+
fr: "Sélectionner le format d'édition",
235+
'pt-br': 'Selecione o formato de edição',
236+
ru: 'Выберите формат редактирования',
237+
ko: '편집 형식 선택',
238+
it: 'Seleziona formato di modifica',
239+
tr: 'Düzenleme formatını seçin',
240+
cs: 'Vyberte formát úprav',
241+
hu: 'Szerkesztési formátum kiválasztása',
242+
bg: 'Изберете формат за редактиране'
243+
},
244+
'views.prompt.handlers.select-edit-format-instructions.title': {
245+
en: 'Edit Format Instructions',
246+
pl: 'Instrukcje formatu edycji',
247+
'zh-cn': '编辑格式',
248+
ja: '編集フォーマット',
249+
'zh-tw': '編輯格式',
250+
de: 'Bearbeitungsformate',
251+
es: 'Formatos de edición',
252+
fr: "Formats d'édition",
253+
'pt-br': 'Formatos de Edição',
254+
ru: 'Форматы редактирования',
255+
ko: '편집 형식',
256+
it: 'Formati di modifica',
257+
tr: 'Düzenleme Formatları',
258+
cs: 'Formáty úprav',
259+
hu: 'Szerkesztési formátumok',
260+
bg: 'Формати за редактиране'
261+
}
262+
} as const

0 commit comments

Comments
 (0)