Commit 1c725847 authored by Yaowentong's avatar Yaowentong

修改模型为豆包2.0 mini

parent c4ef5508
...@@ -1185,50 +1185,67 @@ if __name__ == "__main__": ...@@ -1185,50 +1185,67 @@ if __name__ == "__main__":
# req_list.append(i.get('req_id')) # req_list.append(i.get('req_id'))
# print(req_list) # print(req_list)
# qian_report(15100000026,'2026-06-21','2026-06-21','oral') # qian_report(15100000026,'2026-06-21','2026-06-21','oral')
phone = 18521518364
data_list = bh_utils.query_data( begin = '2026-04-15'
f"select * from geo_commit_task where platform in ('TYQWA','DOUBA') and insertime >1780243200") end = '2026-07-13'
req_list = get_req_id(phone, begin, end)
brand_name1 = '王康医生'
def handle_item(i): brand_name2 = '殷敏毅'
try: req_list_result1 = []
if i.get('comWordsMap'): req_list_result2 = []
i['comWordsMap'] = json.loads(i.get('comWordsMap')) for i in req_list :
if i.get('brandWords'): if i.get('brand_name') == brand_name1:
i['brandWords'] = json.loads(i.get('brandWords')) req_list_result1.append(i.get('req_id'))
if i.get('comWords'): if i.get('brand_name') == brand_name2:
i['comWords'] = json.loads(i.get('comWords')) req_list_result2.append(i.get('req_id'))
if i.get('keywords'): print(f"req_list_result1:{len(req_list_result1)}")
i['keywords'] = json.loads(i.get('keywords'))
if i.get('productWordsMap'): print(req_list_result1)
i['productWordsMap'] = json.loads(i.get('productWordsMap')) print(f"req_list_result2:{len(req_list_result2)}")
print(req_list_result2)
taskId = i.get('taskId') # data_list = bh_utils.query_data(
reqId = i.get('reqId') # f"select * from geo_commit_task where platform in ('TYQWA','DOUBA') and insertime >1780243200")
platform = i.get('platform') #
content_file_path = f'geo/{taskId}/{platform}/context.txt' #
result_file_path = f'geo/{taskId}/{platform}/result.json' # def handle_item(i):
# try:
content = tos_utils.get_string_from_tos(content_file_path) # if i.get('comWordsMap'):
# i['comWordsMap'] = json.loads(i.get('comWordsMap'))
if 'render_ecom_card_widget_' not in content: # if i.get('brandWords'):
return # i['brandWords'] = json.loads(i.get('brandWords'))
logger.success(f"{reqId}----{platform}更新完成") # if i.get('comWords'):
result_content = tos_utils.get_string_from_tos(result_file_path) # i['comWords'] = json.loads(i.get('comWords'))
result_content_json = json.loads(result_content) # if i.get('keywords'):
result_content_json["hasGoods"] = 1 # i['keywords'] = json.loads(i.get('keywords'))
# if i.get('productWordsMap'):
tos_utils.put_string_to_tos(result_file_path, result_content_json) # i['productWordsMap'] = json.loads(i.get('productWordsMap'))
#
if platform == 'TYQWA': # taskId = i.get('taskId')
return qianwen_android_process_original_data(i) # reqId = i.get('reqId')
# platform = i.get('platform')
elif platform == 'DOUBA': # content_file_path = f'geo/{taskId}/{platform}/context.txt'
return doubao_mobile_process_original_data(i) # result_file_path = f'geo/{taskId}/{platform}/result.json'
except Exception as e: #
print(f"{i.get('taskId')} error: {e}") # content = tos_utils.get_string_from_tos(content_file_path)
#
# if 'render_ecom_card_widget_' not in content:
if data_list: # return
with ThreadPoolExecutor(max_workers=50) as executor: # logger.success(f"{reqId}----{platform}更新完成")
list(executor.map(handle_item, data_list)) # result_content = tos_utils.get_string_from_tos(result_file_path)
# result_content_json = json.loads(result_content)
# result_content_json["hasGoods"] = 1
#
# tos_utils.put_string_to_tos(result_file_path, result_content_json)
#
# if platform == 'TYQWA':
# return qianwen_android_process_original_data(i)
#
# elif platform == 'DOUBA':
# return doubao_mobile_process_original_data(i)
# except Exception as e:
# print(f"{i.get('taskId')} error: {e}")
#
#
# if data_list:
# with ThreadPoolExecutor(max_workers=50) as executor:
# list(executor.map(handle_item, data_list))
...@@ -1994,10 +1994,10 @@ def run_data(PAGE_SIZE,MAX_WORKERS): ...@@ -1994,10 +1994,10 @@ def run_data(PAGE_SIZE,MAX_WORKERS):
if __name__ == '__main__': if __name__ == '__main__':
#
data_list = bh_utils.query_data(f"select * from geo_commit_task where status='ING'")
data_list = bh_utils.query_data(f"select * from geo_commit_task where status ='ING' and type !='stream' and platform = 'TXYB'")
def handle_item(i): def handle_item(i):
if i.get('comWordsMap'): if i.get('comWordsMap'):
i['comWordsMap'] = json.loads(i.get('comWordsMap')) i['comWordsMap'] = json.loads(i.get('comWordsMap'))
if i.get('brandWords'): if i.get('brandWords'):
...@@ -2009,13 +2009,12 @@ if __name__ == '__main__': ...@@ -2009,13 +2009,12 @@ if __name__ == '__main__':
if i.get('productWordsMap'): if i.get('productWordsMap'):
i['productWordsMap'] = json.loads(i.get('productWordsMap')) i['productWordsMap'] = json.loads(i.get('productWordsMap'))
type_t = i.get('type') type_t = i.get('type')
type_t = 'batch'
# commit_task(i,'ING') # commit_task(i,'ING')
return task_send_queue(i,type_t) # return task_send_queue(i,type_t)
# return platform_process(i) return platform_process(i)
# #
if data_list: if data_list:
with ThreadPoolExecutor(max_workers=30) as executor: with ThreadPoolExecutor(max_workers=50) as executor:
futures = [executor.submit(handle_item, i) for i in data_list] futures = [executor.submit(handle_item, i) for i in data_list]
for future in as_completed(futures): for future in as_completed(futures):
......
import json import json
import re import re
from aidso_geo.models import spider_save_tos from aidso_geo.models import spider_save_tos
from aidso_geo.models.eco_data_process import save_eco_data_to_bh from aidso_geo.models.eco_data_process import save_eco_data_to_bh
from aidso_geo.utils import robot_utils, bh_utils from aidso_geo.utils import robot_utils, bh_utils
from aidso_geo.utils.ai_interface import get_parse_sse_result from aidso_geo.utils.ai_interface import get_parse_sse_result
from aidso_geo.utils.tos_utils import get_string_from_tos from aidso_geo.utils.tos_utils import get_string_from_tos
def process_price(ori_price): def process_price(ori_price):
price_match = re.search( price_match = re.search(
...@@ -175,7 +178,7 @@ if __name__ == '__main__': ...@@ -175,7 +178,7 @@ if __name__ == '__main__':
# yuanbao_android_process_original_data(file_path2) # yuanbao_android_process_original_data(file_path2)
data_list = bh_utils.query_data( data_list = bh_utils.query_data(
f"select * from geo_commit_task where taskId = '2a7fca28-5389-4506-ad2a-76c222fe424e' and platform = 'TXYBA'") f"select * from geo_commit_task where taskId = '4ae7a6f3-c2a4-4804-9dc2-8f2385674c60' and platform = 'TXYBA'")
# # # # # #
......
...@@ -12,7 +12,7 @@ from aidso_geo.utils.tos_utils import get_string_from_tos ...@@ -12,7 +12,7 @@ from aidso_geo.utils.tos_utils import get_string_from_tos
def ai_get_brand_list(content, prompt): def ai_get_brand_list(content, prompt):
url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions" url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions"
payload = json.dumps({ payload = json.dumps({
"model": "doubao-seed-1-6-250615", "model": "doubao-seed-2-0-mini-260428",
"messages": [ "messages": [
{ {
"role": "system", "role": "system",
...@@ -74,7 +74,7 @@ def ai_get_brand_list(content, prompt): ...@@ -74,7 +74,7 @@ def ai_get_brand_list(content, prompt):
def ai_get_product_list(content, prompt): def ai_get_product_list(content, prompt):
url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions" url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions"
payload = json.dumps({ payload = json.dumps({
"model": "doubao-seed-2-0-lite-260215", "model": "doubao-seed-2-0-mini-260428",
"messages": [ "messages": [
{ {
"role": "system", "role": "system",
...@@ -144,7 +144,7 @@ def ai_get_product_list(content, prompt): ...@@ -144,7 +144,7 @@ def ai_get_product_list(content, prompt):
def ai_get_product_list_search(product_list): def ai_get_product_list_search(product_list):
url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions" url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions"
payload = json.dumps({ payload = json.dumps({
"model": "doubao-seed-1-6-250615", "model": "doubao-seed-2-0-mini-260428",
"messages": [ "messages": [
{ {
"role": "system", "role": "system",
...@@ -211,7 +211,7 @@ def ai_get_brand_name(content): ...@@ -211,7 +211,7 @@ def ai_get_brand_name(content):
# 修正JSON Schema定义:array类型需配置items,同时调整最终期望返回字典格式的提示 # 修正JSON Schema定义:array类型需配置items,同时调整最终期望返回字典格式的提示
payload = json.dumps({ payload = json.dumps({
"model": "doubao-seed-1-6-250615", "model": "doubao-seed-2-0-mini-260428",
"messages": [ "messages": [
{ {
"role": "system", "role": "system",
...@@ -323,23 +323,7 @@ def ai_get_brand_name(content): ...@@ -323,23 +323,7 @@ def ai_get_brand_name(content):
return brand_emotion_dict return brand_emotion_dict
def ai_get_product_sentiment_and_mentions(brand_list, ai_answer_text): def ai_get_product_sentiment_and_mentions(brand_list, ai_answer_text):
"""
入参:
- brand_list: list[str] 品牌列表(顺序很重要)
- ai_answer_text: str AI回答文本
返回:
list[dict],格式:
[
{
"brand_name": "...",
"sentiment": "正向|负向|中性",
"positive_mentions": [...],
"negative_mentions": [...]
},
...
]
"""
url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions" url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions"
...@@ -367,7 +351,7 @@ def ai_get_product_sentiment_and_mentions(brand_list, ai_answer_text): ...@@ -367,7 +351,7 @@ def ai_get_product_sentiment_and_mentions(brand_list, ai_answer_text):
""".strip() """.strip()
payload = { payload = {
"model": "doubao-seed-1-6-250615", "model": "doubao-seed-2-0-mini-260428",
"messages": [ "messages": [
{"role": "system", "content": system_prompt}, {"role": "system", "content": system_prompt},
{ {
...@@ -455,23 +439,7 @@ def ai_get_product_sentiment_and_mentions(brand_list, ai_answer_text): ...@@ -455,23 +439,7 @@ def ai_get_product_sentiment_and_mentions(brand_list, ai_answer_text):
return _fallback_items(brand_list) return _fallback_items(brand_list)
def ai_get_brand_sentiment_and_mentions(brand_list, ai_answer_text): def ai_get_brand_sentiment_and_mentions(brand_list, ai_answer_text):
"""
入参:
- brand_list: list[str] 品牌列表(顺序很重要)
- ai_answer_text: str AI回答文本
返回:
list[dict],格式:
[
{
"brand_name": "...",
"sentiment": "正向|负向|中性",
"positive_mentions": [...],
"negative_mentions": [...]
},
...
]
"""
url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions" url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions"
...@@ -499,7 +467,7 @@ def ai_get_brand_sentiment_and_mentions(brand_list, ai_answer_text): ...@@ -499,7 +467,7 @@ def ai_get_brand_sentiment_and_mentions(brand_list, ai_answer_text):
""".strip() """.strip()
payload = { payload = {
"model": "doubao-seed-1-6-250615", "model": "doubao-seed-2-0-mini-260428",
"messages": [ "messages": [
{"role": "system", "content": system_prompt}, {"role": "system", "content": system_prompt},
{ {
...@@ -594,7 +562,7 @@ def _fallback_items(brand_list): ...@@ -594,7 +562,7 @@ def _fallback_items(brand_list):
def ai_get_product_and_brands(content, prompt): def ai_get_product_and_brands(content, prompt):
url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions" url = "https://ark.cn-beijing.volces.com/api/v3/chat/completions"
payload = json.dumps({ payload = json.dumps({
"model": "doubao-seed-1-6-250615", "model": "doubao-seed-2-0-mini-260428",
"messages": [ "messages": [
{ {
"role": "system", "role": "system",
...@@ -708,35 +676,7 @@ def ai_get_product_and_brands(content, prompt): ...@@ -708,35 +676,7 @@ def ai_get_product_and_brands(content, prompt):
def ai_get_brand_sentiment_and_mentions_by_articles(brand_name, article_list, batch_size=50): def ai_get_brand_sentiment_and_mentions_by_articles(brand_name, article_list, batch_size=50):
"""
入参:
- brand_name: str
单个品牌名,例如: "珂润"
- article_list: list[dict]
文章列表,例如:
[
{"sourceId": "1001", "snippet": "文章内容1..."},
{"sourceId": "1002", "snippet": "文章内容2..."},
...
]
- batch_size: int
每批送给模型的文章数,默认 20
返回:
list[dict],格式:
[
{
"sourceId": "1001",
"brand_name": "珂润",
"sentiment": "正向|负向|中性",
"positive_mentions": [...],
"negative_mentions": [...]
},
...
]
"""
normalized_articles = [] normalized_articles = []
for item in article_list or []: for item in article_list or []:
...@@ -836,7 +776,7 @@ def _call_single_batch(brand_name, batch_articles): ...@@ -836,7 +776,7 @@ def _call_single_batch(brand_name, batch_articles):
] ]
payload = { payload = {
"model": "doubao-seed-1-6-250615", "model": "doubao-seed-2-0-mini-260428",
"messages": [ "messages": [
{"role": "system", "content": system_prompt}, {"role": "system", "content": system_prompt},
{ {
...@@ -996,15 +936,16 @@ if __name__ == '__main__': ...@@ -996,15 +936,16 @@ if __name__ == '__main__':
* **要本地味** → 可以试试**金永丰**,但要注意渠道和日期。 * **要本地味** → 可以试试**金永丰**,但要注意渠道和日期。
* **要最方便** → 去**大润发、家乐福**等大型超市,选择多,品质稳。 * **要最方便** → 去**大润发、家乐福**等大型超市,选择多,品质稳。
""" """
brand_list =['六必居' brand_list =[
'大润发', "瓜子二手车","二手车之家"
'家乐福',
'崔字牌',
'海南金永丰',
'金永丰',
# fcc424e5-58af-494d-9683-5787413a26c9 # fcc424e5-58af-494d-9683-5787413a26c9
] ]
print(ai_get_brand_list(brand_list,content)) ai_response = """
5万左右二手车购买平台推荐
"""
print(ai_get_brand_sentiment_and_mentions(brand_list,ai_response))
# print(ai_result) # print(ai_result)
# pro = # pro =
# ai_get_product_list() # ai_get_product_list()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment