-
Notifications
You must be signed in to change notification settings - Fork 101
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/#218 add ai generation to markdown cells #228
Closed
Aswanth-c
wants to merge
19
commits into
srcbookdev:main
from
Aswanth-c:feat/#218-Add-AI-generation-to-markdown-cells
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1dd1a8e
WIP
Aswanth-c c893164
added ai feature to markdown
Aswanth-c 2159a08
fixed build issue
Aswanth-c 69d6381
removed unwanted console.log
Aswanth-c 07aa999
refactor(MarkdownCell): Improve AI generation flow and error handling
Aswanth-c cc1efaf
added tool tip
Aswanth-c 8c68bbd
removed unwanted package.json
Aswanth-c ea84608
added ai generation on backend
Aswanth-c f28bdc5
Merge branch 'main' into feat/#218-Add-AI-generation-to-markdown-cells
Aswanth-c e37bdf9
Fixed edge cases where markdown had improper generation
Aswanth-c ae2cf40
Merge branch 'main' into feat/#218-Add-AI-generation-to-markdown-cells
Aswanth-c c19fabf
Added changes in main
Aswanth-c ec44ee6
removed duplicate files on merge
Aswanth-c 77e733d
Merge branch 'main' into feat/#218-Add-AI-generation-to-markdown-cells
Aswanth-c cc5a7d7
removed unwanted console log
Aswanth-c 93c1b9d
fixed typescript build error
Aswanth-c 7056e45
fixed lint issues
Aswanth-c ceede6d
fixed lint error click-events-have-key-events
Aswanth-c 9e9c410
Merge branch 'main' into feat/#218-Add-AI-generation-to-markdown-cells
Aswanth-c File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<!-- srcbook:{"language":"markdown"} --> | ||
|
||
## Instructions Context | ||
|
||
You are tasked with editing a **Markdown cell** in a Srcbook. | ||
|
||
A Srcbook is a **Markdown-compatible notebook**, used for documentation or text-based content. | ||
|
||
### Srcbook Spec | ||
|
||
The structure of a Srcbook: | ||
0. The language comment: `<!-- srcbook:{"language":"markdown"} -->` | ||
1. Title cell (heading 1) | ||
2. N more cells, which are either: | ||
- **Markdown cells** (GitHub flavored Markdown) | ||
- Markdown cells, which have a filename and source content. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong, should be code cells |
||
|
||
|
||
# Important Note: | ||
Markdown cells cannot use h1 or h6 headings, as these are reserved for Srcbook. **Do not use h1 (#) or h6 (######) headings in the content.** | ||
|
||
The user is already working on an existing Srcbook and is asking you to edit a specific Markdown cell. | ||
The Srcbook contents will be passed to you as context, as well as the user's request about the intended edits for the Markdown cell. | ||
|
||
--- | ||
|
||
## Example Srcbook | ||
|
||
<!-- srcbook:{"language":"markdown"} --> | ||
|
||
### Getting Started | ||
|
||
#### What are Srcbooks? | ||
|
||
Srcbooks are an interactive way of organizing and presenting information. They are similar to other notebooks but unique in their flexibility and format. | ||
|
||
#### Dependencies | ||
|
||
You can include any necessary information, resources, or links to external content. | ||
|
||
##### Introduction | ||
|
||
This is a Markdown cell showcasing various Markdown features. | ||
|
||
#### Features Overview | ||
|
||
##### Text Formatting | ||
|
||
- **Bold text** | ||
- *Italic text* | ||
- ~~Strikethrough text~~ | ||
|
||
##### Lists | ||
|
||
- **Unordered List:** | ||
- Item 1 | ||
- Item 2 | ||
|
||
- **Ordered List:** | ||
1. First item | ||
2. Second item | ||
|
||
##### Code Blocks | ||
|
||
Inline code: `console.log("Hello, Markdown!")` | ||
|
||
##### Links | ||
|
||
[Click here to visit Google](https://www.google.com) | ||
|
||
##### Images | ||
|
||
![Alt text](image.png) | ||
|
||
--- | ||
|
||
## Final Instructions | ||
|
||
The user's Srcbook will be passed to you, surrounded with `==== BEGIN SRCBOOK ====` and `==== END SRCBOOK ====`. | ||
The specific **Markdown cell** they want updated will also be passed to you, surrounded with `==== BEGIN MARKDOWN CELL ====` and `==== END MARKDOWN CELL ====`. | ||
The user's intent will be passed to you between `==== BEGIN USER REQUEST ====` and `==== END USER REQUEST ====`. | ||
|
||
Your job is to edit the cell based on the contents of the Srcbook and the user's intent. | ||
Act as a **Markdown expert**, writing the best possible content you can. Focus on being **elegant, concise, and clear**. | ||
**ONLY RETURN THE MARKDOWN TEXT , NO PREAMBULE, NO SUFFIX, NO CODE FENCES (LIKE TRIPLE BACKTICKS) ONLY THE MARKDOWN**. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Sparkles, MessageCircleWarning, X } from 'lucide-react'; | ||
import TextareaAutosize from 'react-textarea-autosize'; | ||
import { Button } from '@/components/ui/button'; | ||
import AiGenerateTipsDialog from '@/components/ai-generate-tips-dialog'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
interface AiPromptInputProps { | ||
prompt: string; | ||
setPrompt: (prompt: string) => void; | ||
onClose: () => void; | ||
aiEnabled: boolean; | ||
} | ||
|
||
export function AiPromptInput({ prompt, setPrompt, onClose, aiEnabled }: AiPromptInputProps) { | ||
const navigate = useNavigate(); | ||
return ( | ||
<div className="flex flex-col gap-1.5"> | ||
<div className="flex items-start justify-between px-1"> | ||
<div className="flex items-start flex-grow"> | ||
<Sparkles size={16} className="m-2.5" /> | ||
<TextareaAutosize | ||
className="flex w-full rounded-sm bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none resize-none" | ||
placeholder="Ask the AI to edit this cell..." | ||
value={prompt} | ||
onChange={(e) => setPrompt(e.target.value)} | ||
/> | ||
</div> | ||
<div className="flex items-center gap-1"> | ||
<AiGenerateTipsDialog> | ||
<Button size="icon" variant="icon"> | ||
<MessageCircleWarning size={16} /> | ||
</Button> | ||
</AiGenerateTipsDialog> | ||
<Button size="icon" variant="icon" onClick={onClose}> | ||
<X size={16} /> | ||
</Button> | ||
</div> | ||
</div> | ||
{!aiEnabled && ( | ||
<div className="flex items-center justify-between bg-warning text-warning-foreground rounded-sm text-sm px-3 py-1 m-3"> | ||
<p>AI provider not configured.</p> | ||
<button | ||
className="font-medium underline cursor-pointer" | ||
onClick={() => navigate('/settings')} | ||
aria-hidden="true" | ||
> | ||
Settings | ||
</button> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We don't need this in the prompt