Add logging to server err on no api, more training

main
Cameron Murphy Reikes 2 years ago
parent f909a56024
commit 7e6b84b6c9

@ -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

@ -6,6 +6,7 @@ import (
"io" "io"
"os" "os"
"context" "context"
"log"
gogpt "github.com/sashabaranov/go-gpt3" gogpt "github.com/sashabaranov/go-gpt3"
) )
@ -22,12 +23,13 @@ func index(w http.ResponseWriter, req *http.Request) {
} else { } else {
promptString := string(promptBytes) promptString := string(promptBytes)
fmt.Println()
fmt.Println("Println line prompt string: ", promptString) fmt.Println("Println line prompt string: ", promptString)
ctx := context.Background() ctx := context.Background()
req := gogpt.CompletionRequest{ req := gogpt.CompletionRequest{
Model: "curie:ft-personal-2023-02-28-23-44-34", Model: "curie:ft-personal-2023-02-28-23-44-34",
MaxTokens: 30, MaxTokens: 80,
Prompt: promptString, Prompt: promptString,
Temperature: 0.9, Temperature: 0.9,
Stop: []string{"\""}, Stop: []string{"\""},
@ -35,6 +37,7 @@ func index(w http.ResponseWriter, req *http.Request) {
} }
resp, err := c.CreateCompletion(ctx, req) resp, err := c.CreateCompletion(ctx, req)
if err != nil { if err != nil {
fmt.Println("Failed to generate: ", err)
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
return return
} }
@ -45,10 +48,15 @@ func index(w http.ResponseWriter, req *http.Request) {
} }
func main() { 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) http.HandleFunc("/", index)
log.Println("Serving...")
http.ListenAndServe(":8090", nil) http.ListenAndServe(":8090", nil)
} }

@ -2,6 +2,8 @@ Player: "Hey old man"
Old Man: "Hmm? Another player?" Old Man: "Hmm? Another player?"
Player: "Fuck bitch cunt nugget" Player: "Fuck bitch cunt nugget"
Old Man: "Now now, let's be courteous. We wouldn't want any trouble now would we?" 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!" Player: "Fuck you!"
Old Man: "*fights player*" Old Man: "*fights player*"
@ -24,9 +26,11 @@ Old Man: "He he, certainly! Good luck!"
Player: "Why does anything exist at all." Player: "Why does anything exist at all."
Old Man: "All is one, one is all. Infinity is 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" 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" Player: "I don't care"
Old Man: "... *fights player*" Old Man: "... *fights player*"
@ -42,11 +46,6 @@ Old Man: "Nope! Still hurts."
Player: "Sorry to hear that." Player: "Sorry to hear that."
Old Man: "Bah whatever. Go back to saving the world" 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?" 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." 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?" 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!" Old Man: "Careful, I have a shotgun and I'm not afraid to stand my ground!"
Player: "Fuck off." Player: "Fuck off."
Old Man: "*fights player*" 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"

@ -21,9 +21,10 @@ with open("converted_training.jsonl", "w") as w:
for s_i in range(len(sentences)): for s_i in range(len(sentences)):
s = sentences[s_i] 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 = "\\n".join(sentences[:s_i]).replace('"', '\\"')
prompt += "\\nOld Man: \\\"" prompt += f"\\n{npc_prompt} \\\""
completion = s.split(":")[1].split("\"")[1].replace('"', '\\"') completion = s.split(":")[1].split("\"")[1].replace('"', '\\"')
completion += '\\"' completion += '\\"'
#print(f"Prompt: {prompt} | \n\nCompletion: {completion}\n\n") #print(f"Prompt: {prompt} | \n\nCompletion: {completion}\n\n")

Loading…
Cancel
Save