Azure 代码解释器
AzureCodeInterpreterToolSpec #
Bases: BaseToolSpec
Azure 代码解释器工具规范。
利用 Azure 动态会话执行 Python 代码。
源代码位于 llama-index-integrations/tools/llama-index-tools-azure-code-interpreter/llama_index/tools/azure_code_interpreter/base.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
access_token_provider instance-attribute
#
access_token_provider: Callable[[], Optional[str]] = _access_token_provider_factory()
一个返回用于会话池的访问令牌的函数。
session_id instance-attribute
#
session_id: str = session_id or str(uuid4())
用于会话池的会话 ID。默认为一个随机 UUID。
local_save_path instance-attribute
#
local_save_path: Optional[str] = local_save_path
Python 解释器生成的文件本地保存路径。
code_interpreter #
code_interpreter(python_code: str) -> dict
当需要在会话中执行计算或操作时,此工具用于执行 python 命令。输入应为有效的 python 命令。此工具返回结果、stdout 和 stderr。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
python_code
|
str
|
要由 llm 生成并执行的 Python 代码。 |
必需 |
源代码位于 llama-index-integrations/tools/llama-index-tools-azure-code-interpreter/llama_index/tools/azure_code_interpreter/base.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
upload_file #
upload_file(data: Optional[Any] = None, local_file_path: Optional[str] = None) -> List[RemoteFileMetadata]
将文件上传到会话中的 /mnt/data 路径下。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
data
|
Optional[Any]
|
要上传的数据。 |
无
|
local_file_path
|
Optional[str]
|
要上传的本地文件路径。 |
无
|
返回值
类型 | 描述 |
---|---|
List[RemoteFileMetadata]
|
List[RemoteFileMetadata]:上传文件的元数据列表。 |
源代码位于 llama-index-integrations/tools/llama-index-tools-azure-code-interpreter/llama_index/tools/azure_code_interpreter/base.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
download_file_to_local #
download_file_to_local(remote_file_path: str, local_file_path: Optional[str] = None) -> Optional[BufferedReader]
从会话下载文件到本地环境。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
remote_file_path
|
str
|
要下载文件的路径,相对于 |
必需 |
local_file_path
|
Optional[str]
|
保存下载文件的路径。如果未提供,文件将作为 BufferedReader 返回。 |
无
|
返回值
名称 | 类型 | 描述 |
---|---|---|
BufferedReader |
Optional[BufferedReader]
|
下载文件的数据。 |
源代码位于 llama-index-integrations/tools/llama-index-tools-azure-code-interpreter/llama_index/tools/azure_code_interpreter/base.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
list_files #
list_files() -> List[RemoteFileMetadata]
列出会话中的文件。
返回值
类型 | 描述 |
---|---|
List[RemoteFileMetadata]
|
List[RemoteFileMetadata]:会话中文件的元数据。 |
源代码位于 llama-index-integrations/tools/llama-index-tools-azure-code-interpreter/llama_index/tools/azure_code_interpreter/base.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|