Upload check_mogo.py
Browse files- check_mogo.py +86 -3
check_mogo.py
CHANGED
|
@@ -10,6 +10,89 @@ def get_mongo_col(col="config_beta"):
|
|
| 10 |
col = db[col] # data_package(7234543961263854561) goods_feature("7234800834201014260")
|
| 11 |
return col
|
| 12 |
|
| 13 |
-
|
| 14 |
-
collection
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
col = db[col] # data_package(7234543961263854561) goods_feature("7234800834201014260")
|
| 11 |
return col
|
| 12 |
|
| 13 |
+
def set_txt2txt_price_config():
|
| 14 |
+
# 拿到 collection 对象
|
| 15 |
+
collection = get_mongo_col() # 默认 col="config_beta"
|
| 16 |
+
|
| 17 |
+
doc = collection.find_one(
|
| 18 |
+
{"name": "txt2txt_price_config"},
|
| 19 |
+
{"_id": 0, "data": 1}
|
| 20 |
+
)
|
| 21 |
+
if not doc:
|
| 22 |
+
raise RuntimeError("找不到配置 document")
|
| 23 |
+
|
| 24 |
+
data = doc["data"]
|
| 25 |
+
|
| 26 |
+
data["us.anthropic.claude-sonnet-4-5-20250929-v1:0"] = {
|
| 27 |
+
"completion_price": 0.015,
|
| 28 |
+
"prompt_price": 0.003,
|
| 29 |
+
"currency": "$"
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
# 3. 一次性把整个 data 写回去
|
| 33 |
+
result = collection.update_one(
|
| 34 |
+
{"name": "txt2txt_price_config"},
|
| 35 |
+
{"$set": {"data": data}}
|
| 36 |
+
)
|
| 37 |
+
print(f"matched={result.matched_count}, modified={result.modified_count}")
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
query = {"name": "txt2txt_price_config"}
|
| 41 |
+
projection = {"_id": 0, "data": 1}
|
| 42 |
+
|
| 43 |
+
doc = collection.find_one(query, projection)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
if doc:
|
| 47 |
+
data_value = doc.get("data")
|
| 48 |
+
print(data_value)
|
| 49 |
+
else:
|
| 50 |
+
print("未找到 name 等于 txt2txt_price_config 的记录")
|
| 51 |
+
|
| 52 |
+
def set_txt2txt_config():
|
| 53 |
+
# 拿到 collection 对象
|
| 54 |
+
collection = get_mongo_col() # 默认 col="config_beta"
|
| 55 |
+
|
| 56 |
+
doc = collection.find_one(
|
| 57 |
+
{"name": "txt2txt_config"},
|
| 58 |
+
{"_id": 0, "data": 1}
|
| 59 |
+
)
|
| 60 |
+
if not doc:
|
| 61 |
+
raise RuntimeError("找不到配置 document")
|
| 62 |
+
|
| 63 |
+
data = doc["data"]
|
| 64 |
+
|
| 65 |
+
data.append({
|
| 66 |
+
"stream_selected": 0,
|
| 67 |
+
"label": "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
|
| 68 |
+
"value": "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
|
| 69 |
+
"wechat_selected": 0,
|
| 70 |
+
"wechat_label": 0,
|
| 71 |
+
"selected": 0,
|
| 72 |
+
"max_tokens": 4000,
|
| 73 |
+
"is_think": 0,
|
| 74 |
+
"web_label": 0,
|
| 75 |
+
"stream_label": 0,
|
| 76 |
+
"manufacturer": "亚马逊"
|
| 77 |
+
})
|
| 78 |
+
|
| 79 |
+
# 3. 一次性把整个 data 写回去
|
| 80 |
+
result = collection.update_one(
|
| 81 |
+
{"name": "txt2txt_config"},
|
| 82 |
+
{"$set": {"data": data}}
|
| 83 |
+
)
|
| 84 |
+
print(f"matched={result.matched_count}, modified={result.modified_count}")
|
| 85 |
+
|
| 86 |
+
query = {"name": "txt2txt_config"}
|
| 87 |
+
projection = {"_id": 0, "data": 1}
|
| 88 |
+
|
| 89 |
+
doc = collection.find_one(query, projection)
|
| 90 |
+
|
| 91 |
+
if doc:
|
| 92 |
+
data_value = doc.get("data")
|
| 93 |
+
print(data_value)
|
| 94 |
+
else:
|
| 95 |
+
print("未找到 name 等于 txt2txt_config 的记录")
|
| 96 |
+
|
| 97 |
+
set_txt2txt_price_config()
|
| 98 |
+
set_txt2txt_config()
|