mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-12 01:02:39 +02:00
test(e2e): route connector PDF canary responses in chat fake & add connector PDF canaries
This commit is contained in:
parent
5a2357b981
commit
fbfde74cdc
2 changed files with 78 additions and 0 deletions
|
|
@ -13,6 +13,10 @@ from langchain_core.messages import AIMessage, AIMessageChunk, BaseMessage
|
|||
from langchain_core.outputs import ChatGeneration, ChatGenerationChunk, ChatResult
|
||||
|
||||
DRIVE_CANARY_TOKEN = "SURFSENSE_E2E_CANARY_TOKEN_DRIVE_001"
|
||||
DRIVE_PDF_CANARY_TOKEN = "SURFSENSE_E2E_CANARY_TOKEN_DRIVE_PDF_001"
|
||||
DRIVE_PDF_CANARY_FILE = "e2e-canary.pdf"
|
||||
COMPOSIO_DRIVE_PDF_CANARY_TOKEN = "SURFSENSE_E2E_CANARY_TOKEN_COMPOSIO_DRIVE_PDF_001"
|
||||
COMPOSIO_DRIVE_PDF_CANARY_FILE = "e2e-composio-canary.pdf"
|
||||
GMAIL_CANARY_TOKEN = "SURFSENSE_E2E_CANARY_TOKEN_GMAIL_001"
|
||||
GMAIL_CANARY_SUBJECT = "E2E Canary Email"
|
||||
GMAIL_CANARY_MESSAGE_ID = "fake-msg-canary-001"
|
||||
|
|
@ -20,8 +24,12 @@ CALENDAR_CANARY_TOKEN = "SURFSENSE_E2E_CANARY_TOKEN_CALENDAR_001"
|
|||
CALENDAR_CANARY_SUMMARY = "E2E Canary Calendar Event"
|
||||
ONEDRIVE_CANARY_TOKEN = "SURFSENSE_E2E_CANARY_TOKEN_ONEDRIVE_001"
|
||||
ONEDRIVE_CANARY_FILE = "e2e-onedrive-canary.txt"
|
||||
ONEDRIVE_PDF_CANARY_TOKEN = "SURFSENSE_E2E_CANARY_TOKEN_ONEDRIVE_PDF_001"
|
||||
ONEDRIVE_PDF_CANARY_FILE = "e2e-onedrive-canary.pdf"
|
||||
DROPBOX_CANARY_TOKEN = "SURFSENSE_E2E_CANARY_TOKEN_DROPBOX_001"
|
||||
DROPBOX_CANARY_FILE = "e2e-dropbox-canary.txt"
|
||||
DROPBOX_PDF_CANARY_TOKEN = "SURFSENSE_E2E_CANARY_TOKEN_DROPBOX_PDF_001"
|
||||
DROPBOX_PDF_CANARY_FILE = "e2e-dropbox-canary.pdf"
|
||||
NOTION_CANARY_TOKEN = "SURFSENSE_E2E_CANARY_TOKEN_NOTION_001"
|
||||
NOTION_CANARY_TITLE = "E2E Canary Notion Page"
|
||||
CONFLUENCE_CANARY_TOKEN = "SURFSENSE_E2E_CANARY_TOKEN_CONFLUENCE_001"
|
||||
|
|
@ -143,14 +151,32 @@ class FakeChatLLM(BaseChatModel):
|
|||
latest_human,
|
||||
("drive", "file", "e2e-canary.txt"),
|
||||
)
|
||||
wants_drive_pdf = _contains_any(
|
||||
latest_human,
|
||||
(
|
||||
"drive pdf",
|
||||
DRIVE_PDF_CANARY_FILE,
|
||||
DRIVE_PDF_CANARY_TOKEN,
|
||||
COMPOSIO_DRIVE_PDF_CANARY_FILE,
|
||||
COMPOSIO_DRIVE_PDF_CANARY_TOKEN,
|
||||
),
|
||||
) or (wants_drive and "pdf" in latest_human.lower())
|
||||
wants_onedrive = _contains_any(
|
||||
latest_human,
|
||||
("onedrive", ONEDRIVE_CANARY_FILE, ONEDRIVE_CANARY_TOKEN),
|
||||
)
|
||||
wants_onedrive_pdf = wants_onedrive and _contains_any(
|
||||
latest_human,
|
||||
("pdf", ONEDRIVE_PDF_CANARY_FILE, ONEDRIVE_PDF_CANARY_TOKEN),
|
||||
)
|
||||
wants_dropbox = _contains_any(
|
||||
latest_human,
|
||||
("dropbox", DROPBOX_CANARY_FILE, DROPBOX_CANARY_TOKEN),
|
||||
)
|
||||
wants_dropbox_pdf = wants_dropbox and _contains_any(
|
||||
latest_human,
|
||||
("pdf", DROPBOX_PDF_CANARY_FILE, DROPBOX_PDF_CANARY_TOKEN),
|
||||
)
|
||||
wants_notion = _contains_any(
|
||||
latest_human,
|
||||
("notion", "page", NOTION_CANARY_TITLE),
|
||||
|
|
@ -196,16 +222,36 @@ class FakeChatLLM(BaseChatModel):
|
|||
or "fake-file-canary" in prompt_text
|
||||
or DRIVE_CANARY_TOKEN in prompt_text
|
||||
)
|
||||
has_native_drive_pdf_evidence = (
|
||||
DRIVE_PDF_CANARY_FILE in prompt_text
|
||||
or "fake-file-pdf-native" in prompt_text
|
||||
or DRIVE_PDF_CANARY_TOKEN in prompt_text
|
||||
)
|
||||
has_composio_drive_pdf_evidence = (
|
||||
COMPOSIO_DRIVE_PDF_CANARY_FILE in prompt_text
|
||||
or "fake-file-pdf-composio" in prompt_text
|
||||
or COMPOSIO_DRIVE_PDF_CANARY_TOKEN in prompt_text
|
||||
)
|
||||
has_onedrive_evidence = (
|
||||
ONEDRIVE_CANARY_FILE in prompt_text
|
||||
or "fake-onedrive-canary" in prompt_text
|
||||
or ONEDRIVE_CANARY_TOKEN in prompt_text
|
||||
)
|
||||
has_onedrive_pdf_evidence = (
|
||||
ONEDRIVE_PDF_CANARY_FILE in prompt_text
|
||||
or "fake-onedrive-pdf-canary" in prompt_text
|
||||
or ONEDRIVE_PDF_CANARY_TOKEN in prompt_text
|
||||
)
|
||||
has_dropbox_evidence = (
|
||||
DROPBOX_CANARY_FILE in prompt_text
|
||||
or "id:fake-dropbox-canary" in prompt_text
|
||||
or DROPBOX_CANARY_TOKEN in prompt_text
|
||||
)
|
||||
has_dropbox_pdf_evidence = (
|
||||
DROPBOX_PDF_CANARY_FILE in prompt_text
|
||||
or "id:fake-dropbox-pdf-canary" in prompt_text
|
||||
or DROPBOX_PDF_CANARY_TOKEN in prompt_text
|
||||
)
|
||||
has_notion_evidence = (
|
||||
NOTION_CANARY_TITLE in prompt_text or NOTION_CANARY_TOKEN in prompt_text
|
||||
)
|
||||
|
|
@ -256,10 +302,18 @@ class FakeChatLLM(BaseChatModel):
|
|||
return f"Calendar content found: {CALENDAR_CANARY_TOKEN}"
|
||||
if wants_gmail and has_gmail_evidence:
|
||||
return f"Gmail content found: {GMAIL_CANARY_TOKEN}"
|
||||
if wants_onedrive_pdf and has_onedrive_pdf_evidence:
|
||||
return f"OneDrive PDF content found: {ONEDRIVE_PDF_CANARY_TOKEN}"
|
||||
if wants_onedrive and has_onedrive_evidence:
|
||||
return f"OneDrive content found: {ONEDRIVE_CANARY_TOKEN}"
|
||||
if wants_dropbox_pdf and has_dropbox_pdf_evidence:
|
||||
return f"Dropbox PDF content found: {DROPBOX_PDF_CANARY_TOKEN}"
|
||||
if wants_dropbox and has_dropbox_evidence:
|
||||
return f"Dropbox content found: {DROPBOX_CANARY_TOKEN}"
|
||||
if wants_drive_pdf and has_native_drive_pdf_evidence:
|
||||
return f"Drive PDF content found: {DRIVE_PDF_CANARY_TOKEN}"
|
||||
if wants_drive_pdf and has_composio_drive_pdf_evidence:
|
||||
return f"Drive PDF content found: {COMPOSIO_DRIVE_PDF_CANARY_TOKEN}"
|
||||
if wants_drive and has_drive_evidence:
|
||||
return f"Drive content found: {DRIVE_CANARY_TOKEN}"
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import { randomUUID } from "node:crypto";
|
|||
*/
|
||||
export const CANARY_TOKENS = {
|
||||
driveCanaryFile: "SURFSENSE_E2E_CANARY_TOKEN_DRIVE_001",
|
||||
drivePdfCanary: "SURFSENSE_E2E_CANARY_TOKEN_DRIVE_PDF_001",
|
||||
composioDrivePdfCanary: "SURFSENSE_E2E_CANARY_TOKEN_COMPOSIO_DRIVE_PDF_001",
|
||||
driveReadme: "SURFSENSE_E2E_README_MARKER",
|
||||
driveBudget: "SURFSENSE_E2E_BUDGET_MARKER",
|
||||
driveRoadmap: "SURFSENSE_E2E_ROADMAP_MARKER",
|
||||
|
|
@ -21,7 +23,9 @@ export const CANARY_TOKENS = {
|
|||
gmailCanary: "SURFSENSE_E2E_CANARY_TOKEN_GMAIL_001",
|
||||
calendarCanary: "SURFSENSE_E2E_CANARY_TOKEN_CALENDAR_001",
|
||||
onedriveCanary: "SURFSENSE_E2E_CANARY_TOKEN_ONEDRIVE_001",
|
||||
onedrivePdfCanary: "SURFSENSE_E2E_CANARY_TOKEN_ONEDRIVE_PDF_001",
|
||||
dropboxCanary: "SURFSENSE_E2E_CANARY_TOKEN_DROPBOX_001",
|
||||
dropboxPdfCanary: "SURFSENSE_E2E_CANARY_TOKEN_DROPBOX_PDF_001",
|
||||
notionCanary: "SURFSENSE_E2E_CANARY_TOKEN_NOTION_001",
|
||||
confluenceCanary: "SURFSENSE_E2E_CANARY_TOKEN_CONFLUENCE_001",
|
||||
linearCanary: "SURFSENSE_E2E_CANARY_TOKEN_LINEAR_001",
|
||||
|
|
@ -38,6 +42,16 @@ export const CANARY_TOKENS = {
|
|||
*/
|
||||
export const FAKE_DRIVE_FILES = {
|
||||
canary: { id: "fake-file-canary", name: "e2e-canary.txt", mimeType: "text/plain" },
|
||||
pdfNative: {
|
||||
id: "fake-file-pdf-native",
|
||||
name: "e2e-canary.pdf",
|
||||
mimeType: "application/pdf",
|
||||
},
|
||||
pdfComposio: {
|
||||
id: "fake-file-pdf-composio",
|
||||
name: "e2e-composio-canary.pdf",
|
||||
mimeType: "application/pdf",
|
||||
},
|
||||
readme: { id: "fake-file-readme", name: "README.md", mimeType: "text/markdown" },
|
||||
budget: { id: "fake-file-budget", name: "Q1-Budget.csv", mimeType: "text/csv" },
|
||||
} as const;
|
||||
|
|
@ -65,6 +79,11 @@ export const FAKE_ONEDRIVE_FILES = {
|
|||
name: "e2e-onedrive-canary.txt",
|
||||
mimeType: "text/plain",
|
||||
},
|
||||
pdf: {
|
||||
id: "fake-onedrive-pdf-canary",
|
||||
name: "e2e-onedrive-canary.pdf",
|
||||
mimeType: "application/pdf",
|
||||
},
|
||||
} as const;
|
||||
|
||||
/**
|
||||
|
|
@ -77,6 +96,11 @@ export const FAKE_DROPBOX_FILES = {
|
|||
name: "e2e-dropbox-canary.txt",
|
||||
mimeType: "text/plain",
|
||||
},
|
||||
pdf: {
|
||||
id: "/e2e-dropbox-canary.pdf",
|
||||
name: "e2e-dropbox-canary.pdf",
|
||||
mimeType: "application/pdf",
|
||||
},
|
||||
} as const;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue