-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from n4ze3m/next
v1.0.4
- Loading branch information
Showing
12 changed files
with
320 additions
and
10 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
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,24 @@ | ||
import React from "react"; | ||
|
||
export const SitemapIcon = React.forwardRef< | ||
SVGSVGElement, | ||
React.SVGProps<SVGSVGElement> | ||
>((props, ref) => { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
x="0" | ||
y="0" | ||
enableBackground="new 0 0 512 512" | ||
version="1.1" | ||
viewBox="0 0 512 512" | ||
xmlSpace="preserve" | ||
ref={ref} | ||
{...props} | ||
> | ||
<path d="M76.8 332.8v25.6H128c14.1 0 25.6 11.5 25.6 25.6v51.2c0 14.1-11.5 25.6-25.6 25.6H76.8c-14.1 0-25.6-11.5-25.6-25.6V384c0-14.1 11.5-25.6 25.6-25.6v-51.2C34.4 307.2 0 341.6 0 384v51.2C0 477.6 34.4 512 76.8 512H128c42.4 0 76.8-34.4 76.8-76.8V384c0-42.4-34.4-76.8-76.8-76.8H76.8v25.6zM384 332.8v25.6h51.2c14.1 0 25.6 11.5 25.6 25.6v51.2c0 14.1-11.5 25.6-25.6 25.6H384c-14.1 0-25.6-11.5-25.6-25.6V384c0-14.1 11.5-25.6 25.6-25.6v-51.2c-42.4 0-76.8 34.4-76.8 76.8v51.2c0 42.4 34.4 76.8 76.8 76.8h51.2c42.4 0 76.8-34.4 76.8-76.8V384c0-42.4-34.4-76.8-76.8-76.8H384v25.6zM230.4 25.6v25.6h51.2c14.1 0 25.6 11.5 25.6 25.6V128c0 14.1-11.5 25.6-25.6 25.6h-51.2c-14.1 0-25.6-11.5-25.6-25.6V76.8c0-14.1 11.5-25.6 25.6-25.6V0c-42.4 0-76.8 34.4-76.8 76.8V128c0 42.4 34.4 76.8 76.8 76.8h51.2c42.4 0 76.8-34.4 76.8-76.8V76.8C358.4 34.4 324 0 281.6 0h-51.2v25.6z"></path> | ||
<path d="M128 332.8v-25.6c0-14.1 11.5-25.6 25.6-25.6h204.8c14.1 0 25.6 11.5 25.6 25.6v25.6c0 14.1 11.5 25.6 25.6 25.6 14.1 0 25.6-11.5 25.6-25.6v-25.6c0-42.4-34.4-76.8-76.8-76.8H153.6c-42.4 0-76.8 34.4-76.8 76.8v25.6c0 14.1 11.5 25.6 25.6 25.6 14.1 0 25.6-11.5 25.6-25.6z"></path> | ||
<path d="M230.4 179.2V256c0 14.1 11.5 25.6 25.6 25.6s25.6-11.5 25.6-25.6v-76.8c0-14.1-11.5-25.6-25.6-25.6s-25.6 11.5-25.6 25.6"></path> | ||
</svg> | ||
); | ||
}); |
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,62 @@ | ||
import { PrismaClient } from "@prisma/client"; | ||
import { QSource } from "../type"; | ||
import { websiteQueueController } from "./website.controller"; | ||
const prisma = new PrismaClient(); | ||
import Sitemapper from "sitemapper"; | ||
|
||
export const sitemapQueueController = async ( | ||
source: QSource, | ||
) => { | ||
const url = source.content!; | ||
|
||
const sitemapper = new Sitemapper({ | ||
url, | ||
timeout: 300000, | ||
concurrency: process.env.SITEMAPPER_CONCURRENCY | ||
? parseInt(process.env.SITEMAPPER_CONCURRENCY) | ||
: 2, | ||
retries: process.env.SITEMAPPER_MAX_RETRIES | ||
? parseInt(process.env.SITEMAPPER_MAX_RETRIES) | ||
: 1, | ||
requestHeaders: { | ||
"User-Agent": process.env.SITEMAPPER_USER_AGENT || | ||
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0'", | ||
}, | ||
}); | ||
|
||
const data = await sitemapper.fetch(); | ||
|
||
if (data.errors.length > 0) { | ||
console.log(data.errors); | ||
throw new Error("Sitemapper failed to fetch sitemap"); | ||
} | ||
|
||
const links = data.sites; | ||
|
||
for (const link of links) { | ||
const newSource = await prisma.botSource.create({ | ||
data: { | ||
botId: source.botId, | ||
content: link, | ||
isPending: true, | ||
status: "PENDING", | ||
type: "website", | ||
}, | ||
}); | ||
|
||
await websiteQueueController({ | ||
...newSource, | ||
embedding: source.embedding, | ||
}); | ||
|
||
await prisma.botSource.update({ | ||
where: { | ||
id: newSource.id, | ||
}, | ||
data: { | ||
status: "FINISHED", | ||
isPending: false, | ||
}, | ||
}); | ||
} | ||
}; |
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 |
---|---|---|
|
@@ -5,4 +5,5 @@ export const SUPPORTED_SOURCE_TYPES = [ | |
"github", | ||
"youtube", | ||
"rest", | ||
"sitemap", | ||
]; |
Oops, something went wrong.