|
@@ -19,6 +19,13 @@ from huansuan import callzaihuansuan
|
|
|
import json
|
|
import json
|
|
|
import dedata
|
|
import dedata
|
|
|
import chromadb
|
|
import chromadb
|
|
|
|
|
+from feiyong import feiyong_chaogao
|
|
|
|
|
+from pymongo import MongoClient
|
|
|
|
|
+from anzhuangjsj import anzhuangjsj
|
|
|
|
|
+uri="mongodb://owner:Pheecian1@47.101.198.30:27017/baojia"
|
|
|
|
|
+mongoclient=MongoClient(uri)
|
|
|
|
|
+db = mongoclient['baojia']
|
|
|
|
|
+dbcollection=db['qdxm']
|
|
|
print("chroma")
|
|
print("chroma")
|
|
|
client = chromadb.HttpClient(host='47.101.198.30',port=8000)
|
|
client = chromadb.HttpClient(host='47.101.198.30',port=8000)
|
|
|
collection = client.get_or_create_collection(name="tj_de_bge", metadata={'hnsw:search_ef':15})
|
|
collection = client.get_or_create_collection(name="tj_de_bge", metadata={'hnsw:search_ef':15})
|
|
@@ -29,12 +36,12 @@ qita_collection = client.get_or_create_collection(name="tj_qita_bge")
|
|
|
from FlagEmbedding import FlagModel
|
|
from FlagEmbedding import FlagModel
|
|
|
print("model")
|
|
print("model")
|
|
|
azmodel = FlagModel('/mnt/d/Develop/az/az_encoder_only_base_bge-large-zh-v1.5')
|
|
azmodel = FlagModel('/mnt/d/Develop/az/az_encoder_only_base_bge-large-zh-v1.5')
|
|
|
-model = None # FlagModel('/mnt/d/Develop/az/az_encoder_only_base_bge-large-zh-v1.5')
|
|
|
|
|
-cuoshi_model = None #FlagModel('cuoshi_encoder_only_base_bge-large-zh-v1.5/cuoshi_encoder_only_base_bge-large-zh-v1.5')
|
|
|
|
|
|
|
+model = FlagModel('/mnt/d/Develop/bge/test2_encoder_only_base_bge-large-zh-v1.5')
|
|
|
|
|
+cuoshi_model = FlagModel('cuoshi_encoder_only_base_bge-large-zh-v1.5/cuoshi_encoder_only_base_bge-large-zh-v1.5')
|
|
|
from sentence_transformers import CrossEncoder
|
|
from sentence_transformers import CrossEncoder
|
|
|
azce = CrossEncoder('/mnt/d/Develop/az/models/reranker-chinese-macbert-large-gooaq-bce-4/final')
|
|
azce = CrossEncoder('/mnt/d/Develop/az/models/reranker-chinese-macbert-large-gooaq-bce-4/final')
|
|
|
-ce = None #CrossEncoder('/mnt/d/Develop/az/models/reranker-chinese-macbert-large-gooaq-bce/final')
|
|
|
|
|
-cuoshi_ce = None #CrossEncoder('cuoshi_reranker/final')
|
|
|
|
|
|
|
+ce = CrossEncoder('/mnt/d/Develop/celery/final/final')
|
|
|
|
|
+cuoshi_ce = CrossEncoder('cuoshi_reranker/cuoshi_reranker/final')
|
|
|
with open("hunningtu_rule", "r") as f:
|
|
with open("hunningtu_rule", "r") as f:
|
|
|
content = f.read()
|
|
content = f.read()
|
|
|
obj = json.loads(content)
|
|
obj = json.loads(content)
|
|
@@ -297,34 +304,17 @@ def callzaiclarify(data):
|
|
|
return json_string
|
|
return json_string
|
|
|
def callzaidw(A,B):
|
|
def callzaidw(A,B):
|
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
|
- completion = dsclient.chat.completions.create(
|
|
|
|
|
- # 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
|
|
|
|
|
|
|
+ completion = aiclient.chat.completions.create(
|
|
|
model='glm-4.5-air',
|
|
model='glm-4.5-air',
|
|
|
- #model="modelscope.cn/unsloth/GLM-Z1-32B-0414-GGUF",
|
|
|
|
|
- stream=True,
|
|
|
|
|
|
|
+ ##stream=True,
|
|
|
messages=[
|
|
messages=[
|
|
|
{"role": "system", "content": "You are a helpful assistant."},
|
|
{"role": "system", "content": "You are a helpful assistant."},
|
|
|
{"role": "user", "content": " 计量单位可以用名称或者符号表示,常用的符号包括表示米的符号m,表示千米的符号km,表示吨的符号t,表示千克的符号kg,表示平方米的符号m2,表示立方米的符号m3。也有计量单位很宽泛,比如“项”、“次”. 给定一个工作量计量单位,内容为" + A + ",记作A,再给定一个工作量计量单位,内容为" + B + ",记作B。若两个单位相等,请返回A=B。例如,“项”跟“次”是等价的,应返回A=B。若两个单位不相等,但是存在比例换算关系,请返回比例换算关系,例如A单位是m,B单位是10m, 则返回A=0.1*B。再例如,A单位是10m2,B单位是m2,则返回A=10*B。再例如,A单位是m3, B单位是1000m3,则返回A=0.001*B。若两个单位不相等,且不存在比例换算关系,请返回A<>B,例如A单位是m,B单位是m2,一个表示长度,一个表示面积,不存在比例关系,则返回A<>B。 "},
|
|
{"role": "user", "content": " 计量单位可以用名称或者符号表示,常用的符号包括表示米的符号m,表示千米的符号km,表示吨的符号t,表示千克的符号kg,表示平方米的符号m2,表示立方米的符号m3。也有计量单位很宽泛,比如“项”、“次”. 给定一个工作量计量单位,内容为" + A + ",记作A,再给定一个工作量计量单位,内容为" + B + ",记作B。若两个单位相等,请返回A=B。例如,“项”跟“次”是等价的,应返回A=B。若两个单位不相等,但是存在比例换算关系,请返回比例换算关系,例如A单位是m,B单位是10m, 则返回A=0.1*B。再例如,A单位是10m2,B单位是m2,则返回A=10*B。再例如,A单位是m3, B单位是1000m3,则返回A=0.001*B。若两个单位不相等,且不存在比例换算关系,请返回A<>B,例如A单位是m,B单位是m2,一个表示长度,一个表示面积,不存在比例关系,则返回A<>B。 "},
|
|
|
],
|
|
],
|
|
|
- # Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
|
|
|
|
|
- # 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
|
|
|
|
|
- extra_body={"enable_thinking": False},
|
|
|
|
|
- #extra_body={"thinking": {"type": "disabled"}},
|
|
|
|
|
|
|
+ #extra_body={"enable_thinking": False},
|
|
|
|
|
+ extra_body={"thinking": {"type": "disabled"}},
|
|
|
)
|
|
)
|
|
|
- is_answering = False # 是否进入回复阶段
|
|
|
|
|
- print("\n" + "=" * 20 + "思考过程" + "=" * 20)
|
|
|
|
|
- json_string = ""
|
|
|
|
|
- for chunk in completion:
|
|
|
|
|
- delta = chunk.choices[0].delta
|
|
|
|
|
- if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
|
|
|
|
|
- if not is_answering:
|
|
|
|
|
- print(delta.reasoning_content, end="", flush=True)
|
|
|
|
|
- if hasattr(delta, "content") and delta.content:
|
|
|
|
|
- if not is_answering:
|
|
|
|
|
- print("\n" + "=" * 20 + "完整回复" + "=" * 20)
|
|
|
|
|
- is_answering = True
|
|
|
|
|
- json_string = json_string + delta.content#, end="", flush=True)
|
|
|
|
|
- #json_string = completion.choices[0].message.content
|
|
|
|
|
|
|
+ json_string = completion.choices[0].message.content
|
|
|
print(json_string)
|
|
print(json_string)
|
|
|
time.sleep(1)
|
|
time.sleep(1)
|
|
|
completion = simpleclient.chat.completions.create(
|
|
completion = simpleclient.chat.completions.create(
|
|
@@ -508,6 +498,10 @@ def huansuan(input, dw, label):
|
|
|
return 0.1
|
|
return 0.1
|
|
|
if dw1 == '组' and dw2 == '10组':
|
|
if dw1 == '组' and dw2 == '10组':
|
|
|
return 0.1
|
|
return 0.1
|
|
|
|
|
+ if dw1 == '组' and dw2 == '套':
|
|
|
|
|
+ return 1
|
|
|
|
|
+ if dw1 == '组' and dw2 == '10套':
|
|
|
|
|
+ return 0.1
|
|
|
if dw1 == 'm' and dw2 == '100m单线':
|
|
if dw1 == 'm' and dw2 == '100m单线':
|
|
|
return 0.01
|
|
return 0.01
|
|
|
|
|
|
|
@@ -659,7 +653,7 @@ def process_data(data:dict)-> dict:
|
|
|
elif data['bianma'].startswith('030412'):
|
|
elif data['bianma'].startswith('030412'):
|
|
|
result = azcollection.query(query_embeddings=embeddings, n_results=10, where_document={"$contains": "照明器具"})
|
|
result = azcollection.query(query_embeddings=embeddings, n_results=10, where_document={"$contains": "照明器具"})
|
|
|
elif data['bianma'].startswith('030108'):
|
|
elif data['bianma'].startswith('030108'):
|
|
|
- result = azcollection.query(query_embeddings=embeddings, n_results=10, where_document={"$contains": "第一册"})
|
|
|
|
|
|
|
+ result = azcollection.query(query_embeddings=embeddings, n_results=10, where_document={"$contains": "风机"})
|
|
|
elif data['bianma'].startswith('030502007') or data['bianma'].startswith('030502008'):
|
|
elif data['bianma'].startswith('030502007') or data['bianma'].startswith('030502008'):
|
|
|
result = azcollection.query(query_embeddings=embeddings, n_results=10, where_document={"$contains": "布放光缆"})
|
|
result = azcollection.query(query_embeddings=embeddings, n_results=10, where_document={"$contains": "布放光缆"})
|
|
|
elif data['bianma'].startswith('03'):
|
|
elif data['bianma'].startswith('03'):
|
|
@@ -1000,10 +994,23 @@ def process_data(data:dict)-> dict:
|
|
|
replace['04290303']=extra_info
|
|
replace['04290303']=extra_info
|
|
|
else:
|
|
else:
|
|
|
extra_info = "无"
|
|
extra_info = "无"
|
|
|
|
|
+ fy=[]
|
|
|
|
|
+ if data['bianma'].startswith('03') and '超高' in data['tz']:
|
|
|
|
|
+ fy=feiyong_chaogao(data, [label_name[x] for x in selected], aiclient, qwclient, simpleclient)
|
|
|
|
|
+ if len(fy) > 0:
|
|
|
|
|
+ fy = dedata.read_singledexilie2(30, fy[0])
|
|
|
|
|
+ else:
|
|
|
|
|
+ fy = '{}'
|
|
|
|
|
+ if data['bianma'].startswith('031301017'):##安装脚手架搭拆
|
|
|
|
|
+ print(data['bh'])
|
|
|
|
|
+ print(data['name'])
|
|
|
|
|
+ qd=anzhuangjsj(data['name'], data['bh'], dbcollection)
|
|
|
|
|
+ response = requests.post("http://localhost:3000/api/transform", json={'bianma': data['bianma'], 'mc': data['mc'], 'tz': data['tz'], 'dw': data['dw'], 'sl': data['sl'], 'n': data['n'], "extra": extra_info, 'result':qd, 'fuzhu': [], 'replace': replace, 'fy': fy})
|
|
|
|
|
+ return {"result": response.json()}
|
|
|
if '高强螺栓' in extra_info:
|
|
if '高强螺栓' in extra_info:
|
|
|
- response = requests.post("http://localhost:3000/api/transform", json={'bianma': data['bianma'], 'mc': data['mc'], 'tz': data['tz'], 'dw': data['dw'], 'sl': data['sl'], 'n': data['n'], "extra": extra_info, 'result': [], 'fuzhu': fuzhu_selected, 'replace': replace})
|
|
|
|
|
|
|
+ response = requests.post("http://localhost:3000/api/transform", json={'bianma': data['bianma'], 'mc': data['mc'], 'tz': data['tz'], 'dw': data['dw'], 'sl': data['sl'], 'n': data['n'], "extra": extra_info, 'result': [], 'fuzhu': fuzhu_selected, 'replace': replace, 'fy': '{}'})
|
|
|
return {"result": response.json()}
|
|
return {"result": response.json()}
|
|
|
else:
|
|
else:
|
|
|
- response = requests.post("http://localhost:3000/api/transform", json={'bianma': data['bianma'], 'mc': data['mc'], 'tz': data['tz'], 'dw': data['dw'], 'sl': data['sl'], 'n': data['n'], "extra": extra_info, 'result': result, 'fuzhu': fuzhu_selected, 'replace': replace})
|
|
|
|
|
|
|
+ response = requests.post("http://localhost:3000/api/transform", json={'bianma': data['bianma'], 'mc': data['mc'], 'tz': data['tz'], 'dw': data['dw'], 'sl': data['sl'], 'n': data['n'], "extra": extra_info, 'result': result, 'fuzhu': fuzhu_selected, 'replace': replace, 'fy': fy})
|
|
|
return {"result": response.json()}
|
|
return {"result": response.json()}
|
|
|
|
|
|