菜单

配置文件系统

相关源文件

Open Interpreter 中的配置文件系统提供了一种灵活的配置机制,使用户能够为特定用例保存、加载和应用不同的设置。该系统允许用户快速切换不同的配置,而无需每次手动更改单个设置。

概述

来源: interpreter/terminal_interface/profiles/profiles.py19-24 interpreter/terminal_interface/profiles/profiles.py31-64

配置文件存储和位置

配置文件存储在由 oi_dir 工具确定的用户特定目录中。配置文件目录结构组织如下

{user_config_dir}/open-interpreter/
└── profiles/
    ├── default.yaml           # User's default profile
    └── {custom_profiles}      # User-created profiles

默认配置文件路径在 Open Interpreter 首次运行时自动创建,根据系统的用户配置目录约定。

默认配置文件随 Open Interpreter 安装一起包含在 interpreter/terminal_interface/profiles/defaults/ 目录中。

来源: interpreter/terminal_interface/profiles/profiles.py16-24

配置文件类型和格式

支持的格式

Open Interpreter 支持三种不同的配置文件格式

格式文件扩展名描述
YAML.yaml, .yml人类可读的配置格式
Python.py直接操作解释器设置的 Python 脚本
JSON.json机器可读的配置格式

默认配置文件

Open Interpreter 附带了针对特定用例的多个内置配置文件

配置文件名称目的关键设置
default.yaml标准配置使用 gpt-4o 模型
fast.yaml快速响应,极少解释使用 gpt-4o-mini 模型
local.py离线操作配置使用本地 LLM 设置
os.py带计算机视觉的操作系统控制启用计算机 API 和操作系统控制功能
vision.yaml图像分析功能启用 gpt-4o 的视觉支持
codestral.py使用 Ollama/codestral 进行本地编码使用 codestral 模型设置 Ollama
llama3.py使用 llama3 进行本地操作使用 llama3 模型设置 Ollama

来源: interpreter/terminal_interface/profiles/defaults/ interpreter/terminal_interface/profiles/profiles.py23-24

配置文件剖析

来源: interpreter/terminal_interface/profiles/defaults/default.yaml interpreter/terminal_interface/profiles/profiles.py212-213

使用配置文件

加载配置文件

配置文件可以通过以下几种方式加载

  1. 命令行界面:

  2. Python API:

配置文件解析

加载配置文件时,系统遵循以下解析顺序

  1. 检查名称是否与默认配置文件匹配(不带扩展名)
  2. 在用户的配置文件目录中查找配置文件
  3. 尝试将输入解释为 URL
  4. 如果未找到配置文件,则抛出异常

来源: interpreter/terminal_interface/profiles/profiles.py31-64 interpreter/terminal_interface/profiles/profiles.py67-120

配置文件如何应用

来源: interpreter/terminal_interface/profiles/profiles.py31-64 interpreter/terminal_interface/profiles/profiles.py145-213

代码中的配置文件组件

配置文件系统由几个协同工作的关键组件组成

来源: interpreter/terminal_interface/profiles/profiles.py31-64 interpreter/terminal_interface/profiles/profiles.py16-28

默认系统消息

配置文件的一个重要方面是系统消息,它指导 LLM 的角色和功能。默认系统消息在核心模块中定义,并且可以被配置文件覆盖

来源: interpreter/core/default_system_message.py1-17 interpreter/terminal_interface/profiles/profiles.py195-201

创建自定义配置文件

用户可以以任何受支持的格式创建自己的配置文件

YAML 配置文件示例

YAML 配置文件包含按层次结构组织的配置设置

Python 配置文件示例

Python 配置文件直接操作解释器对象

来源: interpreter/terminal_interface/profiles/defaults/default.yaml interpreter/terminal_interface/profiles/defaults/local.py

配置文件版本控制和迁移

配置文件系统包含版本跟踪功能,以处理 Open Interpreter 版本之间配置文件结构的变化。当加载过时版本的配置文件时,系统会提供将其迁移到当前格式的选项。

迁移过程

  1. 更新属性名称以匹配当前结构
  2. 将嵌套属性转换为正确的层次结构
  3. 更新已弃用的模型名称(例如,gpt-4 → gpt-4o)
  4. 向配置文件添加版本信息

来源: interpreter/terminal_interface/profiles/profiles.py151-193 interpreter/terminal_interface/profiles/profiles.py216-563

特殊情况:WTF 命令

配置文件系统还支持为 wtf 命令配置,该命令为终端错误提供快速帮助

来源: scripts/wtf.py366-379

与其他系统集成

配置文件系统与 Open Interpreter 的其他几个组件集成

来源: interpreter/terminal_interface/profiles/profiles.py145-213

常见配置文件用例

用例推荐配置文件主要功能
标准开发default.yaml使用 gpt-4o 的平衡设置
离线工作local.py无需互联网连接即可工作
快速响应fast.yaml使用较小模型,极少解释
图像分析vision.yaml启用视觉功能
操作系统自动化os.py带视觉的完整计算机控制
本地低资源llama3.py使用 Ollama 和 llama3 进行本地执行
数据分析snowpark.yml为 Snowflake 数据操作预配置

来源: interpreter/terminal_interface/profiles/defaults/