Coder Social home page Coder Social logo

telegram-chatgpt-concierge-bot's Introduction

Telegram ChatGPT Concierge Bot (+ Voice!)

Deploy on Railway

Telegram ChatGPT Concierge Bot

This is a Telegram bot that uses:

  • OpenAI's ChatGPT, obviously, as "the brain"
  • LangchainJS to constructs prompts, handle convo history and interact with Google
  • OpenAI's Whisper API to generate text from voice
  • Play.ht to generate voice from text and reply to voice messages

How to use

Prerequisite: You need Node 18, a Telegram bot token and an OpenAI API key with access to GPT-4. Optionally you can use other model by setting OPENAI_MODEL env var. Ask ChatGPT how to get these. You'll also need ffmpeg installed to use voice interactions.

  1. git clone https://github.com/RafalWilinski/telegram-chatgpt-concierge-bot
  2. cd telegram-chatgpt-concierge-bot
  3. touch .env and fill the following:
TELEGRAM_TOKEN=
OPENAI_API_KEY=
PLAY_HT_SECRET_KEY=
PLAY_HT_USER_ID=
PLAY_HT_VOICE= # check docs for available voices https://playht.github.io/api-docs-generator/#utra-realistic-voices
OPENAI_MODEL=gpt-3.5-turbo # only if you don't have access to GPT-4
#SERVE_THIS_USER_ONLY=99999999 # uncomment this if you want to only serve this user id. The ID will be printed on stdout.
  1. npm install
  2. npm start

Consulting

I, @RafalWilinski (creator of this repo), offer consulting. If you are interested on hiring weekly hours with me on a retainer, feel free to email me at [email protected]


Follow me on Twitter

Discuss on Twitter or HackerNews

Sponsored by ChatWithCloud

telegram-chatgpt-concierge-bot's People

Contributors

lorrylockie avatar mipmip avatar rafalwilinski avatar sebrut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telegram-chatgpt-concierge-bot's Issues

"You exceeded your current quota (...)" - Incorrect error reporting

I'm getting '{"message":"You exceeded your current quota, please check your plan and billing details.","type":"insufficient_quota","param":null,"code":null}' on every message. I've double-checked the token and the account and my plan/billing seems fine.

Then as an experiment I put in an incorrect token and still got the same message - so it seems like this is what one gets in case of any error.

My specific problem seems to be #8 (see discussion there)

Google Search Tool throws error

Bot crashes as soon as it tries to perform a Google search:

