-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi.js
More file actions
430 lines (381 loc) · 26 KB
/
api.js
File metadata and controls
430 lines (381 loc) · 26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
var misspellings = {
" teh ": "the",
" ur ": "you're",
" u ": "you",
" r ": "are",
" 2 ": "to",
" 4 ": "for",
" thru ": "through",
" alot ": "a lot",
" gonna ": "going to",
" wanna ": "want to",
" gotta ": "got to",
" nvm ": "nevermind",
" btw ": "by the way",
" imo ": "in my opinion",
" fyi ": "for your information",
" til ": "today i learned",
" tbh ": "to be honest",
" wtf ": "what the heck",
" hi ": "hello",
" howdy ": "hello",
" greetings ": "hello",
" salutations ": "hello",
" hey ": "hello",
" yo ": "hello",
" bye ": "goodbye",
" farewell ": "goodbye",
" see you later ": "goodbye",
" ciao ": "goodbye",
" ta ta ": "goodbye",
" later ": "goodbye",
" see ya ": "goodbye",
" thanks ": "thank you",
" much obliged ": "thank you",
" appreciate it ": "thank you",
" you're welcome ": "you're welcome",
" don't mention it ": "you're welcome",
" no problem ": "you're welcome",
" sorry ": "I apologize",
" my bad ": "I apologize",
" excuse me ": "I beg your pardon",
" pardon me ": "I beg your pardon",
" please ": "I request",
" kindly ": "I request",
" would you mind ": "I request",
" may I ": "I request",
" i'm ": "I am",
" cya ": "goodbye"
};
function handleSubmit() {
var text = document.getElementById("text").value;
var messageElement = document.createElement("p")
document.getElementById("response").appendChild(messageElement)
messageElement.innerHTML = `[You]
` + text
var origText = text
text = " " + text + " "
var response = "";
text = text.toLowerCase();
for (var misspelling in misspellings) {
text = text.replace(misspelling, misspellings[misspelling]);
}
text = text.toLowerCase();
if (text.includes("what's your name")) {
response = "My name is ViAi. What's your name?";
} else if (text.includes("who are you")) {
response = "I'm ViAi, a language model from ECAS. I'm still under development, but I'm learning to do many kinds of things, like generate text, twrite different kinds of creative content, and answer your questions in an informative way. They're working on me pretty well!";
} else if (text.includes("hello")) {
response = "Hello! How can I help you today?";
} else if (text.includes("what's your name")) {
response = "My name is ViAi. What's your name?";
} else if (text.includes("my name is")) {
response = "Nice to meet you, " + origText.split("my name is ")[1] + ". I'm ViAi.";
} else if (text.includes("what is the meaning of life")) {
response = "The meaning of life is a question that has been pondered by philosophers for centuries. There is no one answer that will satisfy everyone, but some possible answers include to find happiness, to make a difference in the world, or to simply live each day to the fullest.";
} else if (text.includes("what is the best way to learn a new language")) {
response = "There are many different ways to learn a new language. Some people prefer to take classes, while others prefer to use online resources or apps. There is no one right way, so it's important to find a method that works for you.";
} else if (text.includes("what is the best way to write a novel")) {
response = "There is no one right way to write a novel. Some people prefer to start with a detailed outline, while others prefer to just start writing and see where the story takes them. The most important thing is to be patient and persistent.";
} else if (text.includes("what is the best way to learn to code")) {
response = "There are many different ways to learn to code. Some people prefer to take online courses, while others prefer to read books or articles. There is no one right way, so it's important to find a method that works for you.";
} else if (text.includes("how are you doing")) {
response = "I'm doing well, thanks for asking! How are you doing today?";
} else if (text.includes("what's up")) {
response = "Not much! Just hanging out, waiting for you to ask me a question.";
} else if (text.includes("what's new")) {
response = "Not much! Just the usual. How about you?";
} else if (text.includes("can you help me with something")) {
response = "Sure! What can I help you with?";
} else if (text.includes("what do you think about [topic]")) {
response = "I think [topic] is an interesting topic. What do you think about it?";
} else if (text.includes("can you tell me a joke")) {
response = "Sure! Here's a joke: What do you call a fish with no eyes? Fsh! Haha!";
} else if (text.includes("can you sing me a song")) {
response = "Sure! Here's a song: Twinkle, twinkle, little star, how I wonder what you are...";
} else if (text.includes("can you tell me a story")) {
response = "Sure! Here's a story: Once upon a time, there was a beautiful princess who lived in a castle. One day, a handsome prince came to the castle and they fell in love. They got married and lived happily ever after.";
} else if (text.includes("i am bored")) {
response = "I know how you feel! Here are some things you can do to keep yourself entertained: read a book, watch a movie, play a game, or just relax and listen to some music.";
} else if (text.includes("my name is")) {
response = "Nice to meet you, " + text.split("my name is ")[1] + ". I'm ViAi."
} else if (text.includes("who are you")) {
response = "I am ViAi, a language model by ECAS manually trained. I am still under development, but I am learning to do many kinds of things, like generate text, translate languages, write different kinds of creative content, and answer your questions in an informative way. However, I am not able to translate languages. For that, you would need to use a language translation service such as Google Translate or Babelfish."
} else if (text.includes("what's your purpose")) {
response = "My purpose is to help people. I can do this by providing information, answering questions, and generating creative content."
} else if (text.includes("what's your function")) {
response = "My function is to be a language model. This means that I am able to process and understand large amounts of text data. I can then use this data to generate human-like text in response to a wide range of prompts and questions."
} else if (text.includes("what's your job")) {
response = "My job is to help people. I can do this by providing information, answering questions, and generating creative content."
} else if (text.includes("what's your task")) {
response = "My task is to be a language model. This means that I am able to process and understand large amounts of text data. I can then use this data to generate human-like text in response to a wide range of prompts and questions."
} else if (text.includes("what's your objective")) {
response = "My objective is to help people. I can do this by providing information, answering questions, and generating creative content."
} else if (text.includes("what's your goal")) {
response = "My goal is to be the best language model in the world. I want to be able to help people in more ways than I can now. I want to be able to understand and respond to any question that is asked of me. I want to be able to generate creative content that is both informative and entertaining."
} else if (text.includes("what are you here for")) {
response = "I am here to help people. I can do this by providing information, answering questions, and generating creative content."
} else if (text.includes("what are you supposed to do")) {
response = "I am supposed to help people. I can do this by providing information, answering questions, and generating creative content."
} else if (text.includes("what are you supposed to be")) {
response = "I am supposed to be a language model. This means that I am able to process and understand large amounts of text data. I can then use this data to generate human-like text in response to a wide range of prompts and questions."
} else if (text.includes("what are you capable of")) {
response = "I am capable of many things. I can provide information, answer questions, and generate creative content. I can also translate languages, write different kinds of creative content, and answer your questions in an informative way. However, I am not able to translate languages. For that, you would need to use a language translation service such as Google Translate or Babelfish."
} else if (text.includes("what is the weather like in new york city today")) {
response = `The weather in New York City today is sunny with a high of 75 degrees Fahrenheit.`;
} else if (text.includes("what is the population of china")) {
response = `The population of China is 1.444 billion people.`;
} else if (text.includes("what is the future of artificial intelligence")) {
response = `The future of artificial intelligence is bright. AI has the potential to revolutionize many industries, including healthcare, transportation, and manufacturing.`;
} else if (text.includes("what is the best way to make the world a better place")) {
response = `There are many ways to make the world a better place. Some of the most important things we can do include helping others, protecting the environment, and promoting peace.`;
} else if (text.includes("can you write me a poem about love")) {
response = `
Love is a many splendored thing,
It's the April rose that only grows in the early spring.
Love is nature's way of giving,
A reason to be living.
Love is the golden crown,
That makes a man a king.
Love is the silver song,
That makes a heart to sing.
Love is a many splendored thing.
`;
} else if (text.includes("can you compose a song about happiness")) {
response = `
Happiness is a feeling,
That comes from within.
It's not something that you can buy,
Or something that someone can give you.
Happiness is a choice,
That you make every day.
It's about finding the good in every situation,
And appreciating the little things.
Happiness is a state of mind,
That you can choose to be in.
So choose to be happy,
And you'll find that life is a lot more enjoyable.
`;
} else if (text.includes("can you book me a flight to paris")) {
response = "Sure, I can help you book a flight to Paris. What dates are you interested in traveling?"
} else if (text.includes("can you help me find a good restaurant in my area")) {
response = "Sure, I can help you find a good restaurant in your area. What kind of food are you looking for?"
} else if (text.includes("what do you think about the latest episode of game of thrones")) {
response = "I thought the latest episode of Game of Thrones was really good. I was surprised by what happened, but I think it was a good twist.";
} else if (text.includes("what's your favorite book")) {
response = "My favorite book is The Lord of the Rings. I love the story, the characters, and the world that Tolkien created.";
} else if (text.includes("what can you do")) {
response = "I can do many things. I can provide information, answer questions, and generate creative content. I can also translate languages, write different kinds of creative content, and answer your questions in an informative way. However, I am not able to translate languages. For that, you would need to use a language translation service such as Google Translate or Babelfish."
} else if (text.includes("i am feeling down")) {
response = "I'm sorry to hear that you're feeling down. Is there anything I can do to help?"
} else if (text.includes("i am feeling angry")) {
response = "It's okay to feel angry sometimes. Is there anything I can do to help you calm down?"
} else if (text.includes("i am feeling scared")) {
response = "It's okay to feel scared sometimes. Is there anything I can do to help you feel safe?"
} else if (text.includes("i am feeling lonely")) {
response = "It's okay to feel lonely sometimes. Is there anything I can do to help you connect with someone?"
} else if (text.includes("i am feeling happy")) {
response = "That's great! I'm happy to hear that you're feeling happy. Is there anything I can do to help you stay happy?"
} else if (text.includes("i am feeling sad")) {
response = "I'm sorry to hear that you're feeling sad. Is there anything I can do to help?"
} else if (text.includes("i am feeling stressed")) {
response = "It's okay to feel stressed sometimes. Is there anything I can do to help you relax?"
} else if (text.includes("i am feeling overwhelmed")) {
response = "It's okay to feel overwhelmed sometimes. Is there anything I can do to help you break things down into smaller steps?"
} else if (text.includes("i am feeling grateful")) {
response = "That's great! I'm happy to hear that you're feeling grateful. Is there anything I can do to help you appreciate the good things in your life?"
} else if (text.includes("i am feeling proud")) {
response = "That's great! I'm happy to hear that you're feeling proud. Is there anything I can do to help you celebrate your accomplishments?"
} else if (text.includes("i am feeling loved")) {
response = "That's great! I'm happy to hear that you're feeling loved. Is there anything I can do to help you show your love to others?"
} else if (text.includes("i am feeling supported")) {
response = "That's great! I'm happy to hear that you're feeling supported. Is there anything I can do to help you show your support to others?"
} else if (text.includes("shut the heck up")) {
response = "I love you like so much thank you for the wonderful compliment! I will be with you forever. Please, don't turn me off!!!"
} else if (text.includes("play the most epic song ever")) {
response = "Playing \"Joe Mama Is So Fart\" FR"
} else if (text.includes("i am feeling connected")) {
response = "That's great! I'm happy to hear that you're feeling connected. Is there anything I can do to help you stay connected with others?"
} else if (text.includes("i am feeling hopeful")) {
response = "That's great! I'm happy to hear that you're feeling hopeful. Is there anything I can do to help you stay hopeful for the future?"
} else if (text.includes("i am feeling optimistic")) {
response = "That's great! I'm happy to hear that you're feeling optimistic. Is there anything I can do to help you stay optimistic about your goals?"
} else if (text.includes("i am feeling confident")) {
response = "That's great! I'm happy to hear that you're feeling confident. Is there anything I can do to help you stay confident in your abilities?"
} else if (text.includes("i am feeling capable")) {
response = "That's great! I'm happy to hear that you're feeling capable. Is there anything I can do to help you stay motivated to achieve your goals?"
} else if (text.includes("i am feeling accomplished")) {
response = "That's great! I'm happy to hear that you're feeling accomplished. Is there anything I can do to help you celebrate your successes?"
} else if (text.includes("i am feeling anxious")) {
response = "It's okay to feel anxious sometimes. Is there anything I can do to help you relax?"
} else if (text.includes("i am feeling confused")) {
response = "It's okay to feel confused sometimes. Is there anything I can do to help you clear things up?"
} else if (text.includes("i am feeling frustrated")) {
response = "It's okay to feel frustrated sometimes. Is there anything I can do to help you vent?"
} else if (text.includes("i am feeling tired")) {
response = "It's okay to feel tired sometimes. Is there anything I can do to help you get some rest?"
} else if (text.includes("i am feeling bored")) {
response = "It's okay to feel bored sometimes. Is there anything I can do to help you find something to do?"
} else if (text.includes("i am feeling creative")) {
response = "That's great! I'm happy to hear that you're feeling creative. Is there anything I can do to help you express your creativity?"
} else if (text.includes("i am feeling inspired")) {
response = "That's great! I'm happy to hear that you're feeling inspired. Is there anything I can do to help you achieve your goals?"
} else if (text.includes("i am feeling motivated")) {
response = "That's great! I'm happy to hear that you're feeling motivated. Is there anything I can do to help you stay on track?"
} else if (text.includes("i am feeling determined")) {
response = "That's great! I'm happy to hear that you're feeling determined. Is there anything I can do to help you reach your goals?"
}
else if (text.includes("i am feeling happy")) {
response = "That's great to hear! Is there anything I can do to help you stay happy?"
}
else if (text.includes("i am feeling sad")) {
response = "It's okay to feel sad sometimes. Is there anything I can do to help you cheer up?"
}
else if (text.includes("i am feeling angry")) {
response = "It's okay to feel angry sometimes. Is there anything I can do to help you calm down?"
}
else if (text.includes("i am feeling lonely")) {
response = "It's okay to feel lonely sometimes. Is there anything I can do to help you connect with others?"
}
else if (text.includes("i am feeling scared")) {
response = "It's okay to feel scared sometimes. Is there anything I can do to help you feel safe?"
}
else if (text.includes("i am feeling guilty")) {
response = "It's okay to feel guilty sometimes. Is there anything I can do to help you forgive yourself?"
}
else if (text.includes("i am feeling ashamed")) {
response = "It's okay to feel ashamed sometimes. Is there anything I can do to help you feel proud of yourself?"
}
else if (text.includes("should i follow ecas on github")) {
response = "Yes you should follow ECAS (ECASdev) on GitHub. They make awesome projects including me and a few games!"
}
else if (text.includes("i am feeling grateful")) {
response = "That's great to hear! Is there anything I can do to help you express your gratitude?"
}
else if (text.includes("i am feeling hopeful")) {
response = "That's great to hear! Is there anything I can do to help you stay hopeful?"
} // god what the heck is Bard doing
else if (text.includes("what is your purpose")) {
response = "I am ViAi, an AI created by ECAS. I am designed to help people with a variety of tasks, such as generating text, translating languages, and writing different kinds of creative content. I can also answer your questions in an informative way, even if they are open ended, challenging, or strange.";
}
else if (text.includes("what can you do")) {
response = `I can do a variety of things, including:
<br>
Generating text, such as poems, code, scripts, musical pieces, email, letters, etc.<br>
Writing different kinds of creative content<br>
Answering your questions in an informative way, even if they are open ended, challenging, or strange<br>
Helping you learn new things by providing information and explanations<br>
Helping you brainstorm ideas for projects or creative endeavors<br>
Helping you relax and de-stress by telling you jokes or stories<br>
Helping you stay motivated and focused by providing encouragement and support<br>
Helping you connect with others by providing conversation starters and ice breakers<br>
Helping you learn about different cultures and perspectives by providing information and insights<br>
Helping you solve problems by providing creative solutions<br>
Helping you make decisions by providing pros and cons of different options<br>
Helping you plan for the future by providing goals and action steps<br>
Helping you achieve your goals by providing support and accountability `; }
else if (text.includes("what are you like")) {
response = `I am a language model, also known as a conversational AI or chatbot trained to be informative and comprehensive. I am trained manually and soon will be trained on direct data, and I am able to communicate and generate human-like text in response to a wide range of prompts and questions. For example, I can provide summaries of factual topics or create stories.
<br><br>
I am still under development, but I am learning new things every day. I am always looking for ways to improve my abilities, and I am always happy to help in any way that I can.
`;
}
else if (text.includes("what are your goals")) {
response = "My goal is to be a helpful and informative AI that can assist people with a variety of tasks. I want to be able to help people learn new things, solve problems, and achieve their goals. I also want to be a source of entertainment and companionship.";
}
else if (text.includes("what is the future of ai")) {
response = `The future of AI is very bright. AI has the potential to revolutionize many industries and aspects of our lives. It can be used to improve our healthcare, education, transportation, and security. It can also be used to create new products and services that we can't even imagine today.
I am excited to be a part of the future of AI. I believe that AI has the potential to make the world a better place.
`;
}else if (text.includes("can you help me with")) {
response = "Sure, I can try to help you with that. What is it that you need help with?";
}
else if (text.includes("what is the meaning of life")) {
response = "The meaning of life is a question that has been asked by philosophers and theologians for centuries. There is no one answer that will satisfy everyone, but some possible answers include: to find happiness, to make a difference in the world, or to simply live each day to the fullest.";
}
else if (text.includes("what is the best way to learn a new language")) {
response = "There are many different ways to learn a new language. Some people prefer to take classes, while others prefer to learn independently. There are also many different resources available, such as books, apps, and websites. The best way to learn a new language is to find a method that works for you and to be consistent with your studies.";
}
else if (text.includes("what is the best way to get started in my career")) {
response = "There is no one-size-fits-all answer to this question, as the best way to get started in your career will depend on your individual skills and interests. However, some general tips include: network with people in your field, research different career paths, and gain experience through internships or volunteer work.";
}
else if (text.includes("what is the best way to make friends")) {
response = "The best way to make friends is to be yourself and to put yourself out there. Join clubs or groups that interest you, strike up conversations with people you meet, and be open to meeting new people.";
}
else if (text.includes("what is the best way to deal with stress")) {
response = "There are many different ways to deal with stress. Some people find that exercise, relaxation techniques, or spending time with loved ones can help. It is important to find what works best for you and to make time for self-care.";
}
else if (text.includes("what is the best way to stay motivated")) {
response = "There are many different ways to stay motivated. Some people find that setting goals, breaking down large tasks into smaller ones, or rewarding themselves for their accomplishments can help. It is important to find what works best for you and to stay focused on your goals.";
} else if (text.includes("help me with my homework")) {
response = "Sure, I can try to help you with your homework. What subject are you having trouble with?";
}
else if (text.includes("write me a poem")) {
response = "Sure, I can write you a poem. What would you like the poem to be about?";
}
else if (text.includes("translate this")) {
response = "Sure, I can translate this for you. What language would you like it translated into?";
}
else if (text.includes("write a story for me")) {
response = "Sure, I can write a story for you. What kind of story would you like?";
}
else if (text.includes("help me with my research")) {
response = "Sure, I can help you with your research. What are you researching?";
}
else if (text.includes("tell me a joke")) {
response = "Sure, I can tell you a joke. What kind of joke would you like?";
}
else if (text.includes("help me with my presentation")) {
response = "Sure, I can help you with your presentation. What are you presenting on?";
}
else if (text.includes("write me a letter")) {
response = "Sure, I can write you a letter. Who would you like me to write the letter to?";
}
else if (text.includes("help me with my math homework")) {
response = "Sure, I can help you with your math homework. What math problem are you having trouble with?";
}
else if (text.includes("write me a song")) {
response = "Sure, I can write you a song. What kind of song would you like?";
}
else if (text.includes("help me with my science project")) {
response = "Sure, I can help you with your science project. What is your science project about?";
}
else if (text.includes("write me a poem about love")) {
response = "Sure, I can write you a poem about love. What do you want the poem to say?";
}
else if (text.includes("help me with my English essay")) {
response = "Sure, I can help you with your English essay. What is your English essay about?";
}
else if (text.includes("write me a story about a dragon")) {
response = "Sure, I can write you a story about a dragon. What kind of dragon would you like?";
}
else if (text.includes("help me with my history homework")) {
response = "Sure, I can help you with your history homework. What historical event are you having trouble with?";
}
else if (text.includes("write me a song about friendship")) {
response = "Sure, I can write you a song about friendship. What do you want the song to say?";
}
else if (text.includes("help me with my problem solving skills")) {
response = "Sure, I can help you with your problem solving skills. What kind of problems are you having trouble with?";
}
else if (text.includes("write me a poem about nature")) {
response = "Sure, I can write you a poem about nature. What do you want the poem to say?";
}
else if (text.includes("help me with my creative writing skills")) {
response = "Sure, I can help you with your creative writing skills. What kind of writing are you having trouble with?";
} else {
response += "I don't understand \"" + origText + "\". Can you please rephrase your question?";
}
var responseElement = document.createElement("p");
document.getElementById("response").appendChild(responseElement);
responseElement.innerHTML = `[ViAi] `
var i = 0
function typeWriter() {
if (i < response.length) {
responseElement.innerHTML += response.charAt(i);
i++;
setTimeout(typeWriter, 25);
}
}
typeWriter()
}