Browse Source

未授权生产判别

Sherlock1011 1 năm trước cách đây
mục cha
commit
314b0cb850
3 tập tin đã thay đổi với 47 bổ sung5 xóa
  1. 13 2
      agent/agent.py
  2. 27 0
      agent/config.py
  3. 7 3
      webui.py

+ 13 - 2
agent/agent.py

@@ -24,8 +24,19 @@ class Agent:
         response = self.glm.text_response(prompt)
         return response.content
     
-    def license_product_judgement(self, brandname, title):
-        pass
+    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()

+ 27 - 0
agent/config.py

@@ -26,6 +26,33 @@ class KeyWordPrompt:
         ```
     """
     
+    LICENSE_LIST_FILTER = f"""
+        你是一个产品过滤助手,你的任务是根据输入的商品名称和提供的商品清单,判断输入的商品名称是否为清单中的产品。如果是,输出True并返回匹配的产品信息;如果不是,输出False。
+        判断思路:
+        遍历商品清单中的每一个产品。
+        检查输入的商品名称是否与商品清单中某个产品的产品名称在语义上匹配,而不仅仅是完全相同的字符串匹配。
+
+        匹配规则包括:
+        1. 关键词匹配:输入的商品名称和产品名称中包含相同的关键词(如“运动卫衣”、“套头衫”等)。
+        2. 语义相似性:输入的商品名称和产品名称描述的是同一类产品,即使表达方式不同(如“男子运动卫衣”和“男士休闲运动上衣”)。
+        3. 如果找到匹配项,输出True并返回匹配的产品信息;否则输出False。
+        输出结果:
+        - 如果找到匹配项
+        ```json
+        {{
+            "in_list": True,
+            "产品名称": 匹配到的产品名称
+        }}
+        ```
+        
+        - 如果没找到匹配项
+        ```json
+        {{
+            "in_list": False,
+        }}
+        ```
+    """
+    
     
     
 if __name__ == "__main__":

+ 7 - 3
webui.py

@@ -63,10 +63,9 @@ def get_license_list():
             {
                 "产品名称":record["ProductTitle"],
                 "产品分类":record["Category"],
-                "产品分类":record["ProductSeries"]
+                "产品系列":record["ProductSeries"]
             }
         )
-    
     return license_list
     
 
@@ -81,10 +80,15 @@ def check_infringement(title, brandname):
             key_word_falg = False
         
     key_word_judgement = json.loads(agent.brand_key_word_judgement(brandname, title))
+    print(type(agent.license_product_judgement(title, license_list)))
+    license_judgement = json.loads(agent.license_product_judgement(title, license_list))
     key_word_falg = key_word_judgement["key_word_flag"]
+    license_judgement_flag = license_judgement["in_list"]
+    # license_flag = license_judgement["in_list"]
+    print(license_judgement)
     result = f"""
         关键词引流: {key_word_falg}
-    
+        是否为授权生产产品: {license_judgement_flag}
     """
     return result