agent.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. from agent import Glm, KeyWordPrompt
  2. class Agent:
  3. _instance = None
  4. def __new__(cls):
  5. if not cls._instance:
  6. cls._instance = super(Agent, cls).__new__(cls)
  7. cls._instance._initialized = False
  8. return cls._instance
  9. def __init__(self):
  10. if not self._initialized:
  11. self.glm = Glm()
  12. self._initialized = True
  13. def brand_key_word_judgement(self, brandname, title):
  14. """判断是否为关键词引流"""
  15. self.glm.set_modelname("glm-4-plus")
  16. prompt = KeyWordPrompt.EXTRACT_INFO_FROM_TITLE + f"""
  17. 请根据上述逻辑,分析以下商品标题,并输出结果:
  18. 商品标题:{brandname}
  19. 给定的引流品牌:{title}"""
  20. response = self.glm.text_response(prompt)
  21. return response.content
  22. def license_product_judgement(self, brandname, title):
  23. pass
  24. if __name__ == "__main__":
  25. agent = Agent()
  26. agent.brand_key_word_judgement("【防泼水】荷叶风衣连帽加绒外套防风外套保暖户外运动服女外套", "李宁")