Spaces:
Runtime error
Runtime error
removed debugger
Browse files- app.py +0 -4
- sotopia_pi_generate.py +0 -3
app.py
CHANGED
|
@@ -102,7 +102,6 @@ def create_bot_agent_dropdown(environment_id, user_agent_id):
|
|
| 102 |
environment, user_agent = environment_dict[environment_id], agent_dict[user_agent_id]
|
| 103 |
|
| 104 |
bot_agent_list = []
|
| 105 |
-
# import pdb; pdb.set_trace()
|
| 106 |
for neighbor_id in relationship_dict[environment.relationship][user_agent.agent_id]:
|
| 107 |
bot_agent_list.append((agent_dict[neighbor_id].name, neighbor_id))
|
| 108 |
|
|
@@ -122,7 +121,6 @@ def create_user_info(user_agent_dropdown):
|
|
| 122 |
|
| 123 |
def create_bot_info(bot_agent_dropdown):
|
| 124 |
_, _, agent_dict, _ = get_sotopia_profiles()
|
| 125 |
-
# import pdb; pdb.set_trace()
|
| 126 |
bot_agent = agent_dict[bot_agent_dropdown]
|
| 127 |
text = f"{bot_agent.background} {bot_agent.personality}"
|
| 128 |
return gr.Textbox(label="Bot Agent Profile", lines=4, value=text)
|
|
@@ -215,12 +213,10 @@ def chat_tab():
|
|
| 215 |
user_agent = agent_dict[user_agent_dropdown]
|
| 216 |
bot_agent = agent_dict[bot_agent_dropdown]
|
| 217 |
|
| 218 |
-
# import pdb; pdb.set_trace()
|
| 219 |
context = get_context_prompt(bot_agent, user_agent, environment)
|
| 220 |
dialogue_history, next_turn_idx = dialogue_history_prompt(message, history, user_agent, bot_agent)
|
| 221 |
prompt_history = f"{context}\n\n{dialogue_history}"
|
| 222 |
agent_action = generate_action(model_selection, prompt_history, next_turn_idx, ACTION_TYPES, bot_agent.name, TEMPERATURE)
|
| 223 |
-
# import pdb; pdb.set_trace()
|
| 224 |
return agent_action.to_natural_language()
|
| 225 |
|
| 226 |
with gr.Column():
|
|
|
|
| 102 |
environment, user_agent = environment_dict[environment_id], agent_dict[user_agent_id]
|
| 103 |
|
| 104 |
bot_agent_list = []
|
|
|
|
| 105 |
for neighbor_id in relationship_dict[environment.relationship][user_agent.agent_id]:
|
| 106 |
bot_agent_list.append((agent_dict[neighbor_id].name, neighbor_id))
|
| 107 |
|
|
|
|
| 121 |
|
| 122 |
def create_bot_info(bot_agent_dropdown):
|
| 123 |
_, _, agent_dict, _ = get_sotopia_profiles()
|
|
|
|
| 124 |
bot_agent = agent_dict[bot_agent_dropdown]
|
| 125 |
text = f"{bot_agent.background} {bot_agent.personality}"
|
| 126 |
return gr.Textbox(label="Bot Agent Profile", lines=4, value=text)
|
|
|
|
| 213 |
user_agent = agent_dict[user_agent_dropdown]
|
| 214 |
bot_agent = agent_dict[bot_agent_dropdown]
|
| 215 |
|
|
|
|
| 216 |
context = get_context_prompt(bot_agent, user_agent, environment)
|
| 217 |
dialogue_history, next_turn_idx = dialogue_history_prompt(message, history, user_agent, bot_agent)
|
| 218 |
prompt_history = f"{context}\n\n{dialogue_history}"
|
| 219 |
agent_action = generate_action(model_selection, prompt_history, next_turn_idx, ACTION_TYPES, bot_agent.name, TEMPERATURE)
|
|
|
|
| 220 |
return agent_action.to_natural_language()
|
| 221 |
|
| 222 |
with gr.Column():
|
sotopia_pi_generate.py
CHANGED
|
@@ -159,7 +159,6 @@ def generate(
|
|
| 159 |
output_parser: BaseOutputParser[OutputType],
|
| 160 |
temperature: float = 0.7,
|
| 161 |
) -> OutputType:
|
| 162 |
-
# import pdb; pdb.set_trace()
|
| 163 |
input_variables = re.findall(r"{(.*?)}", template)
|
| 164 |
assert (
|
| 165 |
set(input_variables) == set(list(input_values.keys()) + ["format_instructions"])
|
|
@@ -172,7 +171,6 @@ def generate(
|
|
| 172 |
input_values["format_instructions"] = output_parser.get_format_instructions()
|
| 173 |
result = chain.predict([logging_handler], **input_values)
|
| 174 |
prompt = logging_handler.retrive_prompt()
|
| 175 |
-
import pdb; pdb.set_trace()
|
| 176 |
try:
|
| 177 |
parsed_result = output_parser.parse(result)
|
| 178 |
except KeyboardInterrupt:
|
|
@@ -182,7 +180,6 @@ def generate(
|
|
| 182 |
f"[red] Failed to parse result: {result}\nEncounter Exception {e}\nstart to reparse",
|
| 183 |
extra={"markup": True},
|
| 184 |
)
|
| 185 |
-
import pdb; pdb.set_trace()
|
| 186 |
reformat_parsed_result = format_bad_output(
|
| 187 |
result, format_instructions=output_parser.get_format_instructions()
|
| 188 |
)
|
|
|
|
| 159 |
output_parser: BaseOutputParser[OutputType],
|
| 160 |
temperature: float = 0.7,
|
| 161 |
) -> OutputType:
|
|
|
|
| 162 |
input_variables = re.findall(r"{(.*?)}", template)
|
| 163 |
assert (
|
| 164 |
set(input_variables) == set(list(input_values.keys()) + ["format_instructions"])
|
|
|
|
| 171 |
input_values["format_instructions"] = output_parser.get_format_instructions()
|
| 172 |
result = chain.predict([logging_handler], **input_values)
|
| 173 |
prompt = logging_handler.retrive_prompt()
|
|
|
|
| 174 |
try:
|
| 175 |
parsed_result = output_parser.parse(result)
|
| 176 |
except KeyboardInterrupt:
|
|
|
|
| 180 |
f"[red] Failed to parse result: {result}\nEncounter Exception {e}\nstart to reparse",
|
| 181 |
extra={"markup": True},
|
| 182 |
)
|
|
|
|
| 183 |
reformat_parsed_result = format_bad_output(
|
| 184 |
result, format_instructions=output_parser.get_format_instructions()
|
| 185 |
)
|