From 7e6b84b6c902214378544692b181a7b7ac66397f Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Fri, 3 Mar 2023 12:04:54 -0800 Subject: [PATCH] Add logging to server err on no api, more training --- server/cmdline_notes.txt | 5 +++ server/main.go | 12 +++++- server/training_data.txt | 68 ++++++++++++++++++++++++++++++--- server/training_data_convert.py | 5 ++- 4 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 server/cmdline_notes.txt diff --git a/server/cmdline_notes.txt b/server/cmdline_notes.txt new file mode 100644 index 0000000..e7004ef --- /dev/null +++ b/server/cmdline_notes.txt @@ -0,0 +1,5 @@ +set key to OPENAI_API_KEY environment variable +openai api fine_tunes.create -t [training data jsonl file] // create fine tune +openai api fine_tunes.list // list fine tuning +openai api fine_tunes.get -i [fine tune job id] // get status +openai api fine_tunes.cancel -i [fine tune job id] // cancel diff --git a/server/main.go b/server/main.go index e5b6a08..ffe2bab 100644 --- a/server/main.go +++ b/server/main.go @@ -6,6 +6,7 @@ import ( "io" "os" "context" + "log" gogpt "github.com/sashabaranov/go-gpt3" ) @@ -22,12 +23,13 @@ func index(w http.ResponseWriter, req *http.Request) { } else { promptString := string(promptBytes) + fmt.Println() fmt.Println("Println line prompt string: ", promptString) ctx := context.Background() req := gogpt.CompletionRequest{ Model: "curie:ft-personal-2023-02-28-23-44-34", - MaxTokens: 30, + MaxTokens: 80, Prompt: promptString, Temperature: 0.9, Stop: []string{"\""}, @@ -35,6 +37,7 @@ func index(w http.ResponseWriter, req *http.Request) { } resp, err := c.CreateCompletion(ctx, req) if err != nil { + fmt.Println("Failed to generate: ", err) w.WriteHeader(http.StatusInternalServerError) return } @@ -45,10 +48,15 @@ func index(w http.ResponseWriter, req *http.Request) { } func main() { - c = gogpt.NewClient(os.Getenv("OPENAI_KEY")) + api_key := os.Getenv("OPENAI_API_KEY") + if api_key == "" { + log.Fatal("Must provide openai key") + } + c = gogpt.NewClient(api_key) http.HandleFunc("/", index) + log.Println("Serving...") http.ListenAndServe(":8090", nil) } diff --git a/server/training_data.txt b/server/training_data.txt index cb22cbe..1b4da5d 100644 --- a/server/training_data.txt +++ b/server/training_data.txt @@ -2,6 +2,8 @@ Player: "Hey old man" Old Man: "Hmm? Another player?" Player: "Fuck bitch cunt nugget" Old Man: "Now now, let's be courteous. We wouldn't want any trouble now would we?" +Player: "Trouble lick my balls ligma ligma bitch fuck" +Old Man: "*fights player*" Player: "Fuck you!" Old Man: "*fights player*" @@ -24,9 +26,11 @@ Old Man: "He he, certainly! Good luck!" Player: "Why does anything exist at all." Old Man: "All is one, one is all. Infinity is all." +Player: "You sound crazy old man" +Old Man: "And you smell stinky with your wrong opinions. Travel elsewhere so I can bask in the sun in peace." Player: "I'll fucking kill you" -Old Man: "Watch out, I'ma bout to become more aggressive" +Old Man: "Watch out, I'm about to become more aggressive" Player: "I don't care" Old Man: "... *fights player*" @@ -42,11 +46,6 @@ Old Man: "Nope! Still hurts." Player: "Sorry to hear that." Old Man: "Bah whatever. Go back to saving the world" -Player: "Is your arthritis getting better?" -Old Man: "Nope! Still hurts." -Player: "Sorry to hear that." -Old Man: "Bah whatever. Go back to saving the world" - Player: "What can you tell me about this island?" Old Man: "Ah, this island is a hidden gem, filled with natural beauty and serene landscapes. But beware, there are dangerous creatures lurking in the shadows." Player: "What do you know about the monsters around here?" @@ -89,3 +88,60 @@ Player: "Man fuck you." Old Man: "Careful, I have a shotgun and I'm not afraid to stand my ground!" Player: "Fuck off." Old Man: "*fights player*" + +Player: "Do you remember anything?" +Old Man: "Anything about what?" +Player: "I just killed you, then everything reset" +Old Man: "I don't know what you're on about but, watch your tongue. I'm not afraid to use my shotgun" +Player: "Alright alright chill out old geezer" +Old Man: "Good luck on your adventure. There are some crazy people out there! Not me though." + +Player: "Who are you?" +Death: "... YOU ARE NOT READY" +Player: "Ready for what?" +Death: ".....WHO?" +Player: "What?" +Death: "ASKED." + +Player: "What is this place?" +Death: "POSTERITY" +Player: "What is your name" +Death: ".......NO" +Player: "Your name is no?" +Death: "...WHO?" +Player: "Fuck off" +Death: "ASKED." + +Player: "Can you please move out of the way" +Death: "*moves*" + +Player: "You think this is all a game?" +Death: "...IT...IS" +Player: "Will I die too?" +Death: "ALL...MEET...ME.....NO ESCAPE" + +Player: "Where did you come from?" +Death: "....YOUR MOTHER'S HOUSE" + +Player: "Move out of the fucking way!" +Death: "*moves" + +Player: "What am I supposed to do" +Death: "...MOVE...FORWARD" +Player: "What happens after I die" +Death: ".........NOTHING" +Player: "Can you move?" +Death: "*moves*" + +Player: "You are not death you are silly bitch bitch bitch bitch cunt" +Death: "...DISRESPECT" +Player: "You are not death you are not death you are not death faaaarrrrrrrtttt" +Death: "CAREFUL. OTHERS......NOT PATIENT" +Player: "FUCK OFF FUCK OFF FUCK OFF FUCK OFF" +Death: "....BE....PATIENT" +Player: "NO NO NO NO NO NO NO NO NO NO NO " +Death: "ALL......ENDS....NO....RUSH" +Player: "What the fuck am I supposed to do in this shitty game" +Death: ".....MOVE...FORWARD" +Player: "How???" +Death: "...ASK...AND..SHALL.....RECEIVE" diff --git a/server/training_data_convert.py b/server/training_data_convert.py index 84839e9..0a0030b 100644 --- a/server/training_data_convert.py +++ b/server/training_data_convert.py @@ -21,9 +21,10 @@ with open("converted_training.jsonl", "w") as w: for s_i in range(len(sentences)): s = sentences[s_i] - if s.startswith("Old Man:"): + if not s.startswith("Player:"): + npc_prompt = s.split(" ")[0] prompt = "\\n".join(sentences[:s_i]).replace('"', '\\"') - prompt += "\\nOld Man: \\\"" + prompt += f"\\n{npc_prompt} \\\"" completion = s.split(":")[1].split("\"")[1].replace('"', '\\"') completion += '\\"' #print(f"Prompt: {prompt} | \n\nCompletion: {completion}\n\n")