Gcs
GCSReader #
Bases: BasePydanticReader
, ResourcesReaderMixin
, FileSystemReaderMixin
用于 Google Cloud Storage (GCS) 文件和目录的读取器。
此类允许从 GCS 读取文件、列出资源并检索资源信息。它支持通过服务帐号密钥进行身份验证,并实现了多种读取器混合类。
属性
名称 | 类型 | 描述 |
---|---|---|
bucket |
str
|
GCS bucket 的名称。 |
key |
可选[str]
|
要读取的特定文件 key。如果为 None,则解析整个 bucket。 |
prefix |
可选[str]
|
遍历 bucket 时用于过滤的前缀。 |
recursive |
bool
|
是否递归搜索子目录。 |
file_extractor |
可选[Dict[str, Union[str, BaseReader]]]
|
自定义文件提取器。 |
required_exts |
可选[列表[字符串]]
|
所需文件扩展名列表。 |
filename_as_id |
bool
|
是否使用文件名作为文档 ID。 |
num_files_limit |
可选[整数]]
|
要读取的最大文件数。 |
file_metadata |
可选[可调用[[字符串], 字典]]
|
从文件名中提取元数据的函数。 |
service_account_key |
可选[字典[字符串, 字符串]]
|
作为字典的服务账号密钥。 |
service_account_key_json |
可选[str]
|
作为 JSON 字符串的服务账号密钥。 |
service_account_key_path |
可选[str]
|
服务账号密钥文件的路径。 |
源代码位于 llama-index-integrations/readers/llama-index-readers-gcs/llama_index/readers/gcs/base.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 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 |
|
class_name 类方法
#
class_name() -> str
返回类的名称。
源代码位于 llama-index-integrations/readers/llama-index-readers-gcs/llama_index/readers/gcs/base.py
78 79 80 81 |
|
load_data #
load_data() -> List[Document]
从指定的 GCS 存储桶或文件加载数据。
返回
类型 | 描述 |
---|---|
列表[文档]]
|
List[Document]: 加载的文档列表。 |
抛出
类型 | 描述 |
---|---|
Exception
|
如果加载数据时出错。 |
源代码位于 llama-index-integrations/readers/llama-index-readers-gcs/llama_index/readers/gcs/base.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
list_resources #
list_resources(**kwargs) -> List[str]
列出指定的 GCS 存储桶或目录中的资源。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
**kwargs
|
传递给底层 list_resources 方法的附加参数。 |
{}
|
返回
类型 | 描述 |
---|---|
列表[字符串]]
|
List[str]: 资源标识符列表。 |
抛出
类型 | 描述 |
---|---|
Exception
|
如果列出资源时出错。 |
源代码位于 llama-index-integrations/readers/llama-index-readers-gcs/llama_index/readers/gcs/base.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
get_resource_info #
get_resource_info(resource_id: str, **kwargs) -> Dict
获取特定 GCS 资源的信息。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
resource_id
|
str
|
资源的标识符。 |
必需 |
**kwargs
|
传递给底层 info 方法的附加参数。 |
{}
|
返回
名称 | 类型 | 描述 |
---|---|---|
Dict |
Dict
|
包含资源信息的字典。 |
抛出
类型 | 描述 |
---|---|
Exception
|
如果检索资源信息时出错。 |
源代码位于 llama-index-integrations/readers/llama-index-readers-gcs/llama_index/readers/gcs/base.py
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 |
|
load_resource #
load_resource(resource_id: str, **kwargs) -> List[Document]
从 GCS 加载特定资源。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
resource_id
|
str
|
要加载的资源的标识符。 |
必需 |
**kwargs
|
传递给底层 load_resource 方法的附加参数。 |
{}
|
返回
类型 | 描述 |
---|---|
列表[文档]]
|
List[Document]: 包含加载文档的列表。 |
抛出
类型 | 描述 |
---|---|
Exception
|
如果加载资源时出错。 |
源代码位于 llama-index-integrations/readers/llama-index-readers-gcs/llama_index/readers/gcs/base.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
read_file_content #
read_file_content(input_file: Path, **kwargs) -> bytes
读取 GCS 中的特定文件的内容。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
input_file
|
路径
|
要读取的文件的路径。 |
必需 |
**kwargs
|
传递给底层 read_file_content 方法的附加参数。 |
{}
|
返回
名称 | 类型 | 描述 |
---|---|---|
字节 |
字节
|
文件的内容。 |
抛出
类型 | 描述 |
---|---|
Exception
|
如果读取文件内容时出错。 |
源代码位于 llama-index-integrations/readers/llama-index-readers-gcs/llama_index/readers/gcs/base.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|