telegram-chatgpt-concierge-bot/node_modules/googlethis/lib/core/main.js:70 throw new Utils.SearchError('Could not execute search', { ^ SearchError: Could not execute search at Object.search (/home/other_projects/telegram-chatgpt-concierge-bot/node_modules/googlethi/lib/core/main.js:70:11) at processTicksAndRejections (node:internal/process/task_queues:95:5) { info: { status_code: 0, message: 'Request failed with status code 429' }, date: 2023-04-10T14:41:33.375Z, version: '1.7.1' }

Why does that happen?

Also, if it does happen, wouldn't it be better to let ChatGPT handle the error? Like, having the tool answer "Sorry, Google unavailable", so GPT can answer based on its own knowledge (maybe with a little disclaimer that it wasn't able to perform the search)?

Initailizes, but fails when posting request to openai.

I changed the model to 3.5 to get around the waitlist, the bot initilizes, bu the server crashes when posting request to openai. here is the logs.

const { Input } = require("telegraf")

Healthcheck server listening on port undefined
Bot started
Input: Input
Entering new agent_executor chain...
(node: 20924) ExperimentalWarning: The Fetch API is an experimental feature.This feature could change at any time
    (Use`node --trace-warnings ...` to show where the warning was created)
Unhandled error while processing {
    update_id: 794716571,
        message: {
        message_id: 10,
            from: {
            id: 142483133,
                is_bot: false,
                    first_name: '',
                        last_name: '',
                            username: '',
                                language_code: 'en'
        },
        chat: {
            id: 142483133,
                first_name: '',
                    last_name: '',
                        username: 'username',
                            type: 'private'
        },
        date: 1681136303,
            text: 'text'
    }
}
/home/ / telegram - chatgpt - concierge - bot / node_modules / langchain / dist / util / axios - fetch - adapter.cjs: 313
return new axios_1.default.AxiosError(message, axios_1.default.AxiosError[code], config, request, response);
               ^
    AxiosError: Request failed with status code 404
    at createError(/home/ / telegram - chatgpt - concierge - bot / node_modules / langchain / dist / util / axios - fetch - adapter.cjs: 313: 16)
    at settle(/home/ / telegram - chatgpt - concierge - bot / node_modules / langchain / src / util / axios - fetch - adapter.js: 47: 3)
at / home /  / telegram - chatgpt - concierge - bot / node_modules / langchain / dist / util / axios - fetch - adapter.cjs: 181: 19
    at new Promise(<anonymous>)
    at fetchAdapter (/home//telegram-chatgpt-concierge-bot/node_modules/langchain/dist/util/axios-fetch-adapter.cjs:173:12)
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
        config: {
        transitional: {
        silentJSONParsing: true,
    forcedJSONParsing: true,
    clarifyTimeoutError: false
    },
    adapter: [AsyncFunction: fetchAdapter],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    validateStatus: [Function: validateStatus],
    headers: {
        Accept: 'application/json, text/plain, */*',
    'Content-Type': 'application/json',
    'User-Agent': 'OpenAI/NodeJS/3.2.1',
    Authorization: 'Bearer sk-'
    },
    method: 'post',
    data: '{"model":"gpt-4","temperature":1,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"max_tokens":4000,"n":1,"stop":["Observation:"],"stream":false,"messages":[{"role":"system","content":"Assistant is a large language model trained by OpenAI.\\n\\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\\n\\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\\n\\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist."},{"role":"user","content":"TOOLS\\n------\\nAssistant can ask the user to use tools to look up information that may be helpful in answering the users original question. The tools the human can use are:\\n\\nGoogle Search Tool: This is Google. Use this tool to search the internet. Input should be a string\\n\\nRESPONSE FORMAT INSTRUCTIONS\\n----------------------------\\n\\nWhen responding to me please, please output a response in one of two formats:\\n\\n**Option 1:**\\nUse this if you want the human to use a tool.\\nMarkdown code snippet formatted in the following schema:\\n\\n```json\\n{\\n    \\"action\\": string \\\\ The action to take. Must be one of Google Search Tool\\n    \\"action_input\\": string \\\\ The input to the action\\n}\\n```\\n\\n**Option #2:**\\nUse this if you want to respond directly to the human. Markdown code snippet formatted in the following schema:\\n\\n```json\\n{\\n    \\"action\\": \\"Final Answer\\",\\n    \\"action_input\\": string \\\\ You should put what you want to return to use here\\n}\\n```\\n\\nUSER\'S INPUT\\n--------------------\\nHere is the user\'s input (remember to respond with a markdown code snippet of a json blob with a single action, and NOTHING else):\\n\\nLG Sunni"}]}',
    url: 'https://api.openai.com/v1/chat/completions'
  },
    request: Request {
        [Symbol(realm)]: {settingsObject: [Object] },
    [Symbol(state)]: {
        method: 'POST',
    localURLsOnly: false,
    unsafeRequest: false,
    body: [Object],
    client: [Object],
    reservedClient: null,
    replacesClientId: '',
    window: 'client',
    keepalive: false,
    serviceWorkers: 'all',
    initiator: '',
    destination: '',
    priority: null,
    origin: 'client',
    policyContainer: 'client',
    referrer: 'client',
    referrerPolicy: '',
    mode: 'cors',
    useCORSPreflightFlag: false,
    credentials: 'same-origin',
    useCredentials: false,
    cache: 'default',
    redirect: 'follow',
    integrity: '',
    cryptoGraphicsNonceMetadata: '',
    parserMetadata: '',
    reloadNavigation: false,
    historyNavigation: false,
    userActivation: false,
    taintedOrigin: false,
    redirectCount: 0,
    responseTainting: 'basic',
    preventNoCacheCacheControlHeaderModification: false,
    done: false,
    timingAllowFailed: false,
    headersList: [HeadersList],
    urlList: [Array],
    url: [URL]
    },
    [Symbol(signal)]: AbortSignal {
        [Symbol(kEvents)]: [SafeMap [Map]],
    [Symbol(events.maxEventTargetListeners)]: 10,
    [Symbol(events.maxEventTargetListenersWarned)]: false,
    [Symbol(kAborted)]: false,
    [Symbol(kReason)]: undefined,
    [Symbol(realm)]: [Object]
    },
    [Symbol(headers)]: Headers {
        [Symbol(headers list)]: [HeadersList],
    [Symbol(guard)]: 'request',
    [Symbol(realm)]: [Object]
    }
  },
    response: {
        ok: false,
    status: 404,
    statusText: 'Not Found',
    headers: Headers {
        [Symbol(headers list)]: [HeadersList],
    [Symbol(guard)]: 'none'
    },
    config: {
        transitional: [Object],
    adapter: [AsyncFunction: fetchAdapter],
    transformRequest: [Array],
    transformResponse: [Array],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    validateStatus: [Function: validateStatus],
    headers: [Object],
    method: 'post',
    data: '{"model":"gpt-4","temperature":1,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"max_tokens":4000,"n":1,"stop":["Observation:"],"stream":false,"messages":[{"role":"system","content":"Assistant is a large language model trained by OpenAI.\\n\\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\\n\\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\\n\\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist."},{"role":"user","content":"TOOLS\\n------\\nAssistant can ask the user to use tools to look up information that may be helpful in answering the users original question. The tools the human can use are:\\n\\nGoogle Search Tool: This is Google. Use this tool to search the internet. Input should be a string\\n\\nRESPONSE FORMAT INSTRUCTIONS\\n----------------------------\\n\\nWhen responding to me please, please output a response in one of two formats:\\n\\n**Option 1:**\\nUse this if you want the human to use a tool.\\nMarkdown code snippet formatted in the following schema:\\n\\n```json\\n{\\n    \\"action\\": string \\\\ The action to take. Must be one of Google Search Tool\\n    \\"action_input\\": string \\\\ The input to the action\\n}\\n```\\n\\n**Option #2:**\\nUse this if you want to respond directly to the human. Markdown code snippet formatted in the following schema:\\n\\n```json\\n{\\n    \\"action\\": \\"Final Answer\\",\\n    \\"action_input\\": string \\\\ You should put what you want to return to use here\\n}\\n```\\n\\nUSER\'S INPUT\\n--------------------\\nHere is the user\'s input (remember to respond with a markdown code snippet of a json blob with a single action, and NOTHING else):\\n\\nLG Sunni"}]}',
    url: 'https://api.openai.com/v1/chat/completions'
    },
    request: Request {
        [Symbol(realm)]: [Object],
    [Symbol(state)]: [Object],
    [Symbol(signal)]: [AbortSignal],
    [Symbol(headers)]: [Headers]
    },
    data: {error: [Object] }
  }
}```

Not able to run project on Ubuntu with given instructions

Hello,

Thank you for creating and sharing this. I saw the entry on Hacker News and tried to run this code but I only get errors.

node version = v18.15.0
npm version = 9.5.0
repository version : d6312ee - Date: Tue Apr 11 11:29:18 2023 +0200

I entered the .env settings details as instructed, both without double quotes and including double quotes for the string values of the API keys. I also tried using GPT 3.5 turbo as instructed on the readme without success.

Any ideas on what I should do ?

Error trace:

root@bot:/opt/telegram-chatgpt-concierge-bot# npm run dev

[email protected] dev

nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts

[nodemon] 2.0.22
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src/**/*.ts
[nodemon] watching extensions: ts,json
[nodemon] starting `ts-node src/index.ts`


Healthcheck server listening on port undefined
Bot started
Input:  who is elon musk?
Entering new agent_executor chain...
AxiosError: Request failed with status code 404
    at createError (/opt/telegram-chatgpt-concierge-bot/node_modules/langchain/dist/util/axios-fetch-adapter.cjs:313:16)
    at settle (/opt/telegram-chatgpt-concierge-bot/node_modules/langchain/src/util/axios-fetch-adapter.js:47:3)
    at /opt/telegram-chatgpt-concierge-bot/node_modules/langchain/dist/util/axios-fetch-adapter.cjs:181:19
    at new Promise (<anonymous>)
    at fetchAdapter (/opt/telegram-chatgpt-concierge-bot/node_modules/langchain/dist/util/axios-fetch-adapter.cjs:173:12)
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    adapter: [AsyncFunction: fetchAdapter],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    validateStatus: [Function: validateStatus],
    headers: {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'application/json',
      'User-Agent': 'OpenAI/NodeJS/3.2.1',
      Authorization: 'Bearer sk-REMOVED-FOR-PRIVACY...........'
    },
    method: 'post',
    data: '{"model":"gpt-4","temperature":1,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"max_tokens":4000,"n":1,"stop":["Observation:"],"stream":false,"messages":[{"role":"system","content":"Assistant is a large language model trained by OpenAI.\\n\\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\\n\\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\\n\\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist."},{"role":"user","content":"TOOLS\\n------\\nAssistant can ask the user to use tools to look up information that may be helpful in answering the users original question. The tools the human can use are:\\n\\nGoogle Search Tool: This is Google. Use this tool to search the internet. Input should be a string\\n\\nRESPONSE FORMAT INSTRUCTIONS\\n----------------------------\\n\\nWhen responding to me please, please output a response in one of two formats:\\n\\n**Option 1:**\\nUse this if you want the human to use a tool.\\nMarkdown code snippet formatted in the following schema:\\n\\n```json\\n{\\n    \\"action\\": string \\\\ The action to take. Must be one of Google Search Tool\\n    \\"action_input\\": string \\\\ The input to the action\\n}\\n```\\n\\n**Option #2:**\\nUse this if you want to respond directly to the human. Markdown code snippet formatted in the following schema:\\n\\n```json\\n{\\n    \\"action\\": \\"Final Answer\\",\\n    \\"action_input\\": str


  },
  request: Request {
    [Symbol(realm)]: { settingsObject: [Object] },
    [Symbol(state)]: {
      method: 'POST',
      localURLsOnly: false,
      unsafeRequest: false,
      body: [Object],
      client: [Object],
      reservedClient: null,
      replacesClientId: '',
      window: 'client',
      keepalive: false,
      serviceWorkers: 'all',
      initiator: '',
      destination: '',
      priority: null,
      origin: 'client',
      policyContainer: 'client',
      referrer: 'client',
      referrerPolicy: '',
      mode: 'cors',
      useCORSPreflightFlag: false,
      credentials: 'same-origin',
      useCredentials: false,
      cache: 'default',
      redirect: 'follow',
      integrity: '',
      cryptoGraphicsNonceMetadata: '',
      parserMetadata: '',
      reloadNavigation: false,
      historyNavigation: false,
      userActivation: false,
      taintedOrigin: false,
      redirectCount: 0,
      responseTainting: 'basic',
      preventNoCacheCacheControlHeaderModification: false,
      done: false,
      timingAllowFailed: false,
      headersList: [HeadersList],
      urlList: [Array],
      url: [URL]
    },
    [Symbol(signal)]: AbortSignal { aborted: false },
    [Symbol(headers)]: HeadersList {
      cookies: null,
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    }
  },
  response: {
    ok: false,
    status: 404,
    statusText: 'Not Found',
    headers: HeadersList {
      cookies: null,
      [Symbol(headers map)]: [Map],
      [Symbol(headers map sorted)]: null
    },
    config: {
      transitional: [Object],
      adapter: [AsyncFunction: fetchAdapter],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      validateStatus: [Function: validateStatus],
      headers: [Object],
      method: 'post',
      data: '{"model":"gpt-4","temperature":1,"top_p":1,"frequency_penalty":0,"presence_penalty":0,"max_tokens":4000,"n":1,"stop":["Observation:"],"stream":false,"messages":[{"role":"system","content":"Assistant is a large language model trained by OpenAI.\\n\\nAssistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\\n\\nAssistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based on the input it receives, allowing it to engage in discussions and provide explanations and descriptions on a wide range of topics.\\n\\nOverall, Assistant is a powerful system that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist."},{"role":"user","content":"TOOLS\\n------\\nAssistant can ask the user to use tools to look up information that may be helpful in answering the users original question. The tools the human can use are:\\n\\nGoogle Search Tool: This is Google. Use this tool to search the internet. Input should be a string\\n\\nRESPONSE FORMAT INSTRUCTIONS\\n----------------------------\\n\\nWhen responding to me please, please output a response in one of two formats:\\n\\n**Option 1:**\\nUse this if you want the human to use a tool.\\nMarkdown code snippet formatted in the following schema:\\n\\n```json\\n{\\n    \\"action\\": string \\\\ The action to take. Must be one of Google Search Tool\\n    \\"action_input\\": string \\\\ The input to the action\\n}\\n```\\n\\n**Option #2:**\\nUse this if you want to respond directly to the human. Markdown code snippet formatted in the following schema:\\n\\n```json\\n{\\n    \\"action\\": \\"Final Answer\\",\\n    \\"action_input\\": string \\\\ You should put what you want to return to use here\\n}\\n```\\n\\nUSER\'S INPUT\\n--------------------\\nHere is the user\'s input (remember to respond with a markdown code snippet of a json blob with a single action, and NOTHING else):\\n\\nwho is elon musk?"}]}',
      url: 'https://api.openai.com/v1/chat/completions'
    },
    request: Request {
      [Symbol(realm)]: [Object],
      [Symbol(state)]: [Object],
      [Symbol(signal)]: [AbortSignal],
      [Symbol(headers)]: [HeadersList]
    },
    data: { error: [Object] }
  }
}

