Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it possible to autocomplete text using openai in pyqt? #24

Open
thiswillbeyourgithub opened this issue May 12, 2023 · 9 comments
Open

Comments

@thiswillbeyourgithub
Copy link

Hi,

I'm looking for options to implement an autocompletion plugin in an application that uses PyQT. The completion would be using openai's codex (and ultimately be extended to other models).

It would really help me if I saw an implementation in your app I think :) do you have any idea how this would be coded? Any plan to do it? It looks like code completion is the only openai API you have not implemented.

Thanks and have a nice day!

@yjg30737
Copy link
Owner

Sorry to my belated reply.

You mean like this? https://openai.com/blog/openai-codex

If so, generating code is possible. Based of the video the page provided, we need just a prompt and result text browser(with highlighting feature).

But in the case of preview screen, it is only possible when it comes to two case: webpage or desktop application (pyqt only).

Web preview can be accomplished by using Qt WebEngine, PyQt preview can be accomplished by using QMdiArea.

Thank you for that, and i will include it my TODO list after i've updated prompt feature

@thiswillbeyourgithub
Copy link
Author

Sorry to my belated reply.

No worries, FOSS is at the pace of the owner :)

You mean like this? https://openai.com/blog/openai-codex

If so, generating code is possible. Based of the video the page provided, we need just a prompt and result text browser(with highlighting feature).

I actually don't mean that, I just mean regular autocompletion of text and not specifically code. I see it more like "regular autocompletion on steroids thanks to AI" if that makes sense.

My issue is more on how to connect Qt's autocomplete features with an LLM.

What do you think?

@yjg30737
Copy link
Owner

yjg30737 commented May 17, 2023

Hmm.. Could you be more specific? I need an example of it

Sorry to keep asking to you 😥

@thiswillbeyourgithub
Copy link
Author

No worries :) thanks for digging!

I'm a heavy user of Anki, a FOSS flashcard software (and highly recommend it!). There is no built in autocomplete function. There used to be an addon link but it broke a few release ago and unfortunately relies on JS, which I'm not familiar with and is hard to debug in the current configuration (the js is executed in some kind of isolated env, separated from the python, kinda unreliable across releases, etc).

But I know Qt and related GUI engine have their own completion feature (QCompleter IIRC etc). I also know they can be extended with custom code. And that Anki is based on Qt and python (also rust for the backend).

What I'm thinking is that any language model trained on causal language modelling should be decently fast at autocompleting my tokens as I write. And adding the GUI code to Anki should be within my reach as an Anki addon.

But figuring out how to connect an LLM (wether it's local or by API and wether it's a code LLM or text LLM) to the Qt backend seems like it would take me a lot of time and way less of yours.

GIven that it seems to be in the scope of your project, I reached out to see if you were interested in supporting a PyQT autocompletion using an LLM (wether it's openai or not, a code completer or not, etc as I should be able to figure it out afterwards).

Is that clearer :)? Thanks again

@yjg30737
Copy link
Owner

yjg30737 commented May 18, 2023

Do you mean you want to autocomplete the LLM's response based on question? If so, question and response needs to be saved in DB and thankfully this app has it. I can include autocompletion feature based on question-response pair as an option or some sort.

By the way, i can share some of my QCompleter examples (if it helps).

https://github.com/yjg30737/pyqt-left-right-text-completer // customized QCompleter. left is word which can be searched, right word is information

https://github.com/yjg30737/pyqt-instant-search-bar // instant search bar with using QCompleter

https://github.com/yjg30737/pyqt-highlight-completer // highlight input text (it doesn't use QCompleter at all)

I've just skimmed over Anki but i'm not familiar with way of using and concept of that software so i can't fully grasp what you've said, still 😥 hopefully i understand right about it this time

@thiswillbeyourgithub
Copy link
Author

Still no quite that, thanks for trying !!

What I'm looking for is basically this but using an LLM and Qt backend :

gif

@yjg30737
Copy link
Owner

As if like IntelliSense in VSC. but not just code, text in general. Am i right? Please tell me that i'm right

@thiswillbeyourgithub
Copy link
Author

Yes :)

(Btw I am aware that more LLM is not always better for every application, and I keep in my mind to maybe in the end implement an n-gram sentence completer or something. I could figure out that myself, just not the Qt backend.)

@yjg30737
Copy link
Owner

Good. At least i grasp the concept of it and i will make autocomplete feature using LLM or any other model.

But not this package, this package is too huge to implement it suddenly, so i need to approach it step by step, so i will make a separate project(repo) to do it first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants