invalidusernamelol [he/him]

  • 3 Posts
  • 64 Comments
Joined 4 years ago
cake
Cake day: July 30th, 2020

help-circle





  • It’s nice to be able to do something like this without having to use an ORM. Especially if you need a version of the data that’s limited to a certain character size.

    Like having a replica on the edge that serves the 100 character summaries then only loads the full 1000+ character record when a user interacts with it.

    A summary of the review is also more useful than just the first 100 characters of a review.

    If the model that’s used for that is moderately light I could see it actually using less energy over time for high volume applications if it is able to lower overall bandwidth.

    This is all assuming that the model is only run one time or on record update though and not every time the query is run…









  • I still think in development environments, limited LLM systems can be used in tandem with other systems like linters and OG snippets to help maintain style and simplify boilerplate.

    I use Co-Pilot at work because I do development on the side and need something to help me bash out simple scripts really fast that use our apis. The codebase we have is big enough now (50,000 ish lines and hundreds of files) so it tends to pick up primarily on the context of the codebase. It does still fallback to the general context pretty often though and that’s a fucking pain.

    Having the benefits of an LLM trained on your own code and examples without the drawbacks of it occasionally just injecting random bullshit from its training data would be great.





  • Even better is to create a decorator and just wrap the offending functions:

    def shut_up(func):
        def call(*args, **kwargs):
            try:
                return func(*args, **kwargs)
            except Exception as e:
                print(f"shit's fucked, but I'll be quiet about it")
                return
        return call
    
    @shut_up
    def add(x: int, y: int):
        print(x + y)
    
    add(1, 2)
    add(-1, 2)
    add(1, "2")
    
    >>> 3
    >>> 1
    >>> "shit's fucked, but I'll be quiet about it"
    

    Or if you want to attempt to salvage it:

    def shut_up(func):
        def call(*args, **kwargs):
            try:
                return func(*args, **kwargs)
            except Exception as e:
                try:
                    return func(*map(int, args), **kwargs)
                except Exception as e:
                    print(f"shit's really fucked, I even tried to fix it for you")
                    return None
        return call
    

  • You just have to do it manually in Python or rely on systems like mypy to get ‘static’ checking.

    It can be useful to rely on duck typing though if you don’t want to have to re-implement or inherit from an existing base class to use a higer order function.

    If the function is written in a way where all it needs is specific methods or parameters from its input objects, you can really save on interface bloat.

    But if someone is used to writing statically typed code and has to deal with that it can create a lot of confusion and I always end up writing a ton of override signatures either in my code or in a .pyi sidecar so whoever is using it can still get some form of feedback that what they’re doing is okay. Or at the very least putting that information in the docstring so people can read the docs as they’re using the function.