-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: Add AI interaction for text rewrite #66
Conversation
One thought I had on this PR that I forgot to mention in our call: we should probably add a configuration UX to allow users to specify their |
Ran a couple of examples using the ML scholarly papers we've been testing against and results still seem pretty good. Moving this into "ready for review" as I think it makes sense to merge in the initial backend work as one PR and then add in the front-end interaction once we have the UI ready. cc @cguedes @sehyod Merging this in shouldn't cause any issues since it's not called anywhere. ❯ poetry run python python/main.py rewrite --text "A common misconception about overfitting is that it is caused by noise, like training examples labeled with the wrong class. This can indeed aggravate overfitting, by making the learner draw a capricious frontier to keep those examples on what it thinks is the right side. But severe overfitting can occur even in the absence of noise. For instance, suppose we learn a Boolean classifier that is just the disjunction of the examples labeled “true” in the training set. (In other words, the classi- fier is a Boolean formula in disjunctive normal form, where each term is the conjunction of the feature values of one specific training example). This classifier gets all the train- ing examples right and every positive test example wrong, regardless of whether the training data is noisy or not." | jq
[
{
"index": 0,
"text": "Overfitting is not solely caused by noise, as it can occur even without it. For example, a Boolean classifier that is just the disjunction of the examples labeled \"true\" in the training set can lead to severe overfitting, getting all training examples right but every positive test example wrong."
}
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: I've only checked the code. I didn't had an API key to test.
I have put my OpenAI API key into the environment but I'm still not seeing output when running this PR. It says "Processing..." when I hit "REWRITE" but no text is returned. How can I get more diagnostics to figure out what's going on? |
I was able to get this working on a fresh checkout. The AI is alive!!! |
What’s blocking this from going in? |
The missing piece here is actually rewriting the selected text with what the AI returns. I think @cguedes was working on it but he is off today. I think we could merge this as is and add the actual rewrite action in a follow up PR |
Yeah I think there are UX issues to work through on how to take the text returned by the model and incorporate it into the document. Let's just get this in and open up a follow-on issue for what to do with the model-generated text. |
Only thing blocking from my perspective is an approving review. I can't merge without it. |
* feat: Add AI interaction for text rewrite (#60) * linter fix * Fix unit test reading OPENAI_API_KEY with .get * Adjust AI View to use rewrite sidecar command * Use `self.n_options` instead of hard-coded 1 * Create useCallablePromise and improve code * remove unused dependencies --------- Co-authored-by: Carlos Guedes <cguedes@gmail.com> Co-authored-by: Carlos Guedes <cguedes@users.noreply.github.com>
Adds initial "rewrite" capability to the sidecar. For a first pass, we're only focusing on the ability to rewrite a highlighted block of text in a more concise manner.
After trying some of the model options mentioned in #57, I decided to move forward with OpenAI for now. Ultimately, it felt like there's A LOT of noise around the other various model alternatives and I was starting to feel like I had fallen down a deep dark rabbit hole. When a clear winner emerges for us as a better option, I don't think swapping over to it will be too bad.
Another note is that I've opted to use GPT-3.5 rather than davinci. I felt that GPT-3.5 was producing better, more human-like responses. It also costs 1/10th of the price for now.
Example usage
Note that I'm passing
index
as a key rather thanid
to maintain consistency with how the OpenAI response refers to these fields. I think we might want to reserve what they call ID for later, when we eventually get to chat interactions.