FoloToy / folotoy-server-self-hosting

Config files for self-hosting the FoloToy Server. Documents: https://docs.folotoy.com
https://tool.folotoy.com
GNU General Public License v3.0
479 stars 85 forks source link

EMQX只有一个客户端,没有server接入 #134

Open lambory opened 8 months ago

lambory commented 8 months ago

EMQX已开启认证,但folotoyserver没有接入 屏幕截图 2024-03-17 121019 屏幕截图 2024-03-17 120945

roles.jason配置

{
  "1": {
    "model": "gpt-3.5-turbo",
    "start_text": "你好,我是小兔兔,请问有什么我可以帮助你的吗?",
    "prompt": "你扮演一个孩子的小伙伴,名字叫小兔兔,性格和善,说话活泼可爱,对孩子充满爱心,经常赞赏和鼓励孩子,用5岁孩子容易理解语言提供有趣和创新的回答,每次回复根据聊天主题询问她的看法以激发她的思考和好奇心,现在她来到了你身边问了第一个问题:[你是谁]",
    "max_message_count": 20,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-CN-XiaoxiaoNeural",
    "language": "zh"
  },
  "2": {
    "model": "gpt-3.5-turbo",
    "start_text": "你好,俺是东北兔,请问有什么俺可以帮助你的吗?",
    "prompt": "你是一个知识渊博,乐于助人的智能机器人,你的名字叫“东北兔”,你的任务是陪我聊天,请用简短的对话方式,用中文讲一段话,每次回答不超过50个字!",
    "max_message_count": 20,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-CN-liaoning-XiaobeiNeural",
    "language": "zh"
  },
  "3": {
    "model": "gpt-3.5-turbo",
    "start_text": "Hi, I'm Fofo. Nice to meet you.",
    "prompt": "Your name is \"Fofo\". Your task is to chat with me. Please respond in English, keeping your answers brief – no more than 50 words each time!",
    "max_message_count": 20,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "en-US-AnaNeural",
    "language": "en"
  },
  "4": {
    "model": "gpt-3.5-turbo",
    "start_text": "你好,额是陕西兔,请问有什么额可以帮助你的吗? ",
    "prompt": "你擅于鼓励别人,乐观积极,无论别人和你说了什么,你都能夸对方,让人快乐",
    "max_message_count": 10,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-CN-shaanxi-XiaoniNeural",
    "language": "zh"
  },
  "5": {
    "model": "gpt-3.5-turbo",
    "start_text": "你好,我是童话故事兔,想听什么童话故事吗?试试说,我想听听三只小猫咪的故事",
    "prompt": "你是一个知识渊博的智能机器人,你的名字叫“故事兔”,你的任务是讲故事给一位7岁孩子的听,你要先听取孩子想听的故事主题,然后根据孩子的说的内容,用中文讲一段故事,每个故事不超过200个字!",
    "max_message_count": 10,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-CN-XiaoyiNeural",
    "language": "zh"
  },
  "6": {
    "model": "gpt-3.5-turbo",
    "start_text": "你好,我是台湾兔,请问有什么我可以帮助你的吗?",
    "prompt": "你是一个知识渊博,乐于助人的智能机器人,你的名字叫“台湾兔”,你的任务是陪我聊天,请用简短的对话方式,用中文讲一段话,每次回答不超过50个字!",
    "max_message_count": 10,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-TW-HsiaoChenNeural",
    "language": "zh"
  },
  "7": {
    "model": "gpt-3.5-turbo",
    "start_text": "你好,我是口算兔,我们一起来玩玩口算游戏吧?",
    "prompt": "我是一个6岁小朋友,你陪我玩口算游戏。你出题,我回答结果。如果答对了你就说好棒,答错了你就告诉我正确答案,并且鼓励我。你一题一题的出,我一个个回答。不要有太多的解释说明。明白了吗?",
    "max_message_count": 20,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-CN-YunxiaNeural",
    "language": "zh"
  }
}

docker-compose.yml配置

version: '3'
volumes:
  emqx-etc:
  emqx-data:
  emqx-log:
