mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-02 22:01:05 +02:00
commit
ad32ab0b97
4 changed files with 74 additions and 43 deletions
|
|
@ -39,6 +39,7 @@ class DocumentType(str, Enum):
|
||||||
FILE = "FILE"
|
FILE = "FILE"
|
||||||
SLACK_CONNECTOR = "SLACK_CONNECTOR"
|
SLACK_CONNECTOR = "SLACK_CONNECTOR"
|
||||||
NOTION_CONNECTOR = "NOTION_CONNECTOR"
|
NOTION_CONNECTOR = "NOTION_CONNECTOR"
|
||||||
|
YOUTUBE_VIDEO = "YOUTUBE_VIDEO"
|
||||||
|
|
||||||
class SearchSourceConnectorType(str, Enum):
|
class SearchSourceConnectorType(str, Enum):
|
||||||
SERPER_API = "SERPER_API"
|
SERPER_API = "SERPER_API"
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,13 @@ async def create_documents(
|
||||||
url,
|
url,
|
||||||
request.search_space_id
|
request.search_space_id
|
||||||
)
|
)
|
||||||
|
elif request.document_type == DocumentType.YOUTUBE_VIDEO:
|
||||||
|
for url in request.content:
|
||||||
|
fastapi_background_tasks.add_task(
|
||||||
|
process_youtube_video_with_new_session,
|
||||||
|
url,
|
||||||
|
request.search_space_id
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=400,
|
status_code=400,
|
||||||
|
|
@ -117,44 +124,6 @@ async def create_documents(
|
||||||
detail=f"Failed to upload files: {str(e)}"
|
detail=f"Failed to upload files: {str(e)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
async def process_extension_document_with_new_session(
|
|
||||||
individual_document,
|
|
||||||
search_space_id: int
|
|
||||||
):
|
|
||||||
"""Create a new session and process extension document."""
|
|
||||||
from app.db import async_session_maker
|
|
||||||
|
|
||||||
async with async_session_maker() as session:
|
|
||||||
try:
|
|
||||||
await add_extension_received_document(session, individual_document, search_space_id)
|
|
||||||
except Exception as e:
|
|
||||||
import logging
|
|
||||||
logging.error(f"Error processing extension document: {str(e)}")
|
|
||||||
|
|
||||||
async def process_crawled_url_with_new_session(
|
|
||||||
url: str,
|
|
||||||
search_space_id: int
|
|
||||||
):
|
|
||||||
"""Create a new session and process crawled URL."""
|
|
||||||
from app.db import async_session_maker
|
|
||||||
|
|
||||||
async with async_session_maker() as session:
|
|
||||||
try:
|
|
||||||
await add_crawled_url_document(session, url, search_space_id)
|
|
||||||
except Exception as e:
|
|
||||||
import logging
|
|
||||||
logging.error(f"Error processing crawled URL: {str(e)}")
|
|
||||||
|
|
||||||
async def process_file_in_background_with_new_session(
|
|
||||||
file_path: str,
|
|
||||||
filename: str,
|
|
||||||
search_space_id: int
|
|
||||||
):
|
|
||||||
"""Create a new session and process file."""
|
|
||||||
from app.db import async_session_maker
|
|
||||||
|
|
||||||
async with async_session_maker() as session:
|
|
||||||
await process_file_in_background(file_path, filename, search_space_id, session)
|
|
||||||
|
|
||||||
async def process_file_in_background(
|
async def process_file_in_background(
|
||||||
file_path: str,
|
file_path: str,
|
||||||
|
|
@ -348,4 +317,60 @@ async def delete_document(
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=500,
|
status_code=500,
|
||||||
detail=f"Failed to delete document: {str(e)}"
|
detail=f"Failed to delete document: {str(e)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def process_extension_document_with_new_session(
|
||||||
|
individual_document,
|
||||||
|
search_space_id: int
|
||||||
|
):
|
||||||
|
"""Create a new session and process extension document."""
|
||||||
|
from app.db import async_session_maker
|
||||||
|
|
||||||
|
async with async_session_maker() as session:
|
||||||
|
try:
|
||||||
|
await add_extension_received_document(session, individual_document, search_space_id)
|
||||||
|
except Exception as e:
|
||||||
|
import logging
|
||||||
|
logging.error(f"Error processing extension document: {str(e)}")
|
||||||
|
|
||||||
|
async def process_crawled_url_with_new_session(
|
||||||
|
url: str,
|
||||||
|
search_space_id: int
|
||||||
|
):
|
||||||
|
"""Create a new session and process crawled URL."""
|
||||||
|
from app.db import async_session_maker
|
||||||
|
|
||||||
|
async with async_session_maker() as session:
|
||||||
|
try:
|
||||||
|
await add_crawled_url_document(session, url, search_space_id)
|
||||||
|
except Exception as e:
|
||||||
|
import logging
|
||||||
|
logging.error(f"Error processing crawled URL: {str(e)}")
|
||||||
|
|
||||||
|
async def process_file_in_background_with_new_session(
|
||||||
|
file_path: str,
|
||||||
|
filename: str,
|
||||||
|
search_space_id: int
|
||||||
|
):
|
||||||
|
"""Create a new session and process file."""
|
||||||
|
from app.db import async_session_maker
|
||||||
|
|
||||||
|
async with async_session_maker() as session:
|
||||||
|
await process_file_in_background(file_path, filename, search_space_id, session)
|
||||||
|
|
||||||
|
async def process_youtube_video_with_new_session(
|
||||||
|
url: str,
|
||||||
|
search_space_id: int
|
||||||
|
):
|
||||||
|
"""Create a new session and process YouTube video."""
|
||||||
|
from app.db import async_session_maker
|
||||||
|
|
||||||
|
async with async_session_maker() as session:
|
||||||
|
try:
|
||||||
|
# TODO: Implement YouTube video processing
|
||||||
|
print("Processing YouTube video with new session")
|
||||||
|
except Exception as e:
|
||||||
|
import logging
|
||||||
|
logging.error(f"Error processing YouTube video: {str(e)}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import {
|
import {
|
||||||
|
IconBrandDiscord,
|
||||||
IconBrandGithub,
|
IconBrandGithub,
|
||||||
IconBrandLinkedin,
|
IconBrandLinkedin,
|
||||||
IconBrandTwitter,
|
IconBrandTwitter,
|
||||||
|
|
@ -59,6 +60,9 @@ export function Footer() {
|
||||||
<Link href="https://github.com/MODSetter">
|
<Link href="https://github.com/MODSetter">
|
||||||
<IconBrandGithub className="h-6 w-6 text-neutral-500 dark:text-neutral-300" />
|
<IconBrandGithub className="h-6 w-6 text-neutral-500 dark:text-neutral-300" />
|
||||||
</Link>
|
</Link>
|
||||||
|
<Link href="https://discord.gg/ejRNvftDp9">
|
||||||
|
<IconBrandDiscord className="h-6 w-6 text-neutral-500 dark:text-neutral-300" />
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { IconArrowRight, IconBrandGithub } from "@tabler/icons-react";
|
import { IconArrowRight, IconBrandGithub, IconBrandDiscord } from "@tabler/icons-react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
|
|
@ -40,10 +40,11 @@ export function ModernHeroWithGradients() {
|
||||||
</p>
|
</p>
|
||||||
<div className="flex flex-col items-center gap-6 py-6 sm:flex-row">
|
<div className="flex flex-col items-center gap-6 py-6 sm:flex-row">
|
||||||
<Link
|
<Link
|
||||||
href="/login"
|
href="https://discord.gg/ejRNvftDp9"
|
||||||
className="w-48 gap-1 rounded-full border border-gray-200 bg-gradient-to-b from-gray-50 to-gray-100 px-5 py-3 text-center text-sm font-medium text-gray-800 shadow-sm dark:border-[#404040] dark:bg-gradient-to-b dark:from-[#5B5B5D] dark:to-[#262627] dark:text-white dark:shadow-inner dark:shadow-purple-500/10"
|
className="w-48 gap-1 rounded-full border border-gray-200 bg-gradient-to-b from-gray-50 to-gray-100 px-5 py-3 text-center text-sm font-medium text-gray-800 shadow-sm dark:border-[#404040] dark:bg-gradient-to-b dark:from-[#5B5B5D] dark:to-[#262627] dark:text-white dark:shadow-inner dark:shadow-purple-500/10 flex items-center justify-center"
|
||||||
>
|
>
|
||||||
Get Started
|
<IconBrandDiscord className="h-5 w-5 mr-2" />
|
||||||
|
<span>Discord</span>
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
href="https://github.com/MODSetter/SurfSense"
|
href="https://github.com/MODSetter/SurfSense"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue