索引
默认工具函数模式 #
基类:EventBaseModel
默认工具函数模式。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
input
|
str
|
|
required |
workflows/handler.py 中的源代码llama_index/core/tools/types.py
16 17 18 19 | |
工具元数据
dataclass
#
工具元数据(描述: 字符串, 名称: 可选[字符串] = 无, 函数模式: 可选[类型[pydantic.主.基础模型]] = <类>, 直接返回: 布尔值 = 假)
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
description
|
str
|
|
required |
name
|
str | None
|
|
None
|
fn_schema
|
Type[BaseModel] | None
|
|
<class 'llama_index.core.tools.types.DefaultToolFnSchema'>
|
return_direct
|
bool
|
|
False
|
workflows/handler.py 中的源代码llama_index/core/tools/types.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 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 | |
get_name #
get_name() -> str
获取名称。
workflows/handler.py 中的源代码llama_index/core/tools/types.py
55 56 57 58 59 | |
to_openai_function #
to_openai_function() -> Dict[str, Any]
已弃用并由 to_openai_tool 替代。
由模型生成的应调用函数的名称和参数。
workflows/handler.py 中的源代码llama_index/core/tools/types.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
to_openai_tool #
to_openai_tool(skip_length_check: bool = False) -> Dict[str, Any]
前往 OpenAI 工具。
workflows/handler.py 中的源代码llama_index/core/tools/types.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
工具输出 #
基类:EventBaseModel
工具输出。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
blocks
|
List[Annotated[Union[TextBlock, ImageBlock, AudioBlock, DocumentBlock, CachePoint, CitableBlock, CitationBlock], FieldInfo]]
|
|
required |
tool_name
|
str
|
|
required |
raw_input
|
Dict[str, Any]
|
|
required |
raw_output
|
Any
|
|
required |
is_error
|
bool
|
|
False
|
workflows/handler.py 中的源代码llama_index/core/tools/types.py
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 | |
基础工具 #
基类:EventDispatcherSpanMixin
workflows/handler.py 中的源代码llama_index/core/tools/types.py
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 | |
to_langchain_tool #
to_langchain_tool(**langchain_tool_kwargs: Any) -> Tool
致 langchain 工具。
workflows/handler.py 中的源代码llama_index/core/tools/types.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
to_langchain_structured_tool #
to_langchain_structured_tool(**langchain_tool_kwargs: Any) -> StructuredTool
针对 langchain 结构化工具。
workflows/handler.py 中的源代码llama_index/core/tools/types.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
异步基础工具 #
基类:EventBaseTool
基础级别的工具类,向后兼容旧版工具规范,同时支持异步操作。
workflows/handler.py 中的源代码llama_index/core/tools/types.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
调用
abstractmethod
#
call(input: Any) -> ToolOutput
这是应由工具开发者实现的方法。
workflows/handler.py 中的源代码llama_index/core/tools/types.py
225 226 227 228 229 | |
调用
abstractmethod
async
#
acall(input: Any) -> ToolOutput
这是调用方法的异步版本。 工具开发者也应实现一个异步兼容的版本。
workflows/handler.py 中的源代码llama_index/core/tools/types.py
231 232 233 234 235 236 237 | |
基础工具异步适配器 #
基类:EventAsyncBaseTool
允许将同步工具用作异步工具的适配器类。
workflows/handler.py 中的源代码llama_index/core/tools/types.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
adapt_to_async_tool #
adapt_to_async_tool(tool: BaseTool) -> AsyncBaseTool
将同步工具转换为异步工具。
workflows/handler.py 中的源代码llama_index/core/tools/types.py
259 260 261 262 263 264 265 266 | |
选项: 成员:- AsyncBaseTool - BaseToolAsyncAdapter - BaseTool - ToolMetadata - ToolOutput