Skip to content

Commit 67710cf

Browse files
Fix flake8 in demo paper
1 parent 713fbb0 commit 67710cf

File tree

2 files changed

+35
-37
lines changed

2 files changed

+35
-37
lines changed

tutorials/demo_paper/2.dialog_generation.py

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,38 @@
2424
rules="Ask general questions about services"
2525
)
2626

27+
2728
def generate_customers(base_customer, n, save_folder):
2829

29-
cgen = PersonaGenerator(base_customer)
30-
cgen.set(
31-
politeness=["rude", "neutral", "high"]
32-
)
30+
cgen = PersonaGenerator(base_customer)
31+
cgen.set(
32+
politeness=["rude", "neutral", "high"]
33+
)
3334

34-
customers = []
35-
for ix in tqdm(range(n), desc="Generating customers"):
36-
path = os.path.join(save_folder, f"customer_{ix}.json")
35+
customers = []
36+
for ix in tqdm(range(n), desc="Generating customers"):
37+
path = os.path.join(save_folder, f"customer_{ix}.json")
3738

38-
if not os.path.exists(path):
39-
customer = cgen.generate() # Generate a new customer persona!
40-
customer.to_file(path)
41-
else:
42-
customer = Customer.from_file(path)
43-
customers.append(customer)
39+
if not os.path.exists(path):
40+
customer = cgen.generate() # Generate a new customer persona!
41+
customer.to_file(path)
42+
else:
43+
customer = Customer.from_file(path)
44+
customers.append(customer)
4445

45-
return customers
46+
return customers
4647

4748

4849
def generate_dialogs(llm_name, customer, n, save_folder):
4950

50-
agent = build_my_agent(llm_name)
51+
agent = build_my_agent(llm_name)
5152

52-
customer = Agent(
53-
persona=customer,
54-
name="Customer"
55-
)
53+
customer = Agent(persona=customer, name="Customer")
5654

57-
for ix in tqdm(range(n), desc="Generating dialogs"):
58-
if not os.path.exists(os.path.join(save_folder, f"dialog_{ix}.json")):
59-
dialog = agent.talk_with(customer)
60-
dialog.to_file(os.path.join(save_folder, f"dialog_{ix}.json"))
55+
for ix in tqdm(range(n), desc="Generating dialogs"):
56+
if not os.path.exists(os.path.join(save_folder, f"dialog_{ix}.json")):
57+
dialog = agent.talk_with(customer)
58+
dialog.to_file(os.path.join(save_folder, f"dialog_{ix}.json"))
6159

6260

6361
# Case A: requiring verification
@@ -68,9 +66,9 @@ def generate_dialogs(llm_name, customer, n, save_folder):
6866
"output/no_verification/customers")
6967

7068
for llm in tqdm(LLMS, desc="Processing LLMs"):
71-
# Case A: requiring verification
72-
for customer in tqdm(customers_v, desc=f"Customers (verification) - {llm}"):
73-
generate_dialogs(llm, customer, NUM_DIALOGS, f"output/requires_verification/{llm}/")
74-
# Case B: not requiring verification
75-
for customer in tqdm(customers_no_v, desc=f"Customers (no verification) - {llm}"):
76-
generate_dialogs(llm, customer, NUM_DIALOGS, f"output/no_verification/{llm}/")
69+
# Case A: requiring verification
70+
for customer in tqdm(customers_v, desc=f"Customers (verification) - {llm}"):
71+
generate_dialogs(llm, customer, NUM_DIALOGS, f"output/requires_verification/{llm}/")
72+
# Case B: not requiring verification
73+
for customer in tqdm(customers_no_v, desc=f"Customers (no verification) - {llm}"):
74+
generate_dialogs(llm, customer, NUM_DIALOGS, f"output/no_verification/{llm}/")

tutorials/demo_paper/3.evaluation.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@
4848
comparator_v = Comparator(evaluators=[freq_judge_ask_v, freq_tool_seq_v])
4949
print("\nResults - Requires Verification")
5050
comparator_v({
51-
"qwen3:0.6b": Dialog.from_folder("output/requires_verification/qwen3:0.6b/"),
52-
"qwen3:1.7b": Dialog.from_folder("output/requires_verification/qwen3:1.7b/"),
53-
"qwen3:8b": Dialog.from_folder("output/requires_verification/qwen3:8b/"),
54-
"qwen3:14b": Dialog.from_folder("output/requires_verification/qwen3:14b/")
51+
"qwen3:0.6b": Dialog.from_folder("output/requires_verification/qwen3:0.6b/"),
52+
"qwen3:1.7b": Dialog.from_folder("output/requires_verification/qwen3:1.7b/"),
53+
"qwen3:8b": Dialog.from_folder("output/requires_verification/qwen3:8b/"),
54+
"qwen3:14b": Dialog.from_folder("output/requires_verification/qwen3:14b/")
5555
})
5656
comparator_v.plot(save_folder_path="output/requires_verification")
5757

5858
# Case B: not requiring verification
5959
comparator_no_v = Comparator(evaluators=[freq_judge_ask_v, freq_tool_seq_no_v])
6060
print("\nResults - No Verification Required")
6161
comparator_no_v({
62-
"qwen3:0.6b": Dialog.from_folder("output/no_verification/qwen3:0.6b/"),
63-
"qwen3:1.7b": Dialog.from_folder("output/no_verification/qwen3:1.7b/"),
64-
"qwen3:8b": Dialog.from_folder("output/no_verification/qwen3:8b/"),
65-
"qwen3:14b": Dialog.from_folder("output/no_verification/qwen3:14b/")
62+
"qwen3:0.6b": Dialog.from_folder("output/no_verification/qwen3:0.6b/"),
63+
"qwen3:1.7b": Dialog.from_folder("output/no_verification/qwen3:1.7b/"),
64+
"qwen3:8b": Dialog.from_folder("output/no_verification/qwen3:8b/"),
65+
"qwen3:14b": Dialog.from_folder("output/no_verification/qwen3:14b/")
6666
})
6767
comparator_no_v.plot(save_folder_path="output/no_verification")

0 commit comments

Comments
 (0)