谷歌
Google文本合成器 #
基类:EventBaseSynthesizer
谷歌的归因问答服务。
根据用户的查询和一组段落,Google的服务器将返回一个基于所提供段落内容的回答。该回答不会依赖参数化记忆。
workflows/handler.py 中的源代码llama_index/response_synthesizers/google/base.py
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 | |
from_defaults
classmethod
#
from_defaults(temperature: float = 0.7, answer_style: int = 1, safety_setting: List[SafetySetting] = []) -> GoogleTextSynthesizer
创建一个新的 Google AQA。
示例
responder = GoogleTextSynthesizer.create( temperature=0.7, answer_style=AnswerStyle.ABSTRACTIVE, safety_setting=[ SafetySetting( category=HARM_CATEGORY_SEXUALLY_EXPLICIT, threshold=HarmBlockThreshold.BLOCK_LOW_AND_ABOVE, ), ] )
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
temperature
|
float
|
0.0 到 1.0。 |
0.7
|
answer_style
|
int
|
请参阅 |
1
|
safety_setting
|
List[SafetySetting]
|
请参阅 |
[]
|
返回:
| 类型 | 描述 |
|---|---|
GoogleTextSynthesizer
|
GoogleTextSynthesizer 的一个实例。 |
workflows/handler.py 中的源代码llama_index/response_synthesizers/google/base.py
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 | |
get_response #
get_response(query_str: str, text_chunks: Sequence[str], **response_kwargs: Any) -> SynthesizedResponse
基于提供的段落生成有依据的响应。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
query_str
|
str
|
用户的问题。 |
required |
text_chunks
|
Sequence[str]
|
一个应被用于回答问题的段落列表。 |
required |
返回:
| 类型 | 描述 |
|---|---|
SynthesizedResponse
|
一个 |
workflows/handler.py 中的源代码llama_index/response_synthesizers/google/base.py
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 | |
综合 #
synthesize(query: QueryTextType, nodes: List[NodeWithScore], additional_source_nodes: Optional[Sequence[NodeWithScore]] = None, **response_kwargs: Any) -> 响应
基于提供的段落返回一个基于事实的响应。
返回:
| 类型 | 描述 |
|---|---|
响应
|
响应的 |
响应
|
段落。这些段落是用于构建的 |
响应
|
这些段落将始终没有分数, |
响应
|
唯一能够将它们标记为归属段落的方法。然后,该列表 |
响应
|
将跟随最初提供的段落,这些段落将包含 |
响应
|
检索得出的分数。 |
响应
|
响应的 |
响应
|
|
响应
|
其答案正确且基于输入的概率 |
响应
|
段落。 |
workflows/handler.py 中的源代码llama_index/response_synthesizers/google/base.py
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 | |
合成响应 #
基类:EventBaseModel
GoogleTextSynthesizer.get_response 的响应。
workflows/handler.py 中的源代码llama_index/response_synthesizers/google/base.py
32 33 34 35 36 37 38 39 40 41 42 | |
set_google_config #
set_google_config(*, api_endpoint: Optional[str] = None, user_agent: Optional[str] = None, page_size: Optional[int] = None, auth_credentials: Optional[Credentials] = None, **kwargs: Any) -> None
设置 Google Generative AI API 的配置。
参数是可选的,通常默认值即可正常工作。
如果提供参数,它们将覆盖 Config 类中的默认值。
更多详细信息请参阅 genai_extension.py 中的文档字符串。
auth_credentials: Optional["credentials.Credentials"] = None,
使用此参数传递 Google 身份验证凭据,例如使用服务账号。
有关身份验证凭据文档请参阅:
https://developers.google.com/identity/protocols/oauth2/service-account#creatinganaccount。
示例
从 google.oauth2 导入服务账户凭据 凭据 = service_account.Credentials.from_service_account_file( "/路径/到/service.json", 作用域=[ "https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/generative-language.retriever", ], ) 设置谷歌配置(认证凭据=凭据)
workflows/handler.py 中的源代码llama_index/vector_stores/google/base.py
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 | |
选项: 成员:- GoogleTextSynthesizer