Spaces:
Sleeping
Sleeping
Update chat.py
Browse files
chat.py
CHANGED
|
@@ -146,29 +146,21 @@ def populate_prompt(game_id, splits):
|
|
| 146 |
|
| 147 |
|
| 148 |
def initialize_game(game_id, user_id, user_input):
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
|
| 157 |
-
# llm_prompt_op = call_gpt(whole_prompt)
|
| 158 |
-
# #print(llm_prompt_op.choices[0]["message"]["content"])
|
| 159 |
-
# fname="prompt_" + game_id + "_" + user_id + ".txt"
|
| 160 |
-
# save_file(fname, llm_prompt_op.choices[0]["message"]["content"])
|
| 161 |
-
# return llm_prompt_op.choices[0]["message"]["content"]
|
| 162 |
-
|
| 163 |
-
word_doc_contents = read_word_document(file_path + "/" + file_name)
|
| 164 |
-
whole_prompt = word_doc_contents[0].replace("<<USER_INPUT_MSG>>", user_input)
|
| 165 |
-
|
| 166 |
llm_prompt_op = call_gpt(whole_prompt)
|
| 167 |
#print(llm_prompt_op.choices[0]["message"]["content"])
|
| 168 |
fname="prompt_" + game_id + "_" + user_id + ".txt"
|
| 169 |
save_file(fname, llm_prompt_op.choices[0]["message"]["content"])
|
| 170 |
return llm_prompt_op.choices[0]["message"]["content"]
|
| 171 |
|
|
|
|
| 172 |
def generate_image_prompt(game_id, user_id, user_input):
|
| 173 |
if 'You have a manual' in user_input:
|
| 174 |
user_input = user_input.replace('You have a manual of this newly created simulation in your mind. Now what is the first thing you will do in this world?', '')
|
|
|
|
| 146 |
|
| 147 |
|
| 148 |
def initialize_game(game_id, user_id, user_input):
|
| 149 |
+
game_details = get_game_details(game_id)
|
| 150 |
+
whole_prompt = populate_prompt(game_id, game_details["splits"])
|
| 151 |
+
if debug:
|
| 152 |
+
print(whole_prompt[:1000])
|
| 153 |
+
whole_prompt = whole_prompt.replace("<<USER_INPUT_MSG>>", user_input)
|
| 154 |
+
if debug:
|
| 155 |
+
print(whole_prompt[:1000])
|
| 156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
llm_prompt_op = call_gpt(whole_prompt)
|
| 158 |
#print(llm_prompt_op.choices[0]["message"]["content"])
|
| 159 |
fname="prompt_" + game_id + "_" + user_id + ".txt"
|
| 160 |
save_file(fname, llm_prompt_op.choices[0]["message"]["content"])
|
| 161 |
return llm_prompt_op.choices[0]["message"]["content"]
|
| 162 |
|
| 163 |
+
|
| 164 |
def generate_image_prompt(game_id, user_id, user_input):
|
| 165 |
if 'You have a manual' in user_input:
|
| 166 |
user_input = user_input.replace('You have a manual of this newly created simulation in your mind. Now what is the first thing you will do in this world?', '')
|