2424 rules = "Ask general questions about services"
2525)
2626
27+
2728def 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
4849def 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
7068for 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 } /" )
0 commit comments