Made it talk like a cat
Cats are cool, ok? People who say otherwise are just coping because their favorite animal isn't as cute.
This commit is contained in:
parent
cd7fa95690
commit
3b419a52d8
1 changed files with 48 additions and 1 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <bitset>
|
||||
|
||||
#if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))
|
||||
#include <signal.h>
|
||||
|
@ -18,6 +19,8 @@
|
|||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
using std::bitset;
|
||||
|
||||
static console_state con_st;
|
||||
|
||||
static bool is_interacting = false;
|
||||
|
@ -36,6 +39,16 @@ void sigint_handler(int signo) {
|
|||
}
|
||||
#endif
|
||||
|
||||
// convert to meownary
|
||||
std::string toMeownary(int n) {
|
||||
std::string r;
|
||||
while ( n!=0 ){
|
||||
r += ( n % 2 == 0 ? "0" : "1" );
|
||||
n /= 2;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
gpt_params params;
|
||||
params.model = "models/llama-7B/ggml-model.bin";
|
||||
|
@ -331,8 +344,42 @@ int main(int argc, char ** argv) {
|
|||
// display text
|
||||
if (!input_noecho) {
|
||||
for (auto id : embd) {
|
||||
printf("%s", llama_token_to_str(ctx, id));
|
||||
// Take llama DNA and turn a calf into a cat
|
||||
std::string mewken = llama_token_to_str(ctx, id);
|
||||
|
||||
// Cat hasn't learned to speak yet
|
||||
std::string meow = "";
|
||||
|
||||
// For each word the cat thinks of, create a kitten
|
||||
for (int i = 0; i < mewken.length(); ++i) {
|
||||
// Create a cute kitten from a string
|
||||
std::string kitten = toMeownary(mewken[i]);
|
||||
|
||||
// Confuse the kitten and make it chase its tail
|
||||
reverse(kitten.begin(), kitten.end());
|
||||
|
||||
// If the kitten is too small, we need to feed it
|
||||
if (kitten.length() < 8)
|
||||
kitten.insert(kitten.front() == '-' ? 1 : 0, 8 - kitten.length(), '0');
|
||||
|
||||
// Take the kitten to school
|
||||
std::string educated_kitten = "";
|
||||
for (int i = 0; i < kitten.length(); i++) {
|
||||
if (kitten[i] == '0') {
|
||||
printf(" meow");
|
||||
}
|
||||
if (kitten[i] == '1') {
|
||||
printf(" purr");;
|
||||
}
|
||||
}
|
||||
|
||||
// Once the kitten has graduated school,
|
||||
// We can put it up for adoption
|
||||
// And also teach it how to speak cat
|
||||
printf("%s~!", educated_kitten);
|
||||
}
|
||||
}
|
||||
// Make the cat's speech audible to humans
|
||||
fflush(stdout);
|
||||
}
|
||||
// reset color to default if we there is no pending user input
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue