aient 1.0.99__tar.gz → 1.1.0__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.
- {aient-1.0.99/src/aient.egg-info → aient-1.1.0}/PKG-INFO +1 -1
- {aient-1.0.99 → aient-1.1.0}/setup.py +1 -1
- {aient-1.0.99 → aient-1.1.0}/src/aient/core/request.py +4 -1
- {aient-1.0.99 → aient-1.1.0}/src/aient/plugins/read_file.py +63 -4
- {aient-1.0.99 → aient-1.1.0/src/aient.egg-info}/PKG-INFO +1 -1
- {aient-1.0.99 → aient-1.1.0}/LICENSE +0 -0
- {aient-1.0.99 → aient-1.1.0}/MANIFEST.in +0 -0
- {aient-1.0.99 → aient-1.1.0}/README.md +0 -0
- {aient-1.0.99 → aient-1.1.0}/setup.cfg +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/__init__.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/core/.git +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/core/.gitignore +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/core/__init__.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/core/log_config.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/core/models.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/core/response.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/core/test/test_base_api.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/core/test/test_geminimask.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/core/test/test_image.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/core/test/test_payload.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/core/utils.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/models/__init__.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/models/audio.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/models/base.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/models/chatgpt.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/models/claude.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/models/duckduckgo.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/models/gemini.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/models/groq.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/models/vertex.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/plugins/__init__.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/plugins/arXiv.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/plugins/config.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/plugins/excute_command.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/plugins/get_time.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/plugins/image.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/plugins/list_directory.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/plugins/registry.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/plugins/run_python.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/plugins/websearch.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/plugins/write_file.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/prompt/__init__.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/prompt/agent.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/utils/__init__.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/utils/prompt.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient/utils/scripts.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient.egg-info/SOURCES.txt +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient.egg-info/dependency_links.txt +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient.egg-info/requires.txt +0 -0
- {aient-1.0.99 → aient-1.1.0}/src/aient.egg-info/top_level.txt +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_API.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_Deepbricks.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_Web_crawler.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_aiwaves.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_aiwaves_arxiv.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_ask_gemini.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_class.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_claude.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_claude_zh_char.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_ddg_search.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_download_pdf.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_gemini.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_get_token_dict.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_google_search.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_jieba.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_json.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_logging.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_ollama.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_plugin.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_py_run.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_requests.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_search.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_tikitoken.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_token.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_url.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_whisper.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_wildcard.py +0 -0
- {aient-1.0.99 → aient-1.1.0}/test/test_yjh.py +0 -0
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
|
|
4
4
|
|
5
5
|
setup(
|
6
6
|
name="aient",
|
7
|
-
version="1.0
|
7
|
+
version="1.1.0",
|
8
8
|
description="Aient: The Awakening of Agent.",
|
9
9
|
long_description=Path.open(Path("README.md"), encoding="utf-8").read(),
|
10
10
|
long_description_content_type="text/markdown",
|
@@ -322,6 +322,9 @@ async def get_vertex_gemini_payload(request, engine, provider, api_key=None):
|
|
322
322
|
MODEL_ID=original_model,
|
323
323
|
stream=gemini_stream
|
324
324
|
)
|
325
|
+
elif api_key is not None and api_key[2] == ".":
|
326
|
+
url = f"https://aiplatform.googleapis.com/v1/publishers/google/models/{original_model}:{gemini_stream}?key={api_key}"
|
327
|
+
headers.pop("Authorization", None)
|
325
328
|
else:
|
326
329
|
url = "https://{LOCATION}-aiplatform.googleapis.com/v1/projects/{PROJECT_ID}/locations/{LOCATION}/publishers/google/models/{MODEL_ID}:{stream}".format(
|
327
330
|
LOCATION=await location.next(),
|
@@ -1675,4 +1678,4 @@ async def prepare_request_payload(provider, request_data):
|
|
1675
1678
|
|
1676
1679
|
url, headers, payload = await get_payload(request, engine, provider, api_key=provider['api'])
|
1677
1680
|
|
1678
|
-
return url, headers, payload, engine
|
1681
|
+
return url, headers, payload, engine
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
import json
|
3
|
+
import chardet
|
3
4
|
from pdfminer.high_level import extract_text
|
4
5
|
|
5
6
|
from .registry import register_tool
|
@@ -99,9 +100,66 @@ Examples:
|
|
99
100
|
except Exception as e:
|
100
101
|
return f"<read_file error>处理IPython Notebook文件 '{file_path}' 时发生错误: {e}</read_file error>"
|
101
102
|
else:
|
102
|
-
#
|
103
|
-
|
104
|
-
|
103
|
+
# 更新:修改通用文件读取逻辑以支持多种编码
|
104
|
+
# 这部分替换了原有的 else 块内容
|
105
|
+
try:
|
106
|
+
with open(file_path, 'rb') as file: # 以二进制模式读取
|
107
|
+
raw_data = file.read()
|
108
|
+
|
109
|
+
if not raw_data: # 处理空文件
|
110
|
+
text_content = ""
|
111
|
+
else:
|
112
|
+
detected_info = chardet.detect(raw_data)
|
113
|
+
primary_encoding_to_try = detected_info['encoding']
|
114
|
+
confidence = detected_info['confidence']
|
115
|
+
|
116
|
+
decoded_successfully = False
|
117
|
+
|
118
|
+
# 尝试1: 使用检测到的编码 (如果置信度高且编码有效)
|
119
|
+
if primary_encoding_to_try and confidence > 0.7: # 您可以根据需要调整置信度阈值
|
120
|
+
try:
|
121
|
+
text_content = raw_data.decode(primary_encoding_to_try)
|
122
|
+
decoded_successfully = True
|
123
|
+
except (UnicodeDecodeError, LookupError): # LookupError 用于处理无效的编码名称
|
124
|
+
# 解码失败,将尝试后备编码
|
125
|
+
pass
|
126
|
+
|
127
|
+
# 尝试2: UTF-8 (如果第一次尝试失败或未进行)
|
128
|
+
if not decoded_successfully:
|
129
|
+
try:
|
130
|
+
text_content = raw_data.decode('utf-8')
|
131
|
+
decoded_successfully = True
|
132
|
+
except UnicodeDecodeError:
|
133
|
+
# 解码失败,将尝试下一个后备编码
|
134
|
+
pass
|
135
|
+
|
136
|
+
# 尝试3: UTF-16 (如果之前的尝试都失败)
|
137
|
+
# 'utf-16' 会处理带BOM的LE/BE编码。若无BOM,则假定为本机字节序。
|
138
|
+
# chardet 通常能更准确地检测具体的 utf-16le 或 utf-16be。
|
139
|
+
if not decoded_successfully:
|
140
|
+
try:
|
141
|
+
text_content = raw_data.decode('utf-16')
|
142
|
+
decoded_successfully = True
|
143
|
+
except UnicodeDecodeError:
|
144
|
+
# 所有主要尝试都失败
|
145
|
+
pass
|
146
|
+
|
147
|
+
if not decoded_successfully:
|
148
|
+
# 所有尝试均失败后的错误信息
|
149
|
+
detected_str_part = ""
|
150
|
+
if primary_encoding_to_try and confidence > 0.7: # 如果有高置信度的检测结果
|
151
|
+
detected_str_part = f"检测到的编码 '{primary_encoding_to_try}' (置信度 {confidence:.2f}), "
|
152
|
+
elif primary_encoding_to_try: # 如果有检测结果但置信度低
|
153
|
+
detected_str_part = f"低置信度检测编码 '{primary_encoding_to_try}' (置信度 {confidence:.2f}), "
|
154
|
+
|
155
|
+
return f"<read_file error>文件 '{file_path}' 无法解码。已尝试: {detected_str_part}UTF-8, UTF-16。</read_file error>"
|
156
|
+
|
157
|
+
except FileNotFoundError:
|
158
|
+
# 此处不太可能触发 FileNotFoundError,因为函数开头已有 os.path.exists 检查
|
159
|
+
return f"<read_file error>文件 '{file_path}' 在读取过程中未找到。</read_file error>"
|
160
|
+
except Exception as e:
|
161
|
+
# 捕获在此块中可能发生的其他错误,例如未被早期检查捕获的文件读取问题
|
162
|
+
return f"<read_file error>处理通用文件 '{file_path}' 时发生错误: {e}</read_file error>"
|
105
163
|
|
106
164
|
# 返回文件内容
|
107
165
|
return text_content
|
@@ -109,7 +167,8 @@ Examples:
|
|
109
167
|
except PermissionError:
|
110
168
|
return f"<read_file error>没有权限访问文件 '{file_path}'</read_file error>"
|
111
169
|
except UnicodeDecodeError:
|
112
|
-
|
170
|
+
# 更新:修改全局 UnicodeDecodeError 错误信息使其更通用
|
171
|
+
return f"<read_file error>文件 '{file_path}' 包含无法解码的字符 (UnicodeDecodeError)。</read_file error>"
|
113
172
|
except Exception as e:
|
114
173
|
return f"<read_file error>读取文件时发生错误: {e}</read_file error>"
|
115
174
|
|
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
|