-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Ollama integration for image descriptions
--- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/microsoft/markitdown?shareId=XXXX-XXXX-XXXX-XXXX).
- Loading branch information
1 parent
125e206
commit e2470fc
Showing
10 changed files
with
232 additions
and
20 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,21 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile | ||
{ | ||
"name": "Existing Dockerfile", | ||
"build": { | ||
// Sets the run context to one level up instead of the .devcontainer folder. | ||
"context": "..", | ||
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. | ||
"dockerfile": "../Dockerfile", | ||
"args": { | ||
"INSTALL_GIT": "true" | ||
} | ||
}, | ||
|
||
// Features to add to the dev container. More info: https://containers.dev/features. | ||
// "features": {}, | ||
"features": { | ||
"ghcr.io/devcontainers-extra/features/hatch:2": {} | ||
"ghcr.io/devcontainers-extra/features/hatch:2": {}, | ||
"ghcr.io/devcontainers/features/python:1": { | ||
"version": "3.10" | ||
}, | ||
"ghcr.io/devcontainers/features/node:1": { | ||
"version": "16" | ||
}, | ||
"ghcr.io/devcontainers/features/ollama:1": {} | ||
}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Uncomment the next line to run commands after the container is created. | ||
// "postCreateCommand": "cat /etc/os-release", | ||
|
||
// Configure tool-specific properties. | ||
// "customizations": {}, | ||
|
||
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. | ||
"remoteUser": "root" | ||
} |
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
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
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,37 @@ | ||
{ | ||
"name": "markitdown-web-ui", | ||
"version": "1.0.0", | ||
"description": "Web-based UI for MarkItDown", | ||
"main": "src/App.js", | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test", | ||
"eject": "react-scripts eject" | ||
}, | ||
"dependencies": { | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"react-scripts": "4.0.3", | ||
"axios": "^0.21.1", | ||
"react-markdown": "^7.0.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"react-app", | ||
"react-app/jest" | ||
] | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |
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,42 @@ | ||
import React, { useState } from 'react'; | ||
import FileUpload from './components/FileUpload'; | ||
import MarkdownPreview from './components/MarkdownPreview'; | ||
import DownloadButton from './components/DownloadButton'; | ||
import axios from 'axios'; | ||
|
||
function App() { | ||
const [markdownContent, setMarkdownContent] = useState(''); | ||
const [fileName, setFileName] = useState(''); | ||
|
||
const handleFileUpload = async (file) => { | ||
const formData = new FormData(); | ||
formData.append('file', file); | ||
|
||
try { | ||
const response = await axios.post('/api/convert', formData, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data', | ||
}, | ||
}); | ||
setMarkdownContent(response.data.markdown); | ||
setFileName(file.name); | ||
} catch (error) { | ||
console.error('Error uploading file:', error); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<h1>MarkItDown Web UI</h1> | ||
</header> | ||
<main> | ||
<FileUpload onFileUpload={handleFileUpload} /> | ||
<MarkdownPreview content={markdownContent} /> | ||
<DownloadButton content={markdownContent} fileName={fileName} /> | ||
</main> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
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,21 @@ | ||
import React from 'react'; | ||
|
||
function DownloadButton({ content, fileName }) { | ||
const handleDownload = () => { | ||
const element = document.createElement('a'); | ||
const file = new Blob([content], { type: 'text/markdown' }); | ||
element.href = URL.createObjectURL(file); | ||
element.download = fileName.replace(/\.[^/.]+$/, "") + ".md"; | ||
document.body.appendChild(element); | ||
element.click(); | ||
document.body.removeChild(element); | ||
}; | ||
|
||
return ( | ||
<button onClick={handleDownload}> | ||
Download Markdown | ||
</button> | ||
); | ||
} | ||
|
||
export default DownloadButton; |
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,18 @@ | ||
import React from 'react'; | ||
|
||
function FileUpload({ onFileUpload }) { | ||
const handleFileChange = (event) => { | ||
const file = event.target.files[0]; | ||
if (file) { | ||
onFileUpload(file); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="file-upload"> | ||
<input type="file" onChange={handleFileChange} /> | ||
</div> | ||
); | ||
} | ||
|
||
export default FileUpload; |
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,12 @@ | ||
import React from 'react'; | ||
import ReactMarkdown from 'react-markdown'; | ||
|
||
function MarkdownPreview({ content }) { | ||
return ( | ||
<div className="markdown-preview"> | ||
<ReactMarkdown>{content}</ReactMarkdown> | ||
</div> | ||
); | ||
} | ||
|
||
export default MarkdownPreview; |