Giter VIP home page Giter VIP logo

Comments (10)

n3d1117 avatar n3d1117 commented on May 16, 2024

Hi @kithawk, can you elaborate on this use case? Why would you need inline mode in a private chat when you can simply message the bot privately

from chatgpt-telegram-bot.

kithawk avatar kithawk commented on May 16, 2024

This would allow you to generate and send response directly in a private conversation with another user (but marked as being generated via the bot, just like when using bots like @vid or @pic)

from chatgpt-telegram-bot.

n3d1117 avatar n3d1117 commented on May 16, 2024

Ah, I get what you mean now. I've added experimental support for this in the inline-query-response branch.

Let me know what you think. I've tested it a few times and it seems very slow.

from chatgpt-telegram-bot.

kithawk avatar kithawk commented on May 16, 2024

Thanks, it works as expected. However, it appears that the Telegram API for inline queries only provides a response once we stop typing. Therefore, when we pause, ChatGPT sends a response, but if we resume typing and send another message, it makes an additional call to the API, resulting in extra token usage as the API still considers the previous message 'unsent' since ChatGPT has already received it.

For example, if we send @bot hey, we should get a 'hello' response. However, if we pause and then resume typing @bot hey, what's the weather?, we will receive information about no access to the weather. This results in a separate call to the ChatGPT API (using tokens), as well as the API keeping a history of the conversation.

To avoid this issue, one solution could be to not keep history in private inline messages. Another solution could be to send the message to the OpenAI API only if the private inline message ends with something that would explicitly indicate the end of the query, such as @@. This way, only the message @bot hey, what's the weather @@ would be sent to ChatGPT to provide an inline answer.

from chatgpt-telegram-bot.

n3d1117 avatar n3d1117 commented on May 16, 2024

Hi @kithawk, I agree that history should not be kept for inline messages.

Does inline query work for you with long outputs (e.g. if you ask tell me a story)? For me it just keeps spinning and never updates. Seems like the response never shows up if the request takes more than a fixed amount of time (e.g. 5s). But i can't find any documentation on this timeout

from chatgpt-telegram-bot.

kithawk avatar kithawk commented on May 16, 2024

Hey @n3d1117, same behaviour for me - for longer queries it times out. Not sure if this works, but maybe for answer we do the prompt, and once we get response from API we can edit the message that was already sent (containing just the prompt)

from chatgpt-telegram-bot.

n3d1117 avatar n3d1117 commented on May 16, 2024

Hmm not a big fan of this idea. Will keep this issue open in case someone wants to work on it

from chatgpt-telegram-bot.

k3it avatar k3it commented on May 16, 2024

i wonder if the @bold bot can serve as a model for the inline mode. it accepts queries in real-time, but it doesn't execute the query or provide a response until the user clicks one of the presented options. It would be more efficient to hold off on sending anything to the API until after the user confirms the choice by clicking on a pop-up.

This approach would allow for presenting different options for the type of response you want to receive from the API (humor, serious, etc).. similar to "bold", "italic", "fixed" options in the @bold bot.

from chatgpt-telegram-bot.

n3d1117 avatar n3d1117 commented on May 16, 2024

@k3it I don't think that's going to work. Here's how inline queries work for these kinds of bots:

async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
     query = update.inline_query.query
     results = [
        InlineQueryResultArticle(
            id='some_id',
            title="Bold",
            input_message_content=InputTextMessageContent(
                "**query**", parse_mode=ParseMode.MARKDOWN
            ),
        ),
        # italic, etc...
    ]
    await update.inline_query.answer(results)

There's a predefined InputTextMessageContent based on what you write. There's no way to make an API call after the user selects Bold.

Also, I don't think what @kithawk was proposing is feasible either. I haven't checked, but we don't have access to the message sent after a user clicks on the inline popup, so we can't edit it.

from chatgpt-telegram-bot.

bugfloyd avatar bugfloyd commented on May 16, 2024

@n3d1117 I believe we can edit inline messages sent by bot. A PR is proposed to implement this feature. Feel free to review and provide suggestions.

from chatgpt-telegram-bot.

Related Issues (20)

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.