Spaces:
Running
Running
add new model + bug fixes
Browse files- app/api/ask/route.ts +1 -0
- hooks/useAi.ts +3 -3
- index.html +34 -0
- lib/format-ai-response.ts +6 -4
- lib/providers.ts +8 -1
app/api/ask/route.ts
CHANGED
|
@@ -144,6 +144,7 @@ export async function POST(request: NextRequest) {
|
|
| 144 |
|
| 145 |
await writer.close();
|
| 146 |
} catch (error: any) {
|
|
|
|
| 147 |
if (error.message?.includes("exceeded your monthly included credits")) {
|
| 148 |
await writer.write(
|
| 149 |
encoder.encode(
|
|
|
|
| 144 |
|
| 145 |
await writer.close();
|
| 146 |
} catch (error: any) {
|
| 147 |
+
console.error(error);
|
| 148 |
if (error.message?.includes("exceeded your monthly included credits")) {
|
| 149 |
await writer.write(
|
| 150 |
encoder.encode(
|
hooks/useAi.ts
CHANGED
|
@@ -562,16 +562,16 @@ export const useAi = (onScrollToBottom?: () => void) => {
|
|
| 562 |
|
| 563 |
const formatPages = (content: string, isStreaming: boolean = true) => {
|
| 564 |
const pages: Page[] = [];
|
| 565 |
-
if (!content.match(/<<<<<<< NEW_FILE_START
|
| 566 |
return pages;
|
| 567 |
}
|
| 568 |
|
| 569 |
const cleanedContent = content.replace(
|
| 570 |
-
/[\s\S]*?<<<<<<< NEW_FILE_START
|
| 571 |
"<<<<<<< NEW_FILE_START $1 >>>>>>> NEW_FILE_END"
|
| 572 |
);
|
| 573 |
const fileChunks = cleanedContent.split(
|
| 574 |
-
/<<<<<<< NEW_FILE_START
|
| 575 |
);
|
| 576 |
const processedChunks = new Set<number>();
|
| 577 |
|
|
|
|
| 562 |
|
| 563 |
const formatPages = (content: string, isStreaming: boolean = true) => {
|
| 564 |
const pages: Page[] = [];
|
| 565 |
+
if (!content.match(/<<<<<<< NEW_FILE_START[\s\S]*?>>>>>>> NEW_FILE_END/)) {
|
| 566 |
return pages;
|
| 567 |
}
|
| 568 |
|
| 569 |
const cleanedContent = content.replace(
|
| 570 |
+
/[\s\S]*?<<<<<<< NEW_FILE_START\s+([\s\S]*?)\s+>>>>>>> NEW_FILE_END/,
|
| 571 |
"<<<<<<< NEW_FILE_START $1 >>>>>>> NEW_FILE_END"
|
| 572 |
);
|
| 573 |
const fileChunks = cleanedContent.split(
|
| 574 |
+
/<<<<<<< NEW_FILE_START\s+([\s\S]*?)\s+>>>>>>> NEW_FILE_END/
|
| 575 |
);
|
| 576 |
const processedChunks = new Set<number>();
|
| 577 |
|
index.html
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script>
|
| 2 |
+
document.addEventListener("DOMContentLoaded", () => {
|
| 3 |
+
const targetOrigins = [
|
| 4 |
+
"https://huggingface.co/deepsite",
|
| 5 |
+
"https://enzostvs-deepsite.hf.space",
|
| 6 |
+
];
|
| 7 |
+
document.querySelectorAll("*").forEach((element) => {
|
| 8 |
+
element.addEventListener("click", () => {
|
| 9 |
+
targetOrigins.forEach((targetOrigin) => {
|
| 10 |
+
window.postMessage(
|
| 11 |
+
{ type: "ELEMENT_CLICKED", element },
|
| 12 |
+
targetOrigin
|
| 13 |
+
);
|
| 14 |
+
});
|
| 15 |
+
});
|
| 16 |
+
element.addEventListener("mouseover", () => {
|
| 17 |
+
targetOrigins.forEach((targetOrigin) => {
|
| 18 |
+
window.postMessage(
|
| 19 |
+
{ type: "ELEMENT_HOVERED_OVER", element },
|
| 20 |
+
targetOrigin
|
| 21 |
+
);
|
| 22 |
+
});
|
| 23 |
+
});
|
| 24 |
+
element.addEventListener("mouseout", () => {
|
| 25 |
+
targetOrigins.forEach((targetOrigin) => {
|
| 26 |
+
window.postMessage(
|
| 27 |
+
{ type: "ELEMENT_HOVERED_OUT", element },
|
| 28 |
+
targetOrigin
|
| 29 |
+
);
|
| 30 |
+
});
|
| 31 |
+
});
|
| 32 |
+
});
|
| 33 |
+
});
|
| 34 |
+
</script>
|
lib/format-ai-response.ts
CHANGED
|
@@ -47,13 +47,14 @@ export const processAiResponse = (
|
|
| 47 |
|
| 48 |
// Process UPDATE_FILE blocks
|
| 49 |
const updateFileRegex = new RegExp(
|
| 50 |
-
`${UPDATE_FILE_START.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([
|
| 51 |
'g'
|
| 52 |
);
|
| 53 |
let updateFileMatch;
|
| 54 |
|
| 55 |
while ((updateFileMatch = updateFileRegex.exec(chunk)) !== null) {
|
| 56 |
-
const [,
|
|
|
|
| 57 |
|
| 58 |
const pageIndex = updatedPages.findIndex(p => p.path === filePath);
|
| 59 |
if (pageIndex !== -1) {
|
|
@@ -123,13 +124,14 @@ export const processAiResponse = (
|
|
| 123 |
|
| 124 |
// Process NEW_FILE blocks
|
| 125 |
const newFileRegex = new RegExp(
|
| 126 |
-
`${NEW_FILE_START.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([
|
| 127 |
'g'
|
| 128 |
);
|
| 129 |
let newFileMatch;
|
| 130 |
|
| 131 |
while ((newFileMatch = newFileRegex.exec(chunk)) !== null) {
|
| 132 |
-
const [,
|
|
|
|
| 133 |
|
| 134 |
let fileData = fileContent;
|
| 135 |
// Try to extract content from code blocks
|
|
|
|
| 47 |
|
| 48 |
// Process UPDATE_FILE blocks
|
| 49 |
const updateFileRegex = new RegExp(
|
| 50 |
+
`${UPDATE_FILE_START.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([\\s\\S]*?)${UPDATE_FILE_END.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([\\s\\S]*?)(?=${UPDATE_FILE_START.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}|${NEW_FILE_START.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}|$)`,
|
| 51 |
'g'
|
| 52 |
);
|
| 53 |
let updateFileMatch;
|
| 54 |
|
| 55 |
while ((updateFileMatch = updateFileRegex.exec(chunk)) !== null) {
|
| 56 |
+
const [, filePathRaw, fileContent] = updateFileMatch;
|
| 57 |
+
const filePath = filePathRaw.trim();
|
| 58 |
|
| 59 |
const pageIndex = updatedPages.findIndex(p => p.path === filePath);
|
| 60 |
if (pageIndex !== -1) {
|
|
|
|
| 124 |
|
| 125 |
// Process NEW_FILE blocks
|
| 126 |
const newFileRegex = new RegExp(
|
| 127 |
+
`${NEW_FILE_START.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([\\s\\S]*?)${NEW_FILE_END.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([\\s\\S]*?)(?=${UPDATE_FILE_START.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}|${NEW_FILE_START.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}|$)`,
|
| 128 |
'g'
|
| 129 |
);
|
| 130 |
let newFileMatch;
|
| 131 |
|
| 132 |
while ((newFileMatch = newFileRegex.exec(chunk)) !== null) {
|
| 133 |
+
const [, filePathRaw, fileContent] = newFileMatch;
|
| 134 |
+
const filePath = filePathRaw.trim();
|
| 135 |
|
| 136 |
let fileData = fileContent;
|
| 137 |
// Try to extract content from code blocks
|
lib/providers.ts
CHANGED
|
@@ -72,6 +72,13 @@ export const MODELS = [
|
|
| 72 |
logo: DeepSeekLogo,
|
| 73 |
companyName: "DeepSeek",
|
| 74 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
{
|
| 76 |
value: "Qwen/Qwen3-Coder-480B-A35B-Instruct",
|
| 77 |
label: "Qwen3 Coder 480B A35B Instruct",
|
|
@@ -118,5 +125,5 @@ export const MODELS = [
|
|
| 118 |
top_k: 40,
|
| 119 |
temperature: 1.0,
|
| 120 |
top_p: 0.95,
|
| 121 |
-
}
|
| 122 |
];
|
|
|
|
| 72 |
logo: DeepSeekLogo,
|
| 73 |
companyName: "DeepSeek",
|
| 74 |
},
|
| 75 |
+
{
|
| 76 |
+
value: "deepseek-ai/DeepSeek-V3.2",
|
| 77 |
+
label: "DeepSeek V3.2",
|
| 78 |
+
logo: DeepSeekLogo,
|
| 79 |
+
companyName: "DeepSeek",
|
| 80 |
+
isNew: true,
|
| 81 |
+
},
|
| 82 |
{
|
| 83 |
value: "Qwen/Qwen3-Coder-480B-A35B-Instruct",
|
| 84 |
label: "Qwen3 Coder 480B A35B Instruct",
|
|
|
|
| 125 |
top_k: 40,
|
| 126 |
temperature: 1.0,
|
| 127 |
top_p: 0.95,
|
| 128 |
+
}
|
| 129 |
];
|