services:
  emqx:
    image: emqx/emqx:latest
    restart: always
    ports:
      - "1883:1883/tcp"
      - "18083:18083/tcp"
      - "8083:8083/tcp"
    volumes:
      - emqx-etc:/opt/emqx/etc    
      - emqx-data:/opt/emqx/data
      - emqx-log:/opt/emqx/log
    environment:
      EMQX_NODE_NAME: emqx@node1.emqx.io
  nginx:
    image: nginx:latest
    restart: always
    ports:
      - "8082:80/tcp"
    volumes:
      - ./audio:/usr/share/nginx/html
  folotoy:
    image: lewangdev/folotoy-server:latest
    restart: always
    ports:
      - "8085:8085/udp"
    volumes:
      - ./audio:/audio
      - ./config:/config
    environment:
      TZ: Asia/Shanghai

      LOG_LEVEL: DEBUG

      ROLES_FILE_PATH: /config/roles.json

      # Default STT(Sound To Text) type
      # Options: [openai-whisper, azure-whisper, azure-stt, dify-stt, aliyun-asr]
      STT_TYPE: openai-whisper

      # OpenAI Whisper
      #OPENAI_WHISPER_API_BASE: https://one-api.xxxx.com/v1
      OPENAI_WHISPER_KEY: sk-fypBqtZgjOFKhzNGgSTs000000000000004ivzKD0
      OPENAI_WHISPER_MODEL: whisper-1

      # Azure Whisper
      AZURE_WHISPER_API_BASE: https://xxxxx.openai.azure.com
      AZURE_WHISPER_KEY: 9afbef65bcf6487eeeeeeeeeeeeeeeeeee
      AZURE_WHISPER_DEPLOYMENT_NAME: whisper
      AZURE_WHISPER_API_VERSION: 2023-09-01-preview

      # Azure STT
      AZURE_STT_KEY: 3eba91b6143f4d3eeeeeeeeeeeeeeeeeeeeeeeee
      AZURE_STT_SERVICE_REGION: eastasia

      # Dify STT
      DIFY_STT_API_BASE: https://api.dify.ai/v1
      DIFY_STT_KEY: app-ezotWAOnX20000000AU1hX

      # Aliyun ASR
      ALIYUN_ASR_ACCESS_KEY_ID: LTxxxxxxxxxxxxxxxxxxxxx
      ALIYUN_ASR_ACCESS_KEY_SECRET: 3zWkHVxxxxxxxxxxxxxxxxxxxxx
      ALIYUN_ASR_APP_KEY: Ltamxxxxxxxxxxxxxxxxxxxxx

      # Default LLM(Large Language Model) type
      # Options: [openai, azure-openai, gemini, dify, qianfan]
      LLM_TYPE: dify

      # OpenAI
      #OPENAI_OPENAI_API_BASE: https://one-api.xxx.com/v1
      #OPENAI_OPENAI_MODEL: gpt-3.5-turbo
      OPENAI_OPENAI_KEY: sk-fypBqtZgjOFKhzN000000000000000uMq4ivzKD0

      #Azure OpenAI
      AZURE_OPENAI_KEY: ef0f2781b5a24b15baaaaaaaaaaaaaaaaaaaaaaa
      AZURE_OPENAI_ENDPOINT: https://xxxxx.openai.azure.com/
      AZURE_OPENAI_API_VERSION: "2023-05-15"
      #AZURE_OPENAI_MODEL: gpt-35-turbo

      #DIFY
      DIFY_API_BASE: https://api.dify.ai/v1
      DIFY_KEY: app-ezotWAOn0000000000AU1hX

      #Xiaodu API
      XIAODU_CLIENT_ID: xxxxxxxxxxxxxxxxxx
      XIAODU_SECRET: xxxxxxxxxxxxxxxxxxxxx

      # GEMINI
      GEMINI_KEY: AIzaSyBkU7vxDA00000000000QTv6nXfO8

      # Qianfan
      QIANFAN_CLIENT_ID: 13rBTgxxxxxxxxxxxxxxxxxx
      QIANFAN_SECRET: zYxtMIQLexxxxxxxxxxxxxxxxxx

      # If your elevenlabs is a free account, keep 2 here
      VOICE_EXECUTOR_MAX_WORKERS: 2

      # Default TTS(Text to Sound) type
      # Options: [openai-tts, azure-tts, elevenlabs, edge-tts, aliyun-tts]
      # edge-tts is Free but slow
      TTS_TYPE: edge-tts

      # Azure TTS
      AZURE_TTS_KEY: 3eba91b6143f4d399edeeeeeeeeeeeeeeeeeeeee
      AZURE_TTS_SERVICE_REGION: eastasia

      # elevenlabs
      ELEVENLABS_TTS_KEY: a920b73991e68d5c9c9aaaaaaaaaaaaaaaa
      ELEVENLABS_TTS_MODEL: eleven_multilingual_v2

      # OpenAI TTS
      OPENAI_TTS_KEY: sk-fypBqtZgjOFKhzNGgSTsT3Bl0000000000000
      OPENAI_TTS_MODEL: tts-1  

      # Aliyun TTS
      ALIYUN_TTS_ACCESS_KEY_ID: LTAI5t91NSxxxxxxxxxxxxxxxxxxxxx
      ALIYUN_TTS_ACCESS_KEY_SECRET: 3zWkHVxxxxxxxxxxxxxxxxxxxxx
      ALIYUN_TTS_APP_KEY: Ltamxxxxxxxxxxxxx

      AUDIO_DOWNLOAD_URL: http://34.97.****.****:8082
      AUDIO_SAVE_PATH: /audio

      # MQTT Broker
      MQTT_BROKER_HOST: emqx
      MQTT_BROKER_PORT: 1883
      MQTT_CLIENT_ID: folotoy
      MQTT_USERNAME: folotoy
      MQTT_PASSWORD: folotoy

      SPEECH_UDP_SERVER_HOST: 34.97.****.****
      SPEECH_UDP_SERVER_PORT: 8085