Headers is not defined issue

I'm getting the following issue (maybe I'm missing something):

[WARN] Importing from 'langchain/chat_models' is deprecated. Import from eg. 'langchain/chat_models/openai' instead. See https://js.langchain.com/docs/getting-started/install#updating-from-0052 for upgrade instructions.
Healthcheck server listening on port undefined
Bot started
Input: Help
Entering new agent_executor chain...
Unhandled error while processing {
update_id: 858617076,
message: {
message_id: 3,
from: {
id: 5402165287,
is_bot: false,
first_name: '',
last_name: '
',
username: '',
language_code: 'en'
},
chat: {
id: 5402165287,
first_name: '
',
last_name: '',
username: '
',
type: 'private'
},
date: 1681169988,
text: 'Help'
}
}
(node:28132) UnhandledPromiseRejectionWarning: ReferenceError: Headers is not defined
at createRequest (C:\Users*\telegram-chatgpt-concierge-bot\node_modules\langchain\dist\util\axios-fetch-adapter.cjs:239:21)
at fetchAdapter (C:\Users*\telegram-chatgpt-concierge-bot\node_modules\langchain\dist\util\axios-fetch-adapter.cjs:170:21)
at dispatchRequest (C:\Users*\telegram-chatgpt-concierge-bot\node_modules\openai\node_modules\axios\lib\core\dispatchRequest.js:58:10)
at Axios.request (C:\Users*\telegram-chatgpt-concierge-bot\node_modules\openai\node_modules\axios\lib\core\Axios.js:108:15)
at Function.wrap [as request] (C:\Users\Jc\telegram-chatgpt-concierge-bot\node_modules\openai\node_modules\axios\lib\helpers\bind.js:9:15)
at C:\Users*\telegram-chatgpt-concierge-bot\node_modules\openai\dist\common.js:149:22
at C:\Users*\telegram-chatgpt-concierge-bot\node_modules\openai\dist\api.js:1738:133
at async RetryOperation._fn (C:\Users*\telegram-chatgpt-concierge-bot\node_modules\p-retry\index.js:50:12)
(Use node --trace-warnings ... to show where the warning was created)
(node:28132) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 13)
(node:28132) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

