Spaces:
No application file
No application file
File size: 4,502 Bytes
b043e7b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 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 | {
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyOKqfSVq+Brmr4ZM+kUh/HP",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/SkywalkerDarren/chatWeb/blob/master/example.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"把下面换成你自己的openai key,然后依次执行下列准备步骤\n",
"Please replace the following with your own OpenAI API key, and language, and then execute the following preparation steps in order:"
],
"metadata": {
"id": "2rmPdzNs13ga"
}
},
{
"cell_type": "code",
"source": [
"open_ai_key = \"sk-xxxxxxxxxxxx\" # Your OpenAI API key\n",
"language = \"Chinese\" # Language of the chatbot"
],
"metadata": {
"id": "roZqoNX0ubG5"
},
"execution_count": 8,
"outputs": []
},
{
"cell_type": "code",
"source": [
"%%shell\n",
"# Ubuntu no longer distributes chromium-browser outside of snap\n",
"#\n",
"# Proposed solution: https://askubuntu.com/questions/1204571/how-to-install-chromium-without-snap\n",
"\n",
"# Add debian buster\n",
"cat > /etc/apt/sources.list.d/debian.list <<'EOF'\n",
"deb [arch=amd64 signed-by=/usr/share/keyrings/debian-buster.gpg] http://deb.debian.org/debian buster main\n",
"deb [arch=amd64 signed-by=/usr/share/keyrings/debian-buster-updates.gpg] http://deb.debian.org/debian buster-updates main\n",
"deb [arch=amd64 signed-by=/usr/share/keyrings/debian-security-buster.gpg] http://deb.debian.org/debian-security buster/updates main\n",
"EOF\n",
"\n",
"# Add keys\n",
"apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DCC9EFBF77E11517\n",
"apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138\n",
"apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A\n",
"\n",
"apt-key export 77E11517 | gpg --dearmour -o /usr/share/keyrings/debian-buster.gpg\n",
"apt-key export 22F3D138 | gpg --dearmour -o /usr/share/keyrings/debian-buster-updates.gpg\n",
"apt-key export E562B32A | gpg --dearmour -o /usr/share/keyrings/debian-security-buster.gpg\n",
"\n",
"# Prefer debian repo for chromium* packages only\n",
"# Note the double-blank lines between entries\n",
"cat > /etc/apt/preferences.d/chromium.pref << 'EOF'\n",
"Package: *\n",
"Pin: release a=eoan\n",
"Pin-Priority: 500\n",
"\n",
"\n",
"Package: *\n",
"Pin: origin \"deb.debian.org\"\n",
"Pin-Priority: 300\n",
"\n",
"\n",
"Package: chromium*\n",
"Pin: origin \"deb.debian.org\"\n",
"Pin-Priority: 700\n",
"EOF"
],
"metadata": {
"id": "9HBoEHPFvaDv"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!apt-get update\n",
"!apt-get install chromium chromium-driver\n",
"!git clone https://github.com/SkywalkerDarren/chatWeb.git\n",
"%cd chatWeb\n",
"!pip3 install -r requirements.txt"
],
"metadata": {
"id": "71znqup2wrt-"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"import json\n",
"\n",
"with open('config.example.json', 'r') as f:\n",
" config = json.load(f)\n",
"\n",
"config['open_ai_key'] = open_ai_key\n",
"config['language'] = language\n",
"\n",
"with open('config.json', 'w') as f:\n",
" json.dump(config, f)"
],
"metadata": {
"id": "b5kT-S5rt1e6"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"以上是准备步骤,准备完后运行下面这条命令即可,quit以后也可以重复运行\n",
"The above are preparation steps, run the following command after preparation, and you can also run it again after /quit."
],
"metadata": {
"id": "yfJMbmUL1Vfp"
}
},
{
"cell_type": "code",
"source": [
"!python3 main.py"
],
"metadata": {
"id": "gQBKF8cxu3AY"
},
"execution_count": null,
"outputs": []
}
]
}
|