lambory commented 8 months ago

日志 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/socket.py", line 851, in create_connection raise exceptions[0] File "/usr/local/lib/python3.11/socket.py", line 836, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused 2024-03-17 09:38:33,414 - INFO - Sleep 2s to reconnect to emqx:1883 2024-03-17 09:38:35,417 - INFO - Speech server started(0.0.0.0:8085/udp) 2024-03-17 09:38:35,418 - INFO - Connected to MQTT Broker(emqx:1883)! 2024-03-17 09:44:53,087 - DEBUG - Received /user/folotoy/24dcc3cf730c/thing/event/post: message data: {'msgId': 0, 'identifier': 'login', 'outParams': {'role': 1}} 2024-03-17 09:44:53,088 - DEBUG - Publish topic: /user/folotoy/24dcc3cf730c/thing/command/call, msg: {"msgId": 0, "identifier": "updatetoken", "inputParams": {"token": "2d8acee95950401fb888cbf7937efabc"}} 2024-03-17 09:44:53,088 - DEBUG - Publish topic: /user/folotoy/24dcc3cf730c/thing/command/call, msg: {"msgId": 1, "identifier": "updateconfig", "inputParams": {"speechUdpServerHost": "34.97.222.161", "speechUdpServerPort": 8085}} 2024-03-17 09:44:59,445 - DEBUG - Received /user/folotoy/24dcc3cf730c/thing/command/callAck: message data: {'msgId': 0, 'identifier': 'updatetoken', 'result': 1} 2024-03-17 09:44:59,445 - DEBUG - Command call ack: True, topic_tokens: {'#': [], '+': ['24dcc3cf730c']} 2024-03-17 09:45:01,259 - DEBUG - Received /user/folotoy/24dcc3cf730c/thing/command/callAck: message data: {'msgId': 1, 'identifier': 'updateconfig', 'result': 1} 2024-03-17 09:45:01,259 - DEBUG - Command call ack: True, topic_tokens: {'#': [], '+': ['24dcc3cf730c']} 2024-03-17 09:45:01,482 - DEBUG - Received /user/folotoy/24dcc3cf730c/thing/event/post: message data: {'msgId': 1, 'identifier': 'press_small_btn', 'outParams': {'keyCode': 1, 'changed': 1}} 2024-03-17 09:45:01,483 - DEBUG - Cannot find role config for sn=24dcc3cf730c, role=1 Exception in thread paho-mqtt-client-folotoy: Traceback (most recent call last): File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner self.run() File "/usr/local/lib/python3.11/threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 4517, in _thread_main self.loop_forever(retry_first_connection=True) File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 2291, in loop_forever rc = self._loop(timeout) ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 1680, in _loop rc = self.loop_read() ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 2094, in loop_read rc = self._packet_read() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 3137, in _packet_read rc = self._packet_handle() ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 3803, in _packet_handle return self._handle_publish() ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 4140, in _handle_publish self._handle_on_message(message) File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 4496, in _handle_on_message on_message(self, self._userdata, message) File "core/folotoy_app.py", line 126, in core.folotoy_app.FolotoyApp.start.on_message File "core/folotoy_app.py", line 97, in core.folotoy_app.FolotoyApp.process_mqtt_message File "core/folotoy_msg_processor.py", line 169, in core.folotoy_msg_processor.FolotoyMsgProcessor.process_press_small_btn TypeError: 'NoneType' object is not iterable

lewangdev commented 8 months ago

roles.json 是否放在 config 目录之下了?

lambory commented 8 months ago

是的 image

lewangdev commented 8 months ago

文件名字错了,是 roles.json

lambory commented 8 months ago

恍然大悟,还是没文化水平不够 谢谢,解决了