Coder Social home page Coder Social logo

Access external URLs about pokitoki HOT 11 CLOSED

nalgeon avatar nalgeon commented on July 23, 2024
Access external URLs

from pokitoki.

Comments (11)

HeySlava avatar HeySlava commented on July 23, 2024

What would be the expected response if a single request to OpenAI exceeds the content limit (a long article)?

from pokitoki.

nalgeon avatar nalgeon commented on July 23, 2024

It would be an error returned by the OpenAI API.

from pokitoki.

HeySlava avatar HeySlava commented on July 23, 2024

I agree. However it's possible to split a text into several requests

from pokitoki.

HeySlava avatar HeySlava commented on July 23, 2024

            I am sorry. I thought about different thing. Something like this: max_tokens=1000

from pokitoki.

nalgeon avatar nalgeon commented on July 23, 2024

The max_tokens parameter in openai.ChatCompletion is the maximum number of tokens to generate (the number of output tokens). It's currently hardcoded to 1000.

The number of input tokens is determined by the user message. After replacing the URLs with their content, it could be significant.

OpenAI has a limit on the total number of tokens (prompt + input + output). It will return an error if there are too many tokens.

All of this is beyond the scope of this issue. Handling large numbers of tokens is important, but that's a question for another time.

from pokitoki.

nalgeon avatar nalgeon commented on July 23, 2024

Here goes: External links

from pokitoki.

HeySlava avatar HeySlava commented on July 23, 2024
    def is_text(self) -> bool:
        """Checks if the content type is plain text."""
        if not self.content_type:
            return False
        if self.content_type.startswith("text/"):
            return True
        if self.content_type in self.allowed_content_types:
            return True
        return False

Isn't it better to raise an exception instead of returning False? My idea is simple: users will understand that their links are unprocessable before request to Openai.

from pokitoki.

nalgeon avatar nalgeon commented on July 23, 2024

I prefer the current implementation. The bot states that it can't process the binary content:

Q: Explain this paper in simple terms https://arxiv.org/pdf/1706.03762.pdf

A: I'm sorry, but I cannot access the contents of the paper you provided as it appears to be unknown binary content. Can you please provide me with the correct link or the title of the paper so I can provide you with a clear explanation?

from pokitoki.

HeySlava avatar HeySlava commented on July 23, 2024

This is my example:

Read the most popular comments: https://www.youtube.com/watch?v=outcGtbnMuQ
I apologize, but the content you provided does not include any comments from viewers. Can you please provide a different link or specify where the comments can be found?

There are not handlers in case when content_type not in self.allowed_content_types but link contains text-ish content

from pokitoki.

nalgeon avatar nalgeon commented on July 23, 2024

This is another case. The content type is OK (text/html), but the actual content is loaded dynamically via JS. I don't think I will support such cases.

from pokitoki.

nalgeon avatar nalgeon commented on July 23, 2024

I'm pretty happy with with the implementation so far.

from pokitoki.

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.