cant apt get zbar shared lib

'm building a railway project using zbar and pyzbar. When i try to deploy the railway project the app crashes due to not finding shared zbar library.

I tried adding "libzbar0 libzbar-dev" to the "NIXPACKS_APT_PKGS" variable and it seems to do the apt gets in the build logs but it still cant find zbar during deployment. Error: "ImportError: Unable to find zbar shared library". Please help

I also tried adding
"[setup]
nixPkgs = ["...", "zbar"]"
to the railway.toml file

429 From OpenAPI

Hi there! Awesome project, really cool use of AI!
I am having some issues getting it running though. I always get this error when sending a message.

/telegram-chatgpt-concierge-bot/node_modules/openai/node_modules/axios/lib/core/createError.js:16
  var error = new Error(message);
              ^
Error: Request failed with status code 429

I have added my card to OpenAPI and already pay for ChatGPT Plus so not sure why I am getting this.
Interesting to note that OpenAPI doesn't see that the API key has ever been used.

Thanks again for the great project.

Add a user ID filter

Right now anyone with the bots name can talk to it and use the expensive APIs.

It would be neat to be able to specify a list of telegram userids and/or groups that are allowed to speak to the bot.

error when running on Raspberry pi 4, armv7

[email protected] start

ts-node src/index.ts

