Spaces:
Sleeping
Sleeping
Update chat.py
Browse files
chat.py
CHANGED
|
@@ -116,23 +116,8 @@ def start_game(game_id, user_id, user_input):
|
|
| 116 |
vector_db.upsert(payload)
|
| 117 |
|
| 118 |
return(llm_output)
|
| 119 |
-
|
| 120 |
-
def populate_prompt(game_id):
|
| 121 |
-
prompt_text = list()
|
| 122 |
-
idlist = []
|
| 123 |
-
for j in range(21):
|
| 124 |
-
idlist.append(game_id + "-" + str(j))
|
| 125 |
|
| 126 |
|
| 127 |
-
results=vector_db.fetch(ids=idlist)
|
| 128 |
-
|
| 129 |
-
for ids in idlist:
|
| 130 |
-
prompt_text.append(results['vectors'][ids]["metadata"]["text"])
|
| 131 |
-
|
| 132 |
-
whole_prompt = ' '.join(prompt_text).strip()
|
| 133 |
-
return whole_prompt
|
| 134 |
-
|
| 135 |
-
|
| 136 |
def populate_prompt(game_id, splits):
|
| 137 |
prompt_text = list()
|
| 138 |
idlist = []
|
|
@@ -150,12 +135,8 @@ def populate_prompt(game_id, splits):
|
|
| 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 |
-
|
| 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"
|
|
|
|
| 116 |
vector_db.upsert(payload)
|
| 117 |
|
| 118 |
return(llm_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
def populate_prompt(game_id, splits):
|
| 122 |
prompt_text = list()
|
| 123 |
idlist = []
|
|
|
|
| 135 |
def initialize_game(game_id, user_id, user_input):
|
| 136 |
game_details = get_game_details(game_id)
|
| 137 |
whole_prompt = populate_prompt(game_id, game_details["splits"])
|
|
|
|
|
|
|
| 138 |
whole_prompt = whole_prompt.replace("<<USER_INPUT_MSG>>", user_input)
|
| 139 |
+
|
|
|
|
|
|
|
| 140 |
llm_prompt_op = call_gpt(whole_prompt)
|
| 141 |
#print(llm_prompt_op.choices[0]["message"]["content"])
|
| 142 |
fname="prompt_" + game_id + "_" + user_id + ".txt"
|