XMWAI 0.1.6__tar.gz → 0.1.8__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.

Potentially problematic release.


This version of XMWAI might be problematic. Click here for more details.

Files changed (105) hide show
  1. xmwai-0.1.8/MANIFEST.in +2 -0
  2. {xmwai-0.1.6/XMWAI.egg-info → xmwai-0.1.8}/PKG-INFO +1 -1
  3. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/__init__.py +2 -1
  4. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/core.py +30 -20
  5. xmwai-0.1.8/XMWAI/idiom_core.py +54 -0
  6. {xmwai-0.1.6 → xmwai-0.1.8/XMWAI.egg-info}/PKG-INFO +1 -1
  7. {xmwai-0.1.6 → xmwai-0.1.8}/setup.py +1 -1
  8. xmwai-0.1.6/MANIFEST.in +0 -1
  9. xmwai-0.1.6/XMWAI/idiom_core.py +0 -64
  10. {xmwai-0.1.6 → xmwai-0.1.8}/LICENSE.txt +0 -0
  11. {xmwai-0.1.6 → xmwai-0.1.8}/README.md +0 -0
  12. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/bomb_core.py +0 -0
  13. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/0.gif +0 -0
  14. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/1.gif +0 -0
  15. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/10.gif +0 -0
  16. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/11.gif +0 -0
  17. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/12.gif +0 -0
  18. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/13.gif +0 -0
  19. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/14.gif +0 -0
  20. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/15.gif +0 -0
  21. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/16.gif +0 -0
  22. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/17.gif +0 -0
  23. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/18.gif +0 -0
  24. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/19.gif +0 -0
  25. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/2.gif +0 -0
  26. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/20.gif +0 -0
  27. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/21.gif +0 -0
  28. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/22.gif +0 -0
  29. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/23.gif +0 -0
  30. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/24.gif +0 -0
  31. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/25.gif +0 -0
  32. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/26.gif +0 -0
  33. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/27.gif +0 -0
  34. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/28.gif +0 -0
  35. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/29.gif +0 -0
  36. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/3.gif +0 -0
  37. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/30.gif +0 -0
  38. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/31.gif +0 -0
  39. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/32.gif +0 -0
  40. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/33.gif +0 -0
  41. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/34.gif +0 -0
  42. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/35.gif +0 -0
  43. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/36.gif +0 -0
  44. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/37.gif +0 -0
  45. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/38.gif +0 -0
  46. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/39.gif +0 -0
  47. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/4.gif +0 -0
  48. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/40.gif +0 -0
  49. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/41.gif +0 -0
  50. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/42.gif +0 -0
  51. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/43.gif +0 -0
  52. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/44.gif +0 -0
  53. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/45.gif +0 -0
  54. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/46.gif +0 -0
  55. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/47.gif +0 -0
  56. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/48.gif +0 -0
  57. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/49.gif +0 -0
  58. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/5.gif +0 -0
  59. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/50.gif +0 -0
  60. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/51.gif +0 -0
  61. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/52.gif +0 -0
  62. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/53.gif +0 -0
  63. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/54.gif +0 -0
  64. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/55.gif +0 -0
  65. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/56.gif +0 -0
  66. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/57.gif +0 -0
  67. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/58.gif +0 -0
  68. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/59.gif +0 -0
  69. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/6.gif +0 -0
  70. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/60.gif +0 -0
  71. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/61.gif +0 -0
  72. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/62.gif +0 -0
  73. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/63.gif +0 -0
  74. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/64.gif +0 -0
  75. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/65.gif +0 -0
  76. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/66.gif +0 -0
  77. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/67.gif +0 -0
  78. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/68.gif +0 -0
  79. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/69.gif +0 -0
  80. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/7.gif +0 -0
  81. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/70.gif +0 -0
  82. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/71.gif +0 -0
  83. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/72.gif +0 -0
  84. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/73.gif +0 -0
  85. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/74.gif +0 -0
  86. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/75.gif +0 -0
  87. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/76.gif +0 -0
  88. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/77.gif +0 -0
  89. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/78.gif +0 -0
  90. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/79.gif +0 -0
  91. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/8.gif +0 -0
  92. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/80.gif +0 -0
  93. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/81.gif +0 -0
  94. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/82.gif +0 -0
  95. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/83.gif +0 -0
  96. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/84.gif +0 -0
  97. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/85.gif +0 -0
  98. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/9.gif +0 -0
  99. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/gif/__init__.py +0 -0
  100. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI/magic_core.py +0 -0
  101. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI.egg-info/SOURCES.txt +0 -0
  102. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI.egg-info/dependency_links.txt +0 -0
  103. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI.egg-info/requires.txt +0 -0
  104. {xmwai-0.1.6 → xmwai-0.1.8}/XMWAI.egg-info/top_level.txt +0 -0
  105. {xmwai-0.1.6 → xmwai-0.1.8}/setup.cfg +0 -0