papa@raspberrypi2:~/telegram-chatgpt-concierge-bot $ /home/papa/telegram-chatgpt-concierge-bot/node_modules/langchain/dist/agents/executor.cjs:48
input.returnIntermediateSteps ?? this.returnIntermediateSteps;
^

SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Object.require.extensions. [as .js] (/home/papa/telegram-chatgpt-concierge-bot/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/home/papa/telegram-chatgpt-concierge-bot/node_modules/langchain/src/agents/index.ts:24:13)
at Module._compile (internal/modules/cjs/loader.js:999:30)
npm ERR! code 1
npm ERR! path /home/papa/telegram-chatgpt-concierge-bot
npm ERR! command failed
npm ERR! command sh -c ts-node src/index.ts

npm ERR! A complete log of this run can be found in:
npm ERR! /home/papa/.npm/_logs/2023-04-18T07_40_55_333Z-debug.log

can anyone help please?

SyntaxError: Unexpected identifier - import axios from './lib/axios.js';

~/telegram-chatgpt-concierge-bot$ npm start

> [email protected] start /home/dante/telegram-chatgpt-concierge-bot
> ts-node src/index.ts

telegram-chatgpt-concierge-bot/node_modules/axios/index.js:1
import axios from './lib/axios.js';
       ^^^^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Object.require.extensions.(anonymous function) [as .js] (/home/dante/telegram-chatgpt-concierge-bot/node_modules/ts-node/src/index.ts:1608:43)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/dante/telegram-chatgpt-concierge-bot/src/lib/downloadVoiceFile.ts:4:1)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `ts-node src/index.ts`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!    2023-04-10T10_13_25_914Z-debug.log

