Skip to content

Commit f2cc894

Browse files
committed
Merge branch 'main' of https://github.com/mmartin4972/Langkit into main
2 parents edb91db + 6c03130 commit f2cc894

File tree

3 files changed

+56
-135
lines changed

3 files changed

+56
-135
lines changed

client/src/App.js

Lines changed: 27 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -19,125 +19,28 @@ class App extends Component {
1919
},
2020
{
2121
id: 1,
22-
name: 'Fruit',
23-
sourceLang: 'ES',
24-
targetLang: 'EN',
25-
list: [
26-
{
27-
id: 0,
28-
source: 'Manzana',
29-
translation: 'Apple',
30-
sHidden: false,
31-
tHidden: false,
32-
},
33-
{
34-
id: 1,
35-
source: 'Naranja',
36-
translation: 'Orange',
37-
sHidden: false,
38-
tHidden: false,
39-
},
40-
{
41-
id: 2,
42-
source: 'Platana',
43-
translation: 'Banana',
44-
sHidden: false,
45-
tHidden: false,
46-
}
47-
]
48-
},
49-
{
50-
id: 2,
51-
name: 'Fruit but Blue',
52-
sourceLang: 'ES',
53-
targetLang: 'EN',
54-
list: [
55-
{
56-
id: 0,
57-
source: 'Manzana pero azul',
58-
translation: 'Apple but blue',
59-
sHidden: false,
60-
tHidden: false,
61-
},
62-
{
63-
id: 1,
64-
source: 'Naranja pero azul',
65-
translation: 'Orange but blue',
66-
sHidden: false,
67-
tHidden: false,
68-
},
69-
{
70-
id: 2,
71-
source: 'Platana pero azul',
72-
translation: 'Banana but blue',
73-
sHidden: false,
74-
tHidden: false,
75-
}
76-
]
77-
},
78-
{
79-
id: 3,
80-
name: 'Fruit but bluer',
81-
sourceLang: 'ES',
82-
targetLang: 'EN',
83-
list: [
84-
{
85-
id: 0,
86-
source: 'Manzana pero azul',
87-
translation: 'Apple but blue',
88-
sHidden: false,
89-
tHidden: false,
90-
},
91-
{
92-
id: 1,
93-
source: 'Naranja pero azul',
94-
translation: 'Orange but blue',
95-
sHidden: false,
96-
tHidden: false,
97-
},
98-
{
99-
id: 2,
100-
source: 'Platana pero azul',
101-
translation: 'Banana but blue',
102-
sHidden: false,
103-
tHidden: false,
104-
}
105-
]
22+
name: 'New Topic',
23+
sourceLang: 'en',
24+
targetLang: 'es',
25+
list: []
10626
}
10727
],
108-
cmd_window_pairs: [
109-
{'source': 'Word One', 'translation': 'Word One'},
110-
{'source': 'Word One', 'translation': 'Word One'},
111-
{'source': 'Word One', 'translation': 'Word One'},
112-
{'source': 'Word One', 'translation': 'Word One'},
113-
{'source': 'Word One', 'translation': 'Word One'},
114-
{'source': 'Word One', 'translation': 'Word One'},
115-
{'source': 'Word One', 'translation': 'Word One'},
116-
{'source': 'Word One', 'translation': 'Word One'},
117-
{'source': 'Togepi is in front of me and looks nice', 'translation': 'Togepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira bueno'},
118-
{'source': 'Togepi is in front of me and looks nice', 'translation': 'Togepi es en el frentTogepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira buenoe de yo, y mira buenoTogepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira bueno'},
119-
{'source': 'Togepi is in front of me and looks nice', 'translation': 'Togepi es en el Togepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira buenoTogepi es en el frente de yo, y mira buenofrente de yo, y mira bueno'},
120-
{'source': 'Togepi is in front of me and looks nice', 'translation': 'Togepi es en el frente de yo, y mira bueno'},
121-
{'source': 'Togepi is in front of me and looks nice', 'translation': 'Togepi es en el frente de yo, y mira bueno'},
122-
{'source': 'Togepi is in front of me and looks nice', 'translation': 'Togepi es en el frente de yo, y mira bueno'},
123-
{'source': 'Togepi is in front of me and looks nice', 'translation': 'Togepi es en el frente de yo, y mira bueno'},
124-
{'source': 'Togepi is in front of me and looks nice', 'translation': 'Togepi es en el frente de yo, y mira bueno'},
125-
{'source': 'Togepi is in front of me and looks nice', 'translation': 'Togepi es en el frente de yo, y mira bueno'},
126-
{'source': 'Togepi is in front of me and looks nice', 'translation': 'Togepi es en el frente de yo, y mira bueno'},
127-
{'source': 'Togepi is in front of me and looks nice', 'translation': 'Togepi es en el frente de yo, y mira bueno'}
128-
],
28+
cmd_window_pairs: [],
12929
selectedTopic: 1
13030
};
13131
}
13232

