nonebot-plugin-savepic 0.3.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/PKG-INFO +1 -1
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/pic_sql.py +1 -52
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/pyproject.toml +1 -1
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/LICENSE +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/README.md +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/__init__.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/ai_utils.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/config.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/countpic.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/error.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/ext_listener.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/listpic.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/model.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/mvpic.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/networks/__init__.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/networks/resnet_big.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/picture.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/randpic.py +0 -0
- {nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/rule.py +0 -0
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/pic_sql.py
RENAMED
|
@@ -6,7 +6,6 @@ import asyncpg
|
|
|
6
6
|
from nonebot import get_driver
|
|
7
7
|
import dashscope
|
|
8
8
|
import pathlib
|
|
9
|
-
from pinecone import Pinecone, ServerlessSpec
|
|
10
9
|
|
|
11
10
|
from .model import PicData
|
|
12
11
|
from .picture import del_pic
|
|
@@ -20,7 +19,6 @@ from .error import NoPictureException
|
|
|
20
19
|
gdriver = get_driver()
|
|
21
20
|
p_config = Config.parse_obj(gdriver.config)
|
|
22
21
|
_async_database = None
|
|
23
|
-
_pincone_index = None
|
|
24
22
|
_async_embedding_database = None
|
|
25
23
|
|
|
26
24
|
|
|
@@ -64,37 +62,6 @@ async def select_pic(filename: str, group: str):
|
|
|
64
62
|
)
|
|
65
63
|
|
|
66
64
|
|
|
67
|
-
# async def get_most_similar_pic(
|
|
68
|
-
# img_vec: list[float],
|
|
69
|
-
# group_id: str,
|
|
70
|
-
# ignore_diagonal: bool = False,
|
|
71
|
-
# ignore_min: bool = False,
|
|
72
|
-
# ) -> tuple[float, PicData]:
|
|
73
|
-
# async with AsyncSession(_async_database) as db_session:
|
|
74
|
-
# ret = _pincone_index.query(img_vec, top_k=20)["matches"]
|
|
75
|
-
# if not ret:
|
|
76
|
-
# return None, None
|
|
77
|
-
# if not ret[0]["id"]:
|
|
78
|
-
# return None, None
|
|
79
|
-
# if ignore_diagonal and ret[0]["score"] >= 0.999:
|
|
80
|
-
# ret.pop(0)
|
|
81
|
-
|
|
82
|
-
# for i in ret:
|
|
83
|
-
# if i["score"] < 0.65 and not ignore_min:
|
|
84
|
-
# return None, None
|
|
85
|
-
# if i["id"]:
|
|
86
|
-
# despic = await db_session.scalar(
|
|
87
|
-
# select(PicData)
|
|
88
|
-
# .where(PicData.id == int(i["id"]))
|
|
89
|
-
# .where(PicData.name != "")
|
|
90
|
-
# .where(sa.or_(PicData.group == group_id, PicData.group == "globe"))
|
|
91
|
-
# )
|
|
92
|
-
# if despic:
|
|
93
|
-
# return i["score"], despic
|
|
94
|
-
|
|
95
|
-
# return None, None
|
|
96
|
-
|
|
97
|
-
|
|
98
65
|
async def savepic(
|
|
99
66
|
filename: str,
|
|
100
67
|
url: str,
|
|
@@ -173,7 +140,6 @@ async def delete(filename: str, group: str):
|
|
|
173
140
|
del_pic(pic.url)
|
|
174
141
|
pic.name = ""
|
|
175
142
|
await db_session.merge(pic)
|
|
176
|
-
# _pincone_index.delete(ids=[str(pic.id)])
|
|
177
143
|
await _async_embedding_database.execute(
|
|
178
144
|
"UPDATE savepic_word2vec SET embedding = NULL WHERE id = $1", pic.id
|
|
179
145
|
)
|
|
@@ -307,7 +273,7 @@ async def listpic(reg: str, group: str = "globe", pages: int = 0) -> list[str]:
|
|
|
307
273
|
|
|
308
274
|
async def init_db():
|
|
309
275
|
# check if the table exists
|
|
310
|
-
global _async_database,
|
|
276
|
+
global _async_database, _async_embedding_database
|
|
311
277
|
_async_database = create_async_engine(
|
|
312
278
|
p_config.savepic_sqlurl,
|
|
313
279
|
future=True,
|
|
@@ -355,22 +321,6 @@ async def init_db():
|
|
|
355
321
|
)
|
|
356
322
|
)
|
|
357
323
|
|
|
358
|
-
if not p_config.pinecone_apikey:
|
|
359
|
-
raise Exception("请配置 pinecone_apikey")
|
|
360
|
-
if not p_config.pinecone_environment:
|
|
361
|
-
raise Exception("请配置 pinecone_environment")
|
|
362
|
-
|
|
363
|
-
pc = Pinecone(api_key=p_config.pinecone_apikey)
|
|
364
|
-
if p_config.pinecone_index not in pc.list_indexes().names():
|
|
365
|
-
pc.create_index(
|
|
366
|
-
name=p_config.pinecone_index,
|
|
367
|
-
dimension=1536,
|
|
368
|
-
metric="euclidean",
|
|
369
|
-
spec=ServerlessSpec(cloud="aws", region="us-west-2"),
|
|
370
|
-
)
|
|
371
|
-
if not _pincone_index:
|
|
372
|
-
_pincone_index = pc.Index(p_config.pinecone_index)
|
|
373
|
-
|
|
374
324
|
|
|
375
325
|
@gdriver.on_startup
|
|
376
326
|
async def _():
|
|
@@ -393,7 +343,6 @@ async def _():
|
|
|
393
343
|
# .where(PicData.name != "")
|
|
394
344
|
# )
|
|
395
345
|
# if pic:
|
|
396
|
-
# _pincone_index.upsert([(str(pic.id), files[i])])
|
|
397
346
|
# print(f"{pic.name} 加载成功")
|
|
398
347
|
# except Exception as ex:
|
|
399
348
|
# print(ex)
|
|
File without changes
|
|
File without changes
|
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/__init__.py
RENAMED
|
File without changes
|
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/ai_utils.py
RENAMED
|
File without changes
|
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/config.py
RENAMED
|
File without changes
|
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/countpic.py
RENAMED
|
File without changes
|
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/error.py
RENAMED
|
File without changes
|
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/ext_listener.py
RENAMED
|
File without changes
|
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/listpic.py
RENAMED
|
File without changes
|
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/model.py
RENAMED
|
File without changes
|
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/mvpic.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/picture.py
RENAMED
|
File without changes
|
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/randpic.py
RENAMED
|
File without changes
|
{nonebot_plugin_savepic-0.3.0 → nonebot_plugin_savepic-0.3.1}/nonebot_plugin_savepic/rule.py
RENAMED
|
File without changes
|