Can I use other tts services?

Thanks to rafal, railway has been successfully set up, if I want to use azure or tencent tts, which part of the project should I modify?

How can we switch between prompts (a.k.a personalities)?

For example how can we switch between the prompt based on the personality the user wants to select. I used ChatGPT to whip something up - let me know if it's in the right direction or how I can improve it:

Step 1: Define the personalities

// Add the following code snippet inside your index.ts file

const personalities = [
  { name: 'Family', prompt: 'Conversation prompt for family personality' },
  { name: 'Job Interview', prompt: 'Conversation prompt for job interview personality' },
  { name: 'Friend', prompt: 'Conversation prompt for friend personality' },
  { name: 'Travel', prompt: 'Conversation prompt for travel personality' },
];

Step 2: Modify the /start command

// Modify the existing /start command handler in your index.ts file

bot.start((ctx) => {
  const personalityButtons = personalities.map((personality) => ({
    text: personality.name,
    callback_data: `personality:${personality.name}`,
  }));

  ctx.reply("Welcome to my Telegram bot! Please choose a personality:", {
    reply_markup: {
      inline_keyboard: [personalityButtons],
    },
  });
});

Step 3: Handle the /personality command

bot.command("personality", (ctx) => {
  const personalityButtons = personalities.map((personality) => ({
    text: personality.name,
    callback_data: `personality:${personality.name}`,
  }));

  ctx.reply("Choose a new personality:", {
    reply_markup: {
      inline_keyboard: [personalityButtons],
    },
  });
});

