Conversant 项目使用教程

Conversant 项目使用教程

sandbox-conversant-lib Conversational AI tooling & personas built on Cohere's LLMs sandbox-conversant-lib 项目地址: https://gitcode.com/gh_mirrors/sa/sandbox-conversant-lib

1. 项目目录结构及介绍

Conversant 项目的目录结构如下:

sandbox-conversant-lib/
├── conversant/
│   ├── __init__.py
│   ├── demo/
│   │   ├── streamlit_example.py
│   ├── personas/
│   │   ├── fortune-teller/
│   │   │   └── config.json
│   │   ├── your-persona-name/
│   │   │   └── config.json
├── docs/
├── static/
├── tests/
├── .gitattributes
├── .gitignore
├── pre-commit-config.yaml
├── CHANGELOG.md
├── CONTRIBUTORS.md
├── LICENSE
├── README.md
├── poetry.lock
├── pyproject.toml

目录结构介绍

  • conversant/: 核心代码目录,包含对话代理的实现和相关配置。
    • demo/: 包含 Streamlit 演示应用的启动文件 streamlit_example.py
    • personas/: 包含不同角色的配置文件 config.json,每个角色一个子目录。
  • docs/: 项目文档目录。
  • static/: 静态资源目录。
  • tests/: 测试代码目录。
  • .gitattributes: Git 属性配置文件。
  • .gitignore: Git 忽略文件配置。
  • pre-commit-config.yaml: 预提交钩子配置文件。
  • CHANGELOG.md: 项目变更日志。
  • CONTRIBUTORS.md: 贡献者指南。
  • LICENSE: 项目许可证。
  • README.md: 项目介绍和使用说明。
  • poetry.lock: Poetry 依赖锁定文件。
  • pyproject.toml: Poetry 项目配置文件。

2. 项目启动文件介绍

Streamlit 演示应用启动文件

文件路径:conversant/demo/streamlit_example.py

该文件是 Streamlit 演示应用的启动文件,用于启动一个基于 Conversant 的对话代理演示应用。用户可以通过该应用与不同的角色进行对话。

启动步骤

  1. 安装 Streamlit:

    pip install streamlit
    
  2. 设置 Cohere API 密钥:

    export COHERE_API_KEY="YOUR_API_KEY_HERE"
    
  3. 启动 Streamlit 应用:

    streamlit run conversant/demo/streamlit_example.py
    

3. 项目配置文件介绍

角色配置文件

文件路径:conversant/personas/your-persona-name/config.json

每个角色的配置文件包含以下内容:

{
  "chatbot_config": {
    "max_context_examples": 5,
    "avatar": "🤖"
  },
  "client_config": {
    "model": "large",
    "max_tokens": 50,
    "temperature": 0.7
  },
  "chat_prompt_config": {
    "preamble": "Description of the persona",
    "example_separator": "<CONVERSATION>\n",
    "headers": {
      "user": "User",
      "bot": "Bot"
    },
    "examples": [
      {
        "user": "Who are you?",
        "bot": "I am a chatbot."
      }
    ]
  }
}

配置文件说明

  • chatbot_config: 对话代理的配置,包括上下文示例的最大长度和角色的头像。
  • client_config: Cohere API 的配置,包括模型类型、最大生成令牌数和温度。
  • chat_prompt_config: 对话提示的配置,包括角色的描述、示例分隔符、用户和机器人的名称以及示例对话。

通过编辑这些配置文件,用户可以自定义不同的对话角色和行为。

sandbox-conversant-lib Conversational AI tooling & personas built on Cohere's LLMs sandbox-conversant-lib 项目地址: https://gitcode.com/gh_mirrors/sa/sandbox-conversant-lib

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

谢月连Jed

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值