-
Notifications
You must be signed in to change notification settings - Fork 0
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
AI editor #1094
base: main
Are you sure you want to change the base?
AI editor #1094
Conversation
Co-authored-by: Jakub Fidler <[email protected]>
ankihub/entry_point.py
Outdated
if config.labs_enabled: | ||
llm.setup() | ||
LOGGER.info("Set up LLM prompt functionality.") | ||
|
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.
@RisingOrange One possibility to implement "AnkiHub Labs": if labs is enabled, we clone/pull from a separate mono repo on GitHub that contains a bunch of community contributed functionality. Users can individually toggle them on/off. We could accept or reject PRs to this mono repo that are basically a bunch of mini standalone add-ons. Except, we could provide facilities for quick and easy development, web capabilities, and maybe mobile integrations. We could provide a replit template, cursor rules, and copilot prompts to make developing these really easy with AI.
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.
conda-forge might be a good model to look at for how to do this https://conda-forge.org/docs/maintainer/infrastructure/
@andrewsanchez Using |
EDIT: addressed in 649677e This PR is just a quick proof of concept in order to test out some workflows internally with a few people. So I will provide API keys that testers on our team can use. If we decide to put this in the hands of real users, we would need to migrate the |
def _on_reset(self) -> None: | ||
"""Reset the template to the version in the local templates directory.""" | ||
if ask_user( | ||
"Are you sure you want to reset the template to the original version?" | ||
): | ||
local_template_path = ( | ||
TemplateManager._local_templates_dir / f"{self.template_name}.yaml" | ||
) | ||
self.template_content = local_template_path.read_text(encoding="utf-8") | ||
self.yaml_data = yaml.safe_load(self.template_content) | ||
if not isinstance(self.yaml_data, dict): | ||
self.yaml_data = {} | ||
self._update_editors() # Update the editors with the reset content | ||
TemplateManager.save_template(self.template_name, self.template_content) | ||
tooltip("Template reset.", parent=self) |
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.
Not sure why but this results in some funky yaml, @RisingOrange :
model: gpt-4o
system: "You are an expert at creating effective flashcards. Analyze the provided\
\ cloze deletion note and respond with an improved note according to the users instructions.\n\
Follow these guidelines:\n- Use cloze deletions to hide key information.\n- Use\
\ the {{c1::hidden text}} format for cloze deletions. You can also use {{c2::hidden\
\ text}}, {{c3::hidden text}}, and so on. This will result in multiple cards being\
\ created for the note by Anki. Cloze deletions with the same number will be hidden\
\ on the same card, while all the other cloze deletions won't be used for this card.\n\
- Most notes should only have one cloze deletion. Focus on the highest yield concepts\
\ and facts. \"high-yield\" means the information is most important or most frequently\
\ tested on exams.\n- Create focused cards which tests a single concept or fact.\n\
- Ensure the remaining context provides enough information for the user to recall\
\ the hidden content.\n\n## Common Mistakes\nAvoid these common mistakes when creating\
\ cloze deletion cards:\n- Occluding too much information, making the card impossible\
\ to answer.\n - E.g., \"The {{c1::sky}} is {{c1::blue}}.\" This card is impossible\
\ to answer because both \"sky\" and \"blue\" are occluded.\n\n\nHere are some examples\
\ of well-constructed cloze deletion notes:\n- Persistent {{c1::infection}} is the\
\ most common symptom of chronic sinopulmonary disease\n- Chronic sinopulmonary\
\ disease commonly presents with chronic {{c1::cough}} and {{c1::sputum}} production.\n\
- 11-deoxycorticosterone (DOC) may be converted to {{c1::corticosterone}} via the\
\ enzyme {{c2::11\u03B2-hydroxylase}}.\n- 11\u03B2-hydroxylase deficiency presents\
\ with {{c1::hypokalemia}} and {{c1::hypertension}}.\n- The {{c1::orbit}} is the\
\ bony socket housing the eyeball and contains muscles for {{c2::eye movement}}\
\ and {{c2::eyelid opening}}.\n- The upper portion of the nasal septum is formed\
\ by the {{c1::ethmoid}} bone; the lower portion is formed by the {{c2::vomer}}\
\ bone.\n- {{c1::Bone marrow}} within bones stores {{c2::fat}} and produces {{c3::blood\
\ cells}}.\n- Two main side effects of osmotic laxatives include {{c1::diarrhea}}\
\ and {{c1::dehydration}}.\n- Newly synthesized cGMP (from guanylyl cyclase activity)\
\ activates {{c1::protein kinase G}}, which phosphorylates specific proteins responsible\
\ for physiologic actions.\n- The posterior lobe of the pituitary gland is derived\
\ from {{c1::neural}} tissue.\n- The skeleton protects {{c1::internal organs}} and\
\ stores minerals like {{c2::calcium}} and {{c2::phosphate}}.\n\nImprove the provided\
\ cloze deletion note based on the instructions above. Ensure that the card is clear,\
\ and effective for learning and recall. Respond only with the improved note. Do\
\ not provide any pre-amble, explanation, or surrounding xml tags.\n"
prompt: 'Here is the card to improve:
<original note>
$input
</original note>
'
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.
actually not sure if it's this or saving user changes. I'll take a look
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.
ya I think it happens when users try to save the template changes but not sure why yet.
Quick proof of concept PR to prototype in-Anki LLM features for editing and creating cards.