文档更新
This commit is contained in:
@@ -48,6 +48,7 @@ retry_interval = 10 # 重试间隔(秒)
|
||||
| `timeout` | ❌ | API请求超时时间(秒) | 30 |
|
||||
| `retry_interval` | ❌ | 重试间隔时间(秒) | 10 |
|
||||
|
||||
**请注意,对于`client_type`为`gemini`的模型,`base_url`字段无效。**
|
||||
### 2.3 支持的服务商示例
|
||||
|
||||
#### DeepSeek
|
||||
@@ -132,6 +133,7 @@ thinking = {type = "disabled"} # 禁用思考
|
||||
```
|
||||
请注意,`extra_params` 的配置应该构成一个合法的TOML字典结构,具体内容取决于API服务商的要求。
|
||||
|
||||
**请注意,对于`client_type`为`gemini`的模型,此字段无效。**
|
||||
### 3.3 配置参数说明
|
||||
|
||||
| 参数 | 必填 | 说明 |
|
||||
|
||||
@@ -24,7 +24,11 @@ def get_available_models() -> Dict[str, TaskConfig]:
|
||||
### 2. 使用模型生成内容
|
||||
```python
|
||||
async def generate_with_model(
|
||||
prompt: str, model_config: TaskConfig, request_type: str = "plugin.generate", **kwargs
|
||||
prompt: str,
|
||||
model_config: TaskConfig,
|
||||
request_type: str = "plugin.generate",
|
||||
temperature: Optional[float] = None,
|
||||
max_tokens: Optional[int] = None,
|
||||
) -> Tuple[bool, str, str, str]:
|
||||
```
|
||||
使用指定模型生成内容。
|
||||
@@ -33,7 +37,29 @@ async def generate_with_model(
|
||||
- `prompt`:提示词。
|
||||
- `model_config`:模型配置对象(从 `get_available_models` 获取)。
|
||||
- `request_type`:请求类型标识,默认为 `"plugin.generate"`。
|
||||
- `**kwargs`:其他模型特定参数,如 `temperature`、`max_tokens` 等。
|
||||
- `temperature`:生成内容的温度设置,影响输出的随机性。
|
||||
- `max_tokens`:生成内容的最大token数。
|
||||
|
||||
**Return:**
|
||||
- `Tuple[bool, str, str, str]`:返回一个元组,包含(是否成功, 生成的内容, 推理过程, 模型名称)。
|
||||
|
||||
### 3. 有Tool情况下使用模型生成内容
|
||||
```python
|
||||
async def generate_with_model_with_tools(
|
||||
prompt: str,
|
||||
model_config: TaskConfig,
|
||||
tool_options: List[Dict[str, Any]] | None = None,
|
||||
request_type: str = "plugin.generate",
|
||||
temperature: Optional[float] = None,
|
||||
max_tokens: Optional[int] = None,
|
||||
) -> Tuple[bool, str, str, str, List[ToolCall] | None]:
|
||||
```
|
||||
使用指定模型生成内容,并支持工具调用。
|
||||
|
||||
**Args:**
|
||||
- `prompt`:提示词。
|
||||
- `model_config`:模型配置对象(从 `get_available_models` 获取)。
|
||||
- `tool_options`:工具选项列表,包含可用工具的配置,字典为每一个工具的定义,参见[tool-components.md](../tool-components.md#属性说明),可用`tool_api.get_llm_available_tool_definitions()`获取并选择。
|
||||
- `request_type`:请求类型标识,默认为 `"plugin.generate"`。
|
||||
- `temperature`:生成内容的温度设置,影响输出的随机性。
|
||||
- `max_tokens`:生成内容的最大token数。
|
||||
@@ -36,7 +36,7 @@ def get_llm_available_tool_definitions():
|
||||
|
||||
**Returns**:
|
||||
- `List[Tuple[str, Dict[str, Any]]]`: 工具定义列表,每个元素为 `(工具名称, 工具定义字典)` 的元组
|
||||
- 其具体定义请参照[tool-components.md](../tool-components.md)中的工具定义格式。
|
||||
- 其具体定义请参照[tool-components.md](../tool-components.md#属性说明)中的工具定义格式。
|
||||
#### 示例:
|
||||
|
||||
```python
|
||||
|
||||
@@ -78,7 +78,7 @@ class MyTool(BaseTool):
|
||||
|
||||
其构造而成的工具定义为:
|
||||
```python
|
||||
{"name": cls.name, "description": cls.description, "parameters": cls.parameters}
|
||||
definition: Dict[str, Any] = {"name": cls.name, "description": cls.description, "parameters": cls.parameters}
|
||||
```
|
||||
|
||||
### 方法说明
|
||||
|
||||
@@ -35,7 +35,7 @@ class APIProvider(ConfigBase):
|
||||
"""确保api_key在repr中不被显示"""
|
||||
if not self.api_key:
|
||||
raise ValueError("API密钥不能为空,请在配置中设置有效的API密钥。")
|
||||
if not self.base_url:
|
||||
if not self.base_url and self.client_type != "gemini":
|
||||
raise ValueError("API基础URL不能为空,请在配置中设置有效的基础URL。")
|
||||
if not self.name:
|
||||
raise ValueError("API提供商名称不能为空,请在配置中设置有效的名称。")
|
||||
|
||||
Reference in New Issue
Block a user