@@ -0,0 +1,2 @@
1
+ recursive-include XMWAI/gif *
2
+ include XMAI/idiom.json
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: XMWAI
3
- Version: 0.1.6
3
+ Version: 0.1.8
4
4
  Summary: Small code King AI related library
5
5
  Home-page: https://github.com/Tonykai88/XMWAI.git
6
6
  Author: pydevelopment
@@ -1,5 +1,6 @@
1
1
  from .core import story, photo, reply, poem, get_access_token # 从子模块导入函数到顶层
2
2
  from .magic_core import birthday # 从子模块导入函数到顶层
3
3
  from .bomb_core import bomb # 从子模块导入函数到顶层
4
+ from .idiom_core import idiom,searchIdiom # 从子模块导入函数到顶层
4
5
 
5
- __all__ = ["story", "photo", "reply", "poem", "get_access_token", 'birthday', 'bomb'] # 可选:明确导出的内容
6
+ __all__ = ["story", "photo", "reply", "poem", "get_access_token", 'birthday', 'bomb', "idiom", "searchIdiom"] # 可选:明确导出的内容
@@ -184,24 +184,34 @@ def poem(title, key=""):
184
184
  elif key != "CaJQ":
185
185
  print("秘钥错误!请重新输入!")
186
186
  return "秘钥错误!请重新输入!"
187
- key = "ZZC"
188
- access_token = get_access_token(key)
189
- if access_token:
190
- url = f"https://aip.baidubce.com/rpc/2.0/nlp/v1/poem?access_token={access_token}"
191
- payload = {
192
- "text": title, # 直接使用普通字符串
193
- }
194
- headers = {
195
- 'Content-Type': 'application/json',
196
- 'Accept': 'application/json'
197
- }
187
+ messagesList = [
188
+ {
189
+ "role": "system",
190
+ "content": "唐代诗人"
191
+ },
192
+ {
193
+ "role": "user",
194
+ "content": f"请以《{title}》为题,创作一首七言绝句,每句7个字,一共4句,符合古诗韵律规范,内容积极乐观向上,适合中小学生阅读,不要解析,不要题目,不要标点符号,所有文字放在一行"
195
+ }
196
+ ]
198
197
 