13333
submitPrompt = async () => {
134-
const sourceLang = document.getElementById('source-selector').innerHTML;
135-
const targetLang = document.getElementById('target-selector').innerHTML;
34+
var sourceLang = document.getElementById('source-selector').innerHTML;
35+
var targetLang = document.getElementById('target-selector').innerHTML;
36+
var prompt = document.getElementById('prompt-input').value;
37+
38+
13639
const requestOptions = {
13740
method: 'POST',
13841
headers: { 'Content-Type': 'application/json', 'Accept':'application/json' },
13942
body: JSON.stringify([{
140-
cmd: 'Generate me phrases about a dinner party',
43+
cmd: prompt,
14144
from: sourceLang,
14245
to: targetLang
14346
}])
@@ -147,11 +50,22 @@ class App extends Component {
14750
.then(response => {console.log(response); return response.json();})
14851
.then(res => {
14952
console.log(res);
150-
/*
151-
let a = Array.from(res);
152-
for (let i = 0; i < a.length; i++) {
153-
console.log(a[i]);
154-
}*/
53+
54+
var array = [...this.state.cmd_window_pairs]
55+
56+
while (array.length > 0) {
57+
array.pop();
58+
}
59+
60+
for (let i = 0; i < res.length; i++) {
61+
array.push({
62+
id: i,
63+
source: res[i].source,
64+
translation: res[i].translation
65+
});
66+
}
67+
68+
this.setState({cmd_window_pairs: array});
15569
})
15670
.catch(error => console.log(error));
15771
}
@@ -275,7 +189,6 @@ class App extends Component {
275189
this.setState({topics: newList});
276190
}
277191

278-
279192
render() {
280193
console.log(this.state.topics);
281194
return (

client/src/components/CommandWindow.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ function CommandWindow (props) {
2828
<button onClick={() => setSourceSelectorValue('bn')}>bn</button>
2929
<button onClick={() => setSourceSelectorValue('pt')}>pt</button>
3030
<button onClick={() => setSourceSelectorValue('id')}>id</button>
31+
<button onClick={() => setSourceSelectorValue('ur')}>ur</button>
32+
<button onClick={() => setSourceSelectorValue('ja')}>ja</button>
33+
<button onClick={() => setSourceSelectorValue('de')}>de</button>
34+
<button onClick={() => setSourceSelectorValue('te')}>te</button>
3135
</div>
3236
</div>
3337
<div className='language-selector' id='right'>
@@ -43,6 +47,10 @@ function CommandWindow (props) {
4347
<button onClick={() => setTargetSelectorValue('bn')}>bn</button>
4448
<button onClick={() => setTargetSelectorValue('pt')}>pt</button>
4549
<button onClick={() => setTargetSelectorValue('id')}>id</button>
50+
<button onClick={() => setTargetSelectorValue('ur')}>ur</button>
51+
<button onClick={() => setTargetSelectorValue('js')}>js</button>
52+
<button onClick={() => setTargetSelectorValue('de')}>de</button>
53+
<button onClick={() => setTargetSelectorValue('te')}>te</button>
4654
</div>
4755
</div>
4856
</div>

server/main.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,28 +135,28 @@ def prompt_engineer (topic: str, ty: str):
135135

136136

137137
def get_choices (s: str):
138-
s = s.strip()
139-
clean_s = ""
140-
for c in s:
141-
if c.isalpha() or c == "," or c == " " :
142-
clean_s += c
143-
return clean_s.split(', ')
144-
145-
# extracted = []
146-
# buildastring = ''
147-
# read_mode = False
138+
# s = s.strip()
139+
# clean_s = ""
148140
# for c in s:
149-
# if read_mode:
150-
# if c == '\n':
151-
# read_mode = False
152-
# extracted.append(buildastring)
153-
# buildastring = ''
154-
# continue
155-
# buildastring += c
156-
# elif c == ' ':
157-
# read_mode = True
158-
159-
# return extracted
141+
# if c.isalpha() or c == "," or c == " " :
142+
# clean_s += c
143+
# return clean_s.split(', ')
144+
145+
extracted = []
146+
buildastring = ''
147+
read_mode = False
148+
for c in s:
149+
if read_mode:
150+
if c == '\n':
151+
read_mode = False
152+
extracted.append(buildastring)
153+
buildastring = ''
154+
continue
155+
buildastring += c
156+
elif c == ' ':
157+
read_mode = True
158+
159+
return extracted
160160

161161

162162
openai.api_key = os.getenv("OPENAI_KEY")

0 commit comments

Comments
 (0)