Step 4: Modify the message handling logic

// Modify the existing message handler in your index.ts file

bot.on("message", async (ctx) => {
  const text = (ctx.message as any).text;
  const selectedPersonality = getUserSelectedPersonality(ctx.message.chat.id);

  let prompt = '';

  if (selectedPersonality) {
    const selectedPersonalityData = personalities.find(
      (personality) => personality.name === selectedPersonality
    );
    prompt = selectedPersonalityData.prompt;
  }

  // Use the selected personality prompt as part of the input to the AI model
  const input = `${prompt} ${text}`;

  // Call the AI model with the updated input
  const response = await model.call(input);

  // Handle the response based on the selected personality or other conditions
  if (selectedPersonality === 'Family') {
    // Handle family personality-specific behavior
    // ...
  } else if (selectedPersonality === 'Job Interview') {
    // Handle job interview personality-specific behavior
    // ...
  } else {
    // Default behavior for other personalities
    // ...
  }

  // Send the response back to the user
  await ctx.reply(response);
});

Step 5: Implement personality-specific behaviors

// Inside the message handling logic, add conditional statements based on the selected personality

if (selectedPersonality === 'Family') {
  // Handle family personality-specific behavior
  // ...
} else if (selectedPersonality === 'Job Interview') {
  // Handle job interview personality-specific behavior
  // ...
} else {
  // Default behavior for other personalities
  // ...
}

Step 6: Test and iterate
Test your bot and gather user feedback. Based on the feedback, make any necessary adjustments or improvements to the code or behavior of each personality.

Note: You'll need to implement the getUserSelectedPersonality function to retrieve the selected personality for a user from a session or a database.

Please adapt the code to fit your specific implementation, and make sure to handle error cases and edge cases appropriately.

Whoops! There was an error while talking to OpenAI. Error: "Unable to extract error"

Hi,

I've deployed to railway and changed gpt 4 to gpt-3.5-turbo.

i can send one message to the telegram bot and it'll respond. but the second message i get this error on Telegram:

"Whoops! There was an error while talking to OpenAI. Error: "Unable to extract error"

On Raleway, these are the error logs:

at ChatConversationalAgent.extractToolAndInput (/app/node_modules/langchain/dist/agents/chat_convo/index.cjs:125:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ChatConversationalAgent._plan (/app/node_modules/langchain/src/agents/agent.ts:262:13)
at async AgentExecutor._call (/app/node_modules/langchain/src/agents/executor.ts:77:8)
at async AgentExecutor.call (/app/node_modules/langchain/src/chains/base.ts:96:18)
{ message: '"Unable to extract error"' }

What might have caused this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.