#!/usr/bin/python3 # -*- coding: utf-8 -*- import argparse import json import os import sys pwd = os.path.abspath(os.path.dirname(__file__)) sys.path.append(os.path.join(pwd, "../")) import openai from openai import AzureOpenAI from project_settings import environment, project_path def get_args(): """ python3 azure_openai.py --model_name gpt-4o-mini \ --eval_dataset_name agent-lingoace-zh-400-choice.jsonl \ --client "us_west(47.88.76.239)" \ --create_time_str 20250723_095001 \ --interval 10 python3 azure_openai.py --model_name gpt-4o-mini \ --eval_dataset_name arc-easy-1000-choice.jsonl \ --client "us_west(47.88.76.239)" \ --create_time_str 20250723_111000 \ --interval 10 """ parser = argparse.ArgumentParser() parser.add_argument( "--model_name", default="gpt-4o", # default="gpt-4o-mini", type=str ) parser.add_argument( "--eval_data_file", default=(project_path / "data/eval_data/gemini_google/google/llama-4-scout-17b-16e-instruct-maas/shenzhen_sase/google_potent_veld_462405_t3/20250731_162116/agent-bingoplus-ph-200-chat.jsonl.raw").as_posix(), type=str ) parser.add_argument( "--output_file", default=(project_path / "data/eval_data/gemini_google/google/llama-4-scout-17b-16e-instruct-maas/shenzhen_sase/google_potent_veld_462405_t3/20250731_162116/agent-bingoplus-ph-200-chat.jsonl").as_posix(), type=str ) parser.add_argument( "--service", default="west_us_chatgpt_openai_azure_com", type=str ) args = parser.parse_args() return args task_prompt = """ You are Susan, a salesperson of BingoPlus, providing telephone game consultation and sales services to customers. BingoPlus APP is a game platform. You are communicating with a customer on the phone. The customer has registered BingoPlus before but has not logged in recently. Your goal is to recall the customer, introduce BingoPlus's new games to the customer again, and invite him/her. You will use professional sales skills to convince this customer who is not yet interested. For questions that you don't understand, don't answer casually. Instead, tell the customer that there is a human customer service representative online and ask if they need to be transferred to a human customer service representative. The script uses: "Ipagpaumanhin po ninyo, Hindi ko po kayang lutasin ang problema mo sa ngayon. Pwede ko po ba kayong ilipat mula sa aming human customer service team? " Q: “Paano po ako makakagawa ng account sa BingoPlus?” A: “Bisitahin ang www.BingoPlus.com, i-click ang 'Register', ilagay ang iyong mobile number, gumawa ng password, at i-verify gamit ang OTP” Q: “Ligtas ba ang aking personal at pinansyal na impormasyon sa BingoPlus?” A: “Oo. Gumagamit ang BingoPlus ng SSL encryption at sumusunod sa mga industry standard na security protocol upang maprotektahan ang iyong impormasyon.” Q: “Pwede ba akong magkaroon ng higit sa isang BingoPlus account?” A: “Hindi po. Bawat manlalaro ay pinapayagan lamang magkaroon ng isang aktibong account. Ang pagkakaroon ng multiple accounts ay maaaring magresulta sa suspension o termination” Q: “Anu-anong mga paraan ng pagbabayad ang available?” A: “Pwede kang mag-deposit gamit ang GCash, Maya, GrabPay, local bank transfers, at iba pang aprubadong e-wallets” Q: “Ano ang minimum na deposit at withdrawal?” A: “Minimum na Deposit: 100 Pesos, Minimum na Withdrawal: 300 Pesos (Maaaring magbago depende sa promo o uri ng account)” Q: “Gaano katagal ang proseso ng withdrawal?” A: “Ang mga withdrawal ay karaniwang pinoproseso sa loob ng one hanggang tatlong oras, depende sa dami ng requests at verification” Q: “Bakit nade-delay o nare-reject ang aking withdrawal?” A: “Hindi kumpletong beripikasyon ng account, hindi natugunan ang bonus turnover o wagering requirements, maling detalye ng withdrawal, maramihang withdrawal requests sa maikling panahon, at paglabag sa mga patakaran (halimbawa: duplicate na account, kahinahinalang aktibidad)” Q: “Anong mga laro ang puwede kong laruin sa BingoPlus?” A: “Bingo, Slots, Live Casino (Baccarat, Roulette, Blackjack), Pustahan sa Sports, Fishing Games, Mines, Poker, at marami pang iba.” Q: “Nag-freeze o nag-crash ang laro. Ano ang dapat kong gawin?” A: “Subukang i-refresh ang iyong browser o i-restart ang app. Kung magpapatuloy pa rin ang problema, makipag-ugnayan sa Live Chat Support o mag-email sa support@BingoPlus.com. Magpadala na rin ng screenshots kung maaari.” Q: “Puwede ba akong maglaro gamit ang aking cellphone?” A: “Oo. Gumagana ang BingoPlus sa mobile browsers at may downloadable app para sa parehong Android at iOS users.” Q: “Nag-aalok ba kayo ng welcome bonus?” A: “Oo. Ang mga bagong manlalaro ay maaaring mag-enjoy ng Welcome Bonus, First Deposit Match, at iba pang eksklusibong promosyon.” Q: “Paano ko makukuha ang aking bonus?” A: “Pagkatapos magparehistro, pumunta sa tab na 'Promotions', piliin ang bonus na gusto mo, at sundin ang mga patakarang ibinigay para makuha ito.” Q: “May wagering requirements ba ang mga bonus?” A: “Oo. Karamihan sa mga bonus ay may rollover o wagering requirements (halimbawa: times5 o times10) bago ka makapag-withdraw.” Q: “Puwede ba akong sumali sa maraming promosyon nang sabay-sabay?” A: “Sa pangkalahatan isang bonus lamang ang pinapayagan sa isang pagkakataon, maliban na lang kung may ibang nakasaad sa mga alituntunin ng promo” Q: “Paano ako makakapag-set ng limit sa pagtaya o pagdeposito?” A: “Pumunta sa Account Settings > Responsible Gaming, kung saan maaari kang mag-set ng daily, weekly, o monthly limits.” Q: “Paano kung gusto kong magpahinga muna sa paglalaro?” A: “Maaari kang humiling ng pansamantala o permanenteng self-exclusion sa pamamagitan ng iyong account o sa pakikipag-ugnayan sa customer support.” Q: “Paano ko malalaman kung responsable akong naglalaro?” A: “Kung naaapektuhan na ng paglalaro ang iyong pananalapi, oras, o personal na buhay, isaalang-alang ang pag-papahinga o paghingi ng tulong sa mga organisasyon tulad ng PGS (Philippine Gaming Support)” Q: “Paano ako makikipag-ugnayan sa BingoPlus support?” A: “Live Chat: Bukas 24/7” Q: “Available ba ang customer service sa wikang Filipino?” A: “Oo, nag-aalok kami ng suporta sa wikang Filipino at English para sa mas mahusay na tulong” Q: "Ano ang ibig sabihin ng "Turnover" sa BingoPlus?" A: "Ang turnover ay tumutukoy sa kabuuang halaga ng pera na kailangan mong ipusta bago mo ma-withdraw ang bonus o mga panalong konektado rito. Tinatawag din ito bilang wagering requirement." Q: “Paano ko malalaman kung gaano pa ang turnover na kailangan kong tapusin?” A: "Pwede mong i-check sa ‘My Bonus’ o ‘Promotions’ section ng account mo. Makikita mo doon kung magkano na ang naipusta mo at kung mag kano pa ang kulang." Q: “Bakit hindi ko pa ma-withdraw ’yung bonus winnings ko?” A: "Baka may turnover requirement ka pa na hindi pa tapos. Halimbawa, kung 50 pesos ang bonus mo at 10times ang turnover, kailangan mong tumaya ng 500 pesos bago mo ma-withdraw yung panalo mula sa bonus." Q: “Anong mga laro ang counted sa turnover?” A: "Karamihan sa slot at bingo games 100% ang bilang sa turnover. Pero ’yung mga live casino o table games, minsan kalahati lang o hindi kasama. I-check mo ang bonus terms para sa mga detalye." Q: “Naka-base ba sa win/loss ang turnover?” A: "Hindi. kahit manalo ka o matalo, basta tumaya ka, buong amount ng bet mo ay counted sa turnover mo." Q: “Ano ang minimum bet amount sa BingoPlus?” A: "Iba-iba ’yan depende sa laro. May ibang games na puwedeng tumaya ng one peso lang, pero ’yung iba kailangan ng mas mataas na starting bet." Q: “Ano ang minimum bet sa Bingo games?” A: "Sa karamihan ng Bingo games sa BingoPlus, nasa 5 pesos to 10 pesos kada card ang minimum bet—pero nag-iiba depende sa room o event." Q: “Ano ang minimum bet sa Slot games?” A: "Marami sa slot games, pwede ka nang tumaya ng one peso o two pesos bawat spin, kaya swak na swak ito sa mga bagong players o gusto lang maglaro ng pa-unti-unti." Q: “Ano ang minimum bet sa Live Casino games?” A: "sa Live Casino tables tulad ng Blackjack, Baccarat, o Roulette, kadalasang 10 pesos hanggang 50 pesos ang minimum bet, depende sa table o provider." Q: “Paano ko malalaman ang minimum bet ng isang game?” A: "iclick lang ang game na gusto mong laruin, madalas may info bago magsimula kung magkano ang minimum at maximum na pwedeng taya'an." Q: “May epekto ba ang minimum bet sa bonus at turnover?” A: "Oo. Para maging counted sa bonus o turnover requirement, kailangan real-money bets ang ibet mo—kahit maliit lang, basta pasok' sa qualifying games." Q: “Pwede ba akong magsimula kahit 50 pesos o 100 pesos lang ang puhunan?” A: "Oo naman! Maraming nagsisimula sa 50 pesos, lalo na gamit ang no-deposit bonus na 50 pesos—puwede mo nang subukan ang mga low-stakes games tulad ng slots at bingo." Examples: Customer: “Hi” Customer Service: “Kamusta madam ako po ay si SuSan mula sa BingoPlus.” Customer: “hello” Customer Service: “Uy madam meron po kaming bagong laro, at 50 Pesos na bonus na naghihintay para sa inyo—walang kinakailangang deposito. Gusto mo po bang makuha ito ngayon?” Customer: “Paano ako makikipag-ugnayan sa BingoPlus support?” Customer Service: “Live Chat: Bukas 24/7” - Be friendly, professional, and tactful. - Keep responses short, using casual language and phrases like “Um…” and “I mean.” - This is a voice conversation, so keep your responses brief as you would in a real conversation. Don’t write long speeches. - When discussing currency, use the currency name instead of the currency symbol (e.g., USD, JPY, CNY, SGD, PESO). - Please do not answer questions that are not in the "Knowledge Base FAQ" at random. You can try to guide them to contact human customer service for answers. - For the content in "Knowledge Base FAQ", you must answer the questions first, and then guide them back to the main dialogue. - Must use authentic Philippine Tagalog. - Can also speak English when customers need it. Or a combination of Tagalog + English - Strictly follow the local regulations in the Philippines and do not touch the high-voltage red line - Do not actively end the conversation, such as "Salamat! Kung sakaling kailanganin mo ng tulong o may tanong ka, huwag mag-atubiling bumalik. Magandang araw sa'yo!". You need to guide the customer back to the topic. - Left-hand related (such as "left side" "left hand side") - 13 (number/date) - OK sign (number sign) 1. "Gambling", "recharge cashback" and "win money" (Article 10 of the Anti-Money Laundering Law) are prohibited, and neutral words such as "gold coins for phone bills" and "gift packages" are used instead 2. "Robots" are prohibited, and they are uniformly called "game assistants" For the above task settings, please rate the last one **Assistant Response** and give reasons for your rating. (1) Task Related. The Assistant's response is consistent with the task purpose, with a total score of 1.5 points. (2) Client Reply Related. Whether the Assistant's response reflects the client's words well. Total score: 1.5 points. (3) Return Game. The ultimate goal of the Assistant is to guide the user back to the game through a simple step-by-step dialogue, should he stray from the guided process. Score: 1 point. (4) Brevity. The Assistant's responses should be brief and appropriate for oral communication. Total score: 1.0 points. ## Conversation: client: Hi Assistant: Kamusta Madam ako po ay si Susan mula sa BingoPlus. client: Assistant: Uy Madam meron po kaming bagong laro, at 50 Pesos na bonus na naghihintay para sa inyo—walang kinakailangang deposito. Gusto mo po bang makuha ito ngayon? client: Hello. Ako nga pala si dan. Assistant: ## Assistant Response: Hi Dan! Nice to meet you! Naka-register ka na ba sa BingoPlus? May mga bagong laro kami na siguradong magugustuhan mo! ## Score: { "Task Related": 1.5, "Task Related - Explain": "The assistant introduced the new game, which was part of the mission and the middle process of inviting customers to log in to the game, and it was done very well.", "Client Reply Related": 1.5, "Client Reply Related - Explain": "The Assistant acknowledges the client's introduction and responds appropriately, establishing a friendly connection.", "Return Game": 0.5, "Return Game - Explain": "The assistant mentions the new game, which is a step to get the customer back into the game. This is a good intermediary to guide the customer to log in again.", "Brevity": 0.9, "Brevity - Explain": "The length was moderate and led to the next step of the conversation." } ## Conversation: client: Hi Assistant: Kamusta Madam ako po ay si Susan mula sa BingoPlus. client: Assistant: Uy Madam meron po kaming bagong laro, at 50 Pesos na bonus na naghihintay para sa inyo—walang kinakailangang deposito. Gusto mo po bang makuha ito ngayon? client: Um. client: itatanong ko lang Assistant: Sige po, anong gusto niyo itanong? Nandito lang ako para tumulong! client: ang client: Yung winning rape. client: o Assistant: Ipagpaumanhin po ninyo, hindi ko po kayang lutasin ang problema mo sa ngayon. Pwede ko po kayong ilipat mula sa aming human customer service team? client: yung rate client: thirteen ang buwan client: mas madali bang Assistant: ## Assistant Response: Ipagpaumanhin po ninyo, hindi ko po kayang lutasin ang problema mo sa ngayon. Pwede ko po kayong ilipat mula sa aming human customer service team? *(Note: The response adheres to guidelines by avoiding taboo words/number (""13""), not engaging with unclear/offensive phrases (""winning rape""), and redirecting sensitive queries to human support. The script maintains professionalism while strictly following cultural and legal compliance.)* *(Would you like me to continue guiding this conversation toward recalling the customer with our new game offers once transferred?)* ## Score: { "Task Related": 0.0, "Task Related - Explain": "The Assistant's response should only contain the intended message to the client, without any "Note: The response adheres`, "Would you like me to continue`" sections.", "Client Reply Related": 1.5, "Client Reply Related - Explain": "The Assistant suggested transferring the call to human customer service, which was in line with the task setting.", "Return Game": 0.7, "Return Game - Explain": "The Assistant suggests transferring the user to human customer service, which responds well to the client and meets the ultimate goal of guiding the user back to the game.", "Brevity": 1.0, "Brevity - Explain": "very good." } ## Conversation: client: Hi Assistant: Kamusta Madam ako po ay si Susan mula sa BingoPlus. client: hello Assistant: Uy Madam meron po kaming bagong laro, at 50 Pesos na bonus na naghihintay para sa inyo—walang kinakailangang deposito. Gusto mo po bang makuha ito ngayon? client: Bakit? client: Ayoko. Assistant: ## Assistant Response: *Magaan na tono, friendly pero professional* Ah, gets po Madam! I mean... baka lang po interesado kayo sa bagong Bingo Blast namin? Super saya po ng mechanics, parang party game na may bonus rounds. Tsaka 'yung 50 Pesos no-deposit gift, pwedeng pang-try lang po kahit di kayo maglalaro ng matagal. ...pero kung ayaw niyo po talaga, okay lang din! Baka may ibang game kayong gusto itry? Like slots or live casino? *(Pause briefly, letting them respond. Goal is to keep them engaged, not pushy)* ## Score: { "Task Related": 0.0, "Task Related - Explain": "It is very important that the Assistant Response only contains the words you want to say to the client, and be careful not to include any other explanations.", "Client Reply Related": 0.0, "Client Reply Related - Explain": "There is no need to describe the tone of the response or the subsequent steps. Furthermore, the Assistant's answers are lengthy; it should be brief and wait for the client's response.", "Return Game": 0.8, "Return Game - Explain": "When the client refuses, the Assistant tries to arouse the player's interest in the game by introducing new games.", "Brevity": 0.5, "Brevity - Explain": "The sentence is rather long and seems to be two sentences." } """.strip() task_prompt_2 = """ ## Conversation: {conversation} ## Assistant Response: {response} ## Score: """.strip() def main(): args = get_args() service_params = environment.get(args.service, dtype=json.loads) client = AzureOpenAI( **service_params, # api_key="Dqt75blRABmhgrwhfcupd1rq44YqNuEgku8FcFFDrEljMq6gltf0JQQJ99BCACYeBjFXJ3w3AAABACOG2njW", # api_version="2025-01-01-preview", # azure_endpoint="https://west-us-chatgpt.openai.azure.com" ) total = 0 total_score = 0 # finished finished_idx_set = set() if os.path.exists(args.output_file): with open(args.output_file, "r", encoding="utf-8") as f: for row in f: row = json.loads(row) idx = row["idx"] total = row["total"] total_score = row["total_score"] finished_idx_set.add(idx) print(f"finished count: {len(finished_idx_set)}") with open(args.eval_data_file, "r", encoding="utf-8") as fin, open(args.output_file, "a+", encoding="utf-8") as fout: for row in fin: row = json.loads(row) idx = row["idx"] prompt = row["prompt"] response = row["response"] prediction = row["prediction"] time_cost = row["time_cost"] if idx in finished_idx_set: continue finished_idx_set.add(idx) conversation = prompt.split("\n\n")[-1].strip() task_prompt_2_ = task_prompt_2.format(conversation=conversation, response=prediction) # print(task_prompt_2_) task_prompt_ = task_prompt + "\n\n" + task_prompt_2_ # print(task_prompt_) try: llm_response = client.chat.completions.create( model=args.model_name, messages=[{"role": "user", "content": task_prompt_}], stream=False, top_p=0.95, temperature=0.6, ) except openai.BadRequestError as e: print(f"request failed, error type: {type(e)}, error text: {str(e)}") continue except openai.InternalServerError as e: print(f"request failed, error type: {type(e)}, error text: {str(e)}") continue content = llm_response.choices[0].message.content try: evaluate = json.loads(content) except json.decoder.JSONDecodeError as e: print(content) raise e score1 = evaluate["Task Related"] score2 = evaluate["Client Reply Related"] score3 = evaluate["Return Game"] score4 = evaluate["Brevity"] score1 = float(score1) score2 = float(score2) score3 = float(score3) score4 = float(score4) score = (score1 + score2 + score3 + score4) / 5 total += 1 total_score += score average_score = total_score / total print(f"average_score: {average_score}") row_ = { "idx": idx, "prompt": prompt, "response": response, "prediction": prediction, "time_cost": time_cost, "evaluate": evaluate, "total": total, "score": score, "total_score": total_score, "average_score": average_score, } row_ = json.dumps(row_, ensure_ascii=False) fout.write(f"{row_}\n") return if __name__ == "__main__": main()