Spaces:
Sleeping
Sleeping
Update initialize_game to include user input
Browse files
chat.py
CHANGED
|
@@ -133,8 +133,29 @@ def populate_prompt(game_id):
|
|
| 133 |
return whole_prompt
|
| 134 |
|
| 135 |
|
| 136 |
-
def
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
llm_prompt_op = call_gpt(whole_prompt)
|
| 139 |
#print(llm_prompt_op.choices[0]["message"]["content"])
|
| 140 |
fname="prompt_" + game_id + "_" + user_id + ".txt"
|
|
@@ -142,11 +163,4 @@ def initialize_game(user_id, game_id):
|
|
| 142 |
return llm_prompt_op.choices[0]["message"]["content"]
|
| 143 |
|
| 144 |
if __name__ == '__main__':
|
| 145 |
-
|
| 146 |
-
game_id = '536e6bc89df5'
|
| 147 |
-
output = initialize_game(user_id, game_id)
|
| 148 |
-
print('\n\nGENESIS: %s' % output)
|
| 149 |
-
while True:
|
| 150 |
-
a = input('\n\n%s: ' % user_id)
|
| 151 |
-
output = start_game(game_id, user_id, user_input=a)
|
| 152 |
-
print('\n\nGENESIS: %s' % output)
|
|
|
|
| 133 |
return whole_prompt
|
| 134 |
|
| 135 |
|
| 136 |
+
def populate_prompt(game_id, splits):
|
| 137 |
+
prompt_text = list()
|
| 138 |
+
idlist = []
|
| 139 |
+
for j in range(int(splits)):
|
| 140 |
+
idlist.append(game_id + "-" + str(j))
|
| 141 |
+
|
| 142 |
+
results=vector_db.fetch(ids=idlist)
|
| 143 |
+
for ids in idlist:
|
| 144 |
+
prompt_text.append(results['vectors'][ids]["metadata"]["text"])
|
| 145 |
+
|
| 146 |
+
whole_prompt = ' '.join(prompt_text).strip()
|
| 147 |
+
return whole_prompt
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def initialize_game(game_id, user_id, user_input):
|
| 151 |
+
game_details = get_game_details(game_id)
|
| 152 |
+
whole_prompt = populate_prompt(game_id, game_details["splits"])
|
| 153 |
+
if debug:
|
| 154 |
+
print(whole_prompt[:1000])
|
| 155 |
+
whole_prompt = whole_prompt.replace("<<USER_INPUT_MSG>>", user_input)
|
| 156 |
+
if debug:
|
| 157 |
+
print(whole_prompt[:1000])
|
| 158 |
+
|
| 159 |
llm_prompt_op = call_gpt(whole_prompt)
|
| 160 |
#print(llm_prompt_op.choices[0]["message"]["content"])
|
| 161 |
fname="prompt_" + game_id + "_" + user_id + ".txt"
|
|
|
|
| 163 |
return llm_prompt_op.choices[0]["message"]["content"]
|
| 164 |
|
| 165 |
if __name__ == '__main__':
|
| 166 |
+
print("main")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|