Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
name: Deploy AI Archives to EC2
# .github/workflows/deploy.yml
name: Deploy to EC2

on:
push:
branches: [main]
branches:
- xinrui/deepseekmodel

jobs:
deploy:
runs-on: ubuntu-latest
env:
SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_KEY: ${{ secrets.EC2_KEY_BASE64 }}
HOST: ${{ secrets.SERVER_HOST }}
USER: ${{ secrets.SERVER_USER }}

steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Decode and save EC2 SSH key
run: |
echo "$SSH_KEY" | base64 -d > deploy_key
chmod 600 deploy_key

- name: Build
run: |
npm ci
npm run build

- name: Sync build to EC2
run: |
echo "$SSH_KEY" > deploy_key
chmod 600 deploy_key
rsync -avz --delete \
--exclude 'node_modules' --exclude '.git' --exclude '.env' \
-e "ssh -i deploy_key -o StrictHostKeyChecking=no" \
Expand All @@ -32,4 +38,4 @@ jobs:
- name: Restart AI Archives service
run: |
ssh -i deploy_key -o StrictHostKeyChecking=no $USER@$HOST \
"sudo systemctl restart aiarchives"
"sudo systemctl restart aiarchives"
17 changes: 15 additions & 2 deletions app/api/conversation/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,22 @@ export async function POST(req: NextRequest) {
return NextResponse.json({ error: '`htmlDoc` must be a file field' }, { status: 400 });
}

// Parse the conversation from HTML
// Parse the conversation from HTML if not skipScraping, otherwise skip parsing
const skipScraping = formData.has('skipScraping');
let conversation;
const html = await file.text();
const conversation = await parseHtmlToConversation(html, model);
if (!skipScraping) {
conversation = await parseHtmlToConversation(html, model);
} else {
conversation = {
model: model,
content: html,
scrapedAt: new Date().toISOString(),
sourceHtmlBytes: html.length,
};
}

console.log('conversation =>', conversation.model, conversation.content);

// Generate a unique ID for the conversation
const conversationId = randomUUID();
Expand Down
2 changes: 1 addition & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface ConversationCardData {
*/
async function fetchConversations(): Promise<ConversationRecord[]> {
try {
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000';
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000';
const response = await fetch(`${baseUrl}/api/conversation?limit=50`, {
method: 'GET',
headers: {
Expand Down
6 changes: 4 additions & 2 deletions extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"https://claude.ai/*",
"https://gemini.google.com/*",
"https://chatgpt.com/*",
"https://chat.openai.com/*"
"https://chat.openai.com/*",
"https://chat.deepseek.com/*"
],
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
Expand All @@ -26,7 +27,8 @@
"https://bard.google.com/*",
"https://gemini.google.com/*",
"https://claude.ai/*",
"https://www.meta.ai/*"
"https://www.meta.ai/*",
"https://chat.deepseek.com/*"
],
"js": ["config.js", "index.js"],
"run_at": "document_end",
Expand Down
9 changes: 8 additions & 1 deletion extension/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ chrome.tabs.query({ active: true, currentWindow: true, url: 'https://bard.google
});
chrome.tabs.query({ active: true, currentWindow: true, url: 'https://www.meta.ai/*' }, (tabs) => {
if (tabs?.length) {
chrome.tabs.sendMessage(tabs[0].id, { action: 'model', model: 'Meta' }, function (_) {
chrome.tabs.sendMessage(tabs[0].id, { action: 'model', model: 'meta' }, function (_) {
console.log('is Meta');
});
}
Expand All @@ -53,5 +53,12 @@ chrome.tabs.query({ active: true, currentWindow: true, url: 'https://claude.ai/*
});
}
});
chrome.tabs.query({ active: true, currentWindow: true, url: 'https://chat.deepseek.com/*' }, (tabs) => {
if (tabs?.length) {
chrome.tabs.sendMessage(tabs[0].id, { action: 'model', model: 'deepSeek' }, function (_) {
console.log('is DeepSeek');
});
}
});

window.onload = initApp;
1 change: 1 addition & 0 deletions lib/parsers/assets/deepseek.css

Large diffs are not rendered by default.

40 changes: 38 additions & 2 deletions lib/parsers/deepseek.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
import type { Conversation } from '@/types/conversation';
import { JSDOM } from 'jsdom';
import fs from 'fs';
import path from 'path';

/**
* Extracts a DeepSeek share page into a structured Conversation.
* @param html - Raw HTML content from the DeepSeek share page
* @returns Promise resolving to a structured Conversation object
*/
export async function parseDeepSeek(html: string): Promise<Conversation> {
const dom = new JSDOM(html);
const document = dom.window.document;

// 1. Inject <style> from deepseek.css
const cssPath = path.resolve(process.cwd(), 'lib/parsers/assets/deepseek.css');
const css = fs.readFileSync(cssPath, 'utf-8');

const styleTag = document.createElement('style');
styleTag.textContent = css;
document.head.appendChild(styleTag);

// 2. Clean up icons and extra UI elements
const iconSelectors = ['.ds-icon-button'];
iconSelectors.forEach(selector => {
document.querySelectorAll(selector).forEach(el => el.remove());
});

// 3. Grab main conversation container
const chatContainer = document.querySelector('div.dad65929');
if (!chatContainer) {
throw new Error('Conversation container not found');
}

// 4. Prepare the final HTML output
const htmlContent = `
<html>
<head>${document.head.innerHTML}</head>
<body class="light-theme theme-host">
${chatContainer.outerHTML}
</body>
</html>
`;

return {
model: 'DeepSeek',
content: html,
model: 'deepSeek',
content: htmlContent,
scrapedAt: new Date().toISOString(),
sourceHtmlBytes: html.length,
};
Expand Down
Loading