{"repo": "agi-fbhc/agentschallenge", "files": {"websocietysimulator/llm/llm.py": {"43cd745767b8b5e589a6a25460a13975af722c12": {"t": 1785595452.38894, "n": 5563, "h": "76dd4fbf6ccb9d81", "c": "from typing import Dict, List, Optional, Union\nfrom openai import OpenAI\nfrom langchain_openai import OpenAIEmbeddings\nfrom .infinigence_embeddings import InfinigenceEmbeddings\nfrom tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_type\nimport logging\n\nlogger = logging.getLogger(\"websocietysimulator\")\n\n\nclass LLMBase:\n def __init__(self, model: str = \"qwen2.5-72b-instruct\"):\n \"\"\"\n Initialize LLM base class\n\n Args:\n model: Model name, defaults to deepseek-chat\n \"\"\"\n self.model = model\n\n def __call__(self, messages: List[Dict[str, str]], model: Optional[str] = None, temperature: float = 0.0,\n max_tokens: int = 500, stop_strs: Optional[List[str]] = None, n: int = 1) -> Union[str, List[str]]:\n \"\"\"\n Call LLM to get response\n\n Args:\n messages: List of input messages, each message is a dict containing role and content\n model: Optional model override\n max_tokens: Maximum tokens in response, defaults to 500\n stop_strs: Optional list of stop strings\n n: Number of responses to generate, defaults to 1\n\n Returns:\n Union[str, List[str]]: Response text from LLM, either a single string or list of strings\n \"\"\"\n raise NotImplementedError(\"Subclasses need to implement this method\")\n\n def get_embedding_model(self):\n \"\"\"\n Get the embedding model for text embeddings\n\n Returns:\n OpenAIEmbeddings: An instance of OpenAI's text embedding model\n \"\"\"\n raise NotImplementedError(\"Subclasses need to implement this method\")\n\n\nclass InfinigenceLLM(LLMBase):\n def __init__(self, api_key: str, model: str = \"qwen2.5-72b-instruct\"):\n \"\"\"\n Initialize Deepseek LLM\n\n Args:\n api_key: Deepseek API key\n model: Model name, defaults to qwen2.5-72b-instruct\n \"\"\"\n super().__init__(model)\n self.client = OpenAI(\n api_key=api_key,\n base_url=\"https://cloud.infini-ai.com/maas/v1\"\n )\n self.embedding_model = InfinigenceEmbeddings(api_key=api_key)\n\n @retry(\n retry=retry_if_exception_type(Exception),\n wait=wait_exponential(multiplier=1, min=10, max=300), # 等待时间从10秒开始,指数增长,最长300秒\n stop=stop_after_attempt(10) # 最多重试10次\n )\n def __call__(self, messages: List[Dict[str, str]], model: Optional[str] = None, temperature: float = 0.0,\n max_tokens: int = 500, stop_strs: Optional[List[str]] = None, n: int = 1) -> Union[str, List[str]]:\n \"\"\"\n Call Infinigence AI API to get response with rate limit handling\n\n Args:\n messages: List of input messages, each message is a dict containing role and content\n model: Optional model override\n max_tokens: Maximum tokens in response, defaults to 500\n stop_strs: Optional list of stop strings\n n: Number of responses to generate, defaults to 1\n\n Returns:\n Union[str, List[str]]: Response text from LLM, either a single string or list of strings\n \"\"\"\n try:\n response = self.client.chat.completions.create(\n model=model or self.model,\n messages=messages,\n temperature=temperature,\n max_tokens=max_tokens,\n stop=stop_strs,\n n=n,\n )\n\n if n == 1:\n return response.choices[0].message.content\n else:\n return [choice.message.content for choice in response.choices]\n except Exception as e:\n if \"429\" in str(e):\n logger.warning(\"Rate limit exceeded\")\n else:\n logger.error(f\"Other LLM Error: {e}\")\n raise e\n\n def get_embedding_model(self):\n return self.embedding_model\n\n\nclass OpenAILLM(LLMBase):\n def __init__(self, api_key: str, model: str = \"gpt-3.5-turbo\"):\n \"\"\"\n Initialize OpenAI LLM\n\n Args:\n api_key: OpenAI API key\n model: Model name, defaults to gpt-3.5-turbo\n \"\"\"\n super().__init__(model)\n self.client = OpenAI(api_key=api_key)\n self.embedding_model = OpenAIEmbeddings(api_key=api_key)\n\n def __call__(self, messages: List[Dict[str, str]], model: Optional[str] = None, temperature: float = 0.0,\n max_tokens: int = 500, stop_strs: Optional[List[str]] = None, n: int = 1) -> Union[str, List[str]]:\n \"\"\"\n Call OpenAI API to get response\n\n Args:\n messages: List of input messages, each message is a dict containing role and content\n model: Optional model override\n max_tokens: Maximum tokens in response, defaults to 500\n stop_strs: Optional list of stop strings\n n: Number of responses to generate, defaults to 1\n\n Returns:\n Union[str, List[str]]: Response text from LLM, either a single string or list of strings\n \"\"\"\n response = self.client.chat.completions.create(\n model=model or self.model,\n messages=messages,\n temperature=temperature,\n max_tokens=max_tokens,\n stop=stop_strs,\n n=n\n )\n\n if n == 1:\n return response.choices[0].message.content\n else:\n return [choice.message.content for choice in response.choices]\n\n def get_embedding_model(self):\n return self.embedding_model"}}, "agent.py": {"43cd745767b8b5e589a6a25460a13975af722c12": {"t": 1785595495.725667, "n": 5257, "h": "6431a16cf9efc800", "c": "from typing import Dict, List, Optional, Union\nfrom openai import OpenAI\nfrom tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_type\nimport logging\nimport os\nlogger = logging.getLogger(\"websocietysimulator\")\n\n\nclass LLMBase:\n def __init__(self, model: str = \"qwen2.5-72b-instruct\"):\n \"\"\"\n Initialize LLM base class\n\n Args:\n model: Model name, defaults to qwen2.5-72b-instruct\n \"\"\"\n self.model = model\n\n def __call__(self, messages: List[Dict[str, str]], model: Optional[str] = None, temperature: float = 0.0,\n max_tokens: int = 500, stop_strs: Optional[List[str]] = None, n: int = 1) -> Union[str, List[str]]:\n \"\"\"\n Call LLM to get response\n\n Args:\n messages: List of input messages, each message is a dict containing role and content\n model: Optional model override\n temperature: Sampling temperature, defaults to 0.0\n max_tokens: Maximum tokens in response, defaults to 500\n stop_strs: Optional list of stop strings\n n: Number of responses to generate, defaults to 1\n\n Returns:\n Union[str, List[str]]: Response text from LLM, either a single string or list of strings\n \"\"\"\n raise NotImplementedError(\"Subclasses need to implement this method\")\n\n\nclass InfinigenceLLM(LLMBase):\n def __init__(self, api_key: str, model: str = \"qwen2.5-72b-instruct\"):\n \"\"\"\n Initialize Infinigence LLM\n\n Args:\n api_key: API key for authentication\n model: Model name, defaults to qwen2.5-72b-instruct\n \"\"\"\n super().__init__(model)\n self.client = OpenAI(\n api_key=api_key,\n base_url=\"https://cloud.infini-ai.com/maas/v1\"\n )\n\n @retry(\n retry=retry_if_exception_type(Exception),\n wait=wait_exponential(multiplier=1, min=4, max=60), # 等待时间从4秒开始,指数增长,最长60秒\n stop=stop_after_attempt(5) # 最多重试5次\n )\n def __call__(self, messages: List[Dict[str, str]], model: Optional[str] = None, temperature: float = 0.0,\n max_tokens: int = 500, stop_strs: Optional[List[str]] = None, n: int = 1) -> Union[str, List[str]]:\n \"\"\"\n Call Infinigence AI API to get response with rate limit handling\n\n Args:\n messages: List of input messages, each message is a dict containing role and content\n model: Optional model override\n temperature: Sampling temperature, defaults to 0.0\n max_tokens: Maximum tokens in response, defaults to 500\n stop_strs: Optional list of stop strings\n n: Number of responses to generate, defaults to 1\n\n Returns:\n Union[str, List[str]]: Response text from LLM, either a single string or list of strings\n \"\"\"\n try:\n response = self.client.chat.completions.create(\n model=model or self.model,\n messages=messages,\n temperature=temperature,\n max_tokens=max_tokens,\n stop=stop_strs,\n n=n\n )\n\n if n == 1:\n return response.choices[0].message.content\n else:\n return [choice.message.content for choice in response.choices]\n except Exception as e:\n if \"429\" in str(e):\n logger.warning(\"Rate limit exceeded\")\n else:\n logger.error(f\"Other LLM Error: {e}\")\n raise e\n\n\n\n\n\n\n\nclass LLMClient:\n def __init__(self, api_key=None, model=\"qwen2.5-72b-instruct\", system_message=\"You are a helpful assistant.\"):\n \"\"\"\n 初始化 LLM 客户端实例。\n :param api_key: API 密钥,可以直接传入,也可以从环境变量中读取。\n :param model: 模型名称,默认为 'qwen2.5-72b-instruct'。\n :param system_message: 系统消息,用于设置对话背景。\n \"\"\"\n self.api_key = api_key or os.getenv(\"API_KEY\")\n if not self.api_key:\n raise ValueError(\"API key is required. Please provide it or set it in the environment as 'API_KEY'.\")\n self.model = model\n self.system_message = system_message\n self.client = InfinigenceLLM(api_key=self.api_key, model=model)\n\n def generate_response(self, content, temperature=0.7, max_tokens=150):\n \"\"\"\n 调用模型生成响应。\n :param content: 用户输入的内容。\n :param temperature: 控制生成内容的随机性。\n :param max_tokens: 生成内容的最大 token 数量。\n :return: 模型响应。\n \"\"\"\n # 构建消息格式\n messages = [\n {\"role\": \"system\", \"content\": self.system_message},\n {\"role\": \"user\", \"content\": content}\n ]\n\n try:\n response = self.client(\n messages=messages,\n temperature=temperature,\n max_tokens=max_tokens\n )\n return response\n except Exception as e:\n return f\"Error: {e}\"\n\n\n# 使用示例\nif __name__ == \"__main__\":\n # 如果需要,可直接设置环境变量 API_KEY\n # os.environ[\"API_KEY\"] = \"your_api_key_here\"\n\n # 实例化类\n llm_client = LLMClient() # 或从环境变量中获取\n\n # 用户输入内容\n user_content = \"What is an LLM?\"\n\n # 调用模型生成响应\n response = llm_client.generate_response(content=user_content)\n print(\"Model Response:\", response)\n\n"}}, "docs/pages/overview.html": {"43cd745767b8b5e589a6a25460a13975af722c12": {"t": 1785595503.80511, "n": 28890, "h": "89274d2f67fff5d1", "c": "\n\n\n \n \n Overview - WWW'25 AgentSociety Challenge\n \n \n \n\n\n \n\n \n \n
\n Current Registered Teams: Loading...\n
\n\n \n
\n
\n ×\n

Information Precheck for AgentSociety Challenge

\n

Please note: This form helps prevent duplicate registrations. The email address and team name will be checked against existing registrations.

\n
\n
\n \n \n
\n
\n \n \n Team name must be unique and cannot be changed later\n
\n
\n \n \n Keep this password safe - you'll need it for submissions\n
\n \n
\n
\n
\n\n \n
\n
\n ×\n \n
\n
\n\n
\n
\n

🌏 AgentSociety Challenge

\n
\n \n
\n

\n We are excited to announce the AgentSociety Challenge, a competition for designing large language model (LLM) agents to advance web experience. \n As organizers, we recognize the crucial role online review platforms play in today's web society, serving as vital spaces for experience sharing, \n advice seeking, and social interaction. We have carefully designed two competitive tracks to explore the potential of LLM agents: the User Modeling Track,\n which focuses on understanding user preferences and simulating online reviews, and the Recommendation Track, \n dedicated to delivering personalized recommendations across diverse scenarios. The Challenge utilizes large-scale public datasets from prominent online review platforms, \n complemented by a textual simulator to provide interactive feedback for LLM agents. Through this challenge, \n we aim to drive innovation and breakthrough in the integration of LLM technologies with real-world Web applications.\n

\n\n

📍 Problem Statement

\n

\n The participants are tasked to construct agentic workflows with LLM to process information, write reviews, and make recommendations \n by interacting with online review platforms. To facilitate this, we have built an interactive \n simulation environment that allows agents to engage with these platforms in a controlled setting.\n The interactive environment is built based on open-source datasets, including Yelp[1], \n Amazon[2], and Goodreads[3], \n complemented by a textual simulator to provide interactive feedback for agents.\n Specifically, this challenge consists of two tracks: \n

\n

\n

\n Based on the concept of modular agent design, participants are encouraged to adopt an actionable modular design space with four key modules: \n Planning, Reasoning, Tool use, and Memory[4]. \n These modules have standardized interface to allow them cooperate with each other in a workflow: upon receiving a task query, the agent begins by decomposing it into sub-tasks through the Planning module. \n The Reasoning module then processes each sub-task, and when necessary, activates the Tool use module to select external tools for problem-solving. \n Additionally, the Memory module supports the reasoning process by accessing past observations and experiences, ensuring the agent continuously refines its actions based on feedback from the environment. \n Through this modular design approach, participants can not only create effective solutions for this challenge but also contribute reusable modules to the broader agent community, \n fostering innovation and collaboration in agent development.\n

\n\n
\n \n
\n\n

\n As a bonus, the top-ranking teams advancing to the Final Phase will receive assistance in deploying their agents on the OpenCity platform[5]. \n OpenCity is an open-source platform designed to simulate large-scale LLM agents within a digital city environment. \n Solutions submitted to the Recommendation and User Modeling tracks will be adapted to simulate offline movement and online reviews, \n respectively, offering a dynamic illustration of the Agent Society vision. Selected teams will be invited to present their work at the WWW Workshop, \n where they can compete for the Best Demo award.\n \n

\n\n

📅 Timeline

\n

\n The competition will be held from Jan 1st, 2025 to Feb 14th, 2025, following the timeline outlined below: \n

\n Note: All submission deadlines are end-of-day in the Anywhere on Earth (AoE) time zone. Top 20 teams will be selected to participate in the Final Phase.\n

\n\n

💪🏻 Token Support

\n

\n To support participants, we will provide API-key access during the development phase. \n This will be offered through InfinigenceAI, with the following specifications: RPM=100, TPM=60000, RPD=10000, and the ability to call models such as Qwen-72b-instruct. \n If you wish to use the API, please send your identification documents via email. \n Required documents include your full name, organization, proof of participation in this competition, track of participation and any other relevant identification details. \n Once your verification is completed, we will send you the API key. Please note that the number of API keys is limited.\n

\n\n

🏆 Award

\n

\n The total prize pool is 12,000 USD. To encourage and reward excellence, \n the competition will offer monetary prizes and certificates to top-3 winning teams of each track:\n

\n Besides, challenge prizes also include the in-person travel grant for the top 2 winning teams each track. \n This remuneration is to be paid after the in-person presentation in our workshop the Web Conference:\n \n We will recommend 1st & 2nd place of each track to submit a competition-related papers for inclusion in the conference's companion proceedings.\n

\n\n

🏪 Organizing Committee

\n

\n Hosting Organization: Tsinghua University, Infinigence AI, the Web Conference\n


\n

\n Committee Members: Yuwei Yan (HKUST-gz); Yu Shang, Qingbing Zeng, Yu Li, Keyu Zhao, Zhiheng Zheng, Xuefei Ning (Tsinghua University); Tianji Wu, Shengen Yan (Infinigence AI)\n


\n

\n Committee Chair: Fengli Xu, Yu Wang, Yong Li (Tsinghua University)\n

\n\n

📬 Contact

\n

\n For any questions or inquiries, please contact us at LLMSociety-Challenge@outlook.com.\n

\n\n

📚 Reference

\n
    \n
  1. \n Nabiha Asghar. \n Yelp dataset challenge: Review rating prediction. \n arXiv preprint arXiv:1605.05362, 2016. \n [arXiv]\n
  2. \n
  3. \n Yupeng Hou, Jiacheng Li, Zhankui He, An Yan, Xiusi Chen, Julian McAuley. \n Bridging Language and Items for Retrieval and Recommendation. \n arXiv preprint arXiv:2403.03952, 2024.\n [arXiv]\n
  4. \n
  5. \n Mengting Wan, Julian J. McAuley. \n Item recommendation on monotonic behavior chains. \n In Proceedings of the 12th ACM Conference on Recommender Systems (RecSys 2018), \n Vancouver, BC, Canada, October 2-7, 2018, pp. 86–94. ACM, 2018. \n [DOI]\n
  6. \n
  7. \n Yu Shang, Yu Li, Keyu Zhao, Likai Ma, Jiahe Liu, Fengli Xu, Yong Li. \n AgentSquare: Automatic LLM Agent Search in Modular Design Space. \n arXiv preprint arXiv:2410.06153, 2024. \n [arXiv].\n
  8. \n
  9. \n Yuwei Yan, Qingbin Zeng, Zhiheng Zheng, Jingzhe Yuan, Jie Feng, Jun Zhang, Fengli Xu, Yong Li. \n OpenCity: A Scalable Platform to Simulate Urban Activities with Massive LLM Agents. \n arXiv preprint arXiv:2410.21286, 2024. \n [arXiv].\n
  10. \n
\n
\n
\n\n \n\n\n"}}}}