199
- # 直接发送JSON对象,不转换为字符串
200
- response = requests.post(url, headers=headers, json=payload)
201
- if response.status_code == 200:
202
- return response.json()['poem'][0]['content'] # 使用response.json()直接解析JSON响应
203
- else:
204
- print("Failed with status code:", response.status_code)
205
- print("Response:", response.text)
206
- else:
207
- print("Failed to get access token.")
198
+ url = "https://qianfan.baidubce.com/v2/chat/completions"
199
+
200
+ payload = json.dumps({
201
+ "model": "ernie-4.5-turbo-32k",
202
+ "messages": messagesList
203
+ }, ensure_ascii=False)
204
+ headers = {
205
+ 'Content-Type': 'application/json',
206
+ 'appid': '',
207
+ 'Authorization': 'Bearer bce-v3/ALTAK-cGbxpVA5AbSz6h8nbLaFh/b539762075d55c76d93dc78bcf0a91beeaf0490a'
208
+ }
209
+
210
+ response = requests.request("POST", url, headers=headers, data=payload.encode("utf-8"))
211
+
212
+ response_data = json.loads(response.text)
213
+ content = response_data["choices"][0]["message"]["content"]
214
+ content.replace(" ", "")
215
+ content.replace("\n", "")
216
+ content.replace(" ", "")
217
+ return content
@@ -0,0 +1,54 @@
1
+ import random
2
+ import json
3
+ from importlib.resources import files
4
+ from pathlib import Path
5
+
6
+
7
+ def get_json_path():
8
+ """获取 idiom.json 的正确路径(兼容 PyPI 安装后的包内资源)"""
9
+ return Path(files("XMWAI").joinpath("idiom.json"))
10
+
11
+
12
+ def idiom(word, mode=0):
13
+ """
14
+ 查询成语信息
15
+ :param word: 要查询的成语
16
+ :param mode: 查询模式
17
+ 0 - 判断是否是成语,返回 True/False
18
+ 1 - 返回拼音
19
+ 2 - 返回解释
20
+ 3 - 返回出处
21
+ :return: 查询结果或 None
22
+ """
23
+ with open(get_json_path(), "r", encoding="utf-8") as f:
24
+ data = json.load(f)
25
+ for i in data:
26
+ if word == i["word"]:
27
+ if mode == 0:
28
+ return True
29
+ elif mode == 1:
30
+ return i["pinyin"]
31
+ elif mode == 2:
32
+ return i["explanation"]
33
+ elif mode == 3:
34
+ return i["derivation"]
35
+ return False if mode == 0 else None
36
+
37
+
38
+ def searchIdiom(text, num=1):
39
+ """
40
+ 模糊查询成语
41
+ :param text: 要查询的字
42
+ :param num: 第几个字(1~4)
43
+ :return: 匹配的成语 或 False
44
+ """
45
+ wordList = []
46
+ with open(get_json_path(), "r", encoding="utf-8") as f:
47
+ data = json.load(f)
48
+ for i in data:
49
+ try:
50
+ if text == i["word"][num - 1]:
51
+ wordList.append(i["word"])
52
+ except:
53
+ pass
54
+ return random.choice(wordList) if wordList else False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: XMWAI
3
- Version: 0.1.6
3
+ Version: 0.1.8
4
4
  Summary: Small code King AI related library
5
5
  Home-page: https://github.com/Tonykai88/XMWAI.git
6
6
  Author: pydevelopment
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="XMWAI", # 包名(pip install XMWAI)
5
- version="0.1.6", # 初始版本号
5
+ version="0.1.8", # 初始版本号
6
6
  author="pydevelopment", # 作者
7
7
  author_email="hekai@xiaoma.cn", # 邮箱
8
8
  description="Small code King AI related library", # 简短描述
xmwai-0.1.6/MANIFEST.in DELETED
@@ -1 +0,0 @@
1
- recursive-include XMWAI/gif *
@@ -1,64 +0,0 @@
1
- import random
2
-
3
- import json
4
-
5
-
6
- def idiom(word, mode=0):
7
- """
8
- 查询成语信息
9
- :param word: 要查询的成语
10
- :param mode: 查询模式
11
- 0 - 判断是否是成语,返回 True/False
12
- 1 - 返回拼音
13
- 2 - 返回解释
14
- 3 - 返回出处
15
- :return: 查询结果或 None
16
- """
17
- if mode == 0:
18
- with open("idiom.json", "r", encoding="utf-8") as f:
19
- data = json.load(f)
20
- for i in data:
21
- if word == i["word"]:
22
- return True
23
- return False
24
- elif mode == 1:
25
- with open("idiom.json", "r", encoding="utf-8") as f:
26
- data = json.load(f)
27
- for i in data:
28
- if word == i["word"]:
29
- return i["pinyin"]
30
- return None
31
-
32
- elif mode == 2:
33
- with open("idiom.json", "r", encoding="utf-8") as f:
34
- data = json.load(f)
35
- for i in data:
36
- if word == i["word"]:
37
- return i["explanation"]
38
- return None
39
- elif mode == 3:
40
- with open("idiom.json", "r", encoding="utf-8") as f:
41
- data = json.load(f)
42
- for i in data:
43
- if word == i["word"]:
44
- return i["derivation"]
45
- return None
46
-
47
-
48
- def searchIdiom(text, num=1):
49
- """
50
- 模糊查询成语
51
- :param text: 要查询的字
52
- :param mode: 第几个字
53
- :return: 查询结果 或 None
54
- """
55
- wordList = []
56
- with open("idiom.json", "r", encoding="utf-8") as f:
57
- data = json.load(f)
58
- for i in data:
59
- if text == i["word"][num-1]:
60
- wordList.append(i["word"])
61
- if wordList:
62
- return random.choice(wordList)
63
- else:
64
- return False
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes