| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- from agent import Glm, KeyWordPrompt
- class Agent:
-
- _instance = None
- def __new__(cls):
- if not cls._instance:
- cls._instance = super(Agent, cls).__new__(cls)
- cls._instance._initialized = False
- return cls._instance
-
- def __init__(self):
- if not self._initialized:
- self.glm = Glm()
- self._initialized = True
-
- def brand_key_word_judgement(self, brandname, title):
- """判断是否为关键词引流"""
- self.glm.set_modelname("glm-4-plus")
- prompt = KeyWordPrompt.EXTRACT_INFO_FROM_TITLE + f"""
- 请根据上述逻辑,分析以下商品标题,并输出结果:
- 商品标题:{brandname}
- 给定的引流品牌:{title}"""
-
- response = self.glm.text_response(prompt)
- return response.content
-
- def license_product_judgement(self, title, license_list):
- """判断是否为未授权商品"""
- self.glm.set_modelname("glm-4-plus")
- prompt = KeyWordPrompt.LICENSE_LIST_FILTER + f"""
- 请根据上述逻辑,分析以下商品是否为授权生产的,并输出结果:
- 商品标题: {title}
- 已生产的产品清单:
- ```json
- {license_list}
- ```
- """
- response = self.glm.text_response(prompt)
- return response.content
- if __name__ == "__main__":
- agent = Agent()
- agent.brand_key_word_judgement("【防泼水】荷叶风衣连帽加绒外套防风外套保暖户外运动服女外套", "李宁")
|