mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 01:06:23 +02:00
replace text-based autocomplete with vision-based endpoint
This commit is contained in:
parent
ced7f7562a
commit
aeb3f13f91
6 changed files with 102 additions and 133 deletions
|
|
@ -1,28 +1,29 @@
|
|||
from fastapi import APIRouter, Depends, Query
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi.responses import StreamingResponse
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.db import User, get_async_session
|
||||
from app.services.autocomplete_service import stream_autocomplete
|
||||
from app.services.new_streaming_service import VercelStreamingService
|
||||
from app.services.vision_autocomplete_service import stream_vision_autocomplete
|
||||
from app.users import current_active_user
|
||||
|
||||
router = APIRouter(prefix="/autocomplete", tags=["autocomplete"])
|
||||
|
||||
|
||||
@router.post("/stream")
|
||||
async def autocomplete_stream(
|
||||
text: str = Query(..., description="Current text in the input field"),
|
||||
cursor_position: int = Query(-1, description="Cursor position in the text (-1 for end)"),
|
||||
search_space_id: int = Query(..., description="Search space ID for KB context and LLM config"),
|
||||
class VisionAutocompleteRequest(BaseModel):
|
||||
screenshot: str
|
||||
search_space_id: int
|
||||
|
||||
|
||||
@router.post("/vision/stream")
|
||||
async def vision_autocomplete_stream(
|
||||
body: VisionAutocompleteRequest,
|
||||
user: User = Depends(current_active_user),
|
||||
session: AsyncSession = Depends(get_async_session),
|
||||
):
|
||||
if cursor_position < 0:
|
||||
cursor_position = len(text)
|
||||
|
||||
return StreamingResponse(
|
||||
stream_autocomplete(text, cursor_position, search_space_id, session),
|
||||
stream_vision_autocomplete(body.screenshot, body.search_space_id, session),
|
||||
media_type="text/event-stream",
|
||||
headers={
|
||||
**VercelStreamingService.get_response_headers(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue