chore: import upstream snapshot with attribution
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
import type { ArxivGetAuthorPapersParams, ArxivGetAuthorPapersResponse } from '@/tools/arxiv/types'
|
||||
import { extractTotalResults, parseArxivXML } from '@/tools/arxiv/utils'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const getAuthorPapersTool: ToolConfig<
|
||||
ArxivGetAuthorPapersParams,
|
||||
ArxivGetAuthorPapersResponse
|
||||
> = {
|
||||
id: 'arxiv_get_author_papers',
|
||||
name: 'ArXiv Get Author Papers',
|
||||
description: 'Search for papers by a specific author on ArXiv.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
authorName: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Author name to search for',
|
||||
},
|
||||
maxResults: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Maximum number of results to return (default: 10, max: 2000)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params: ArxivGetAuthorPapersParams) => {
|
||||
const baseUrl = 'https://export.arxiv.org/api/query'
|
||||
const searchParams = new URLSearchParams()
|
||||
|
||||
searchParams.append('search_query', `au:"${params.authorName}"`)
|
||||
searchParams.append(
|
||||
'max_results',
|
||||
(params.maxResults ? Math.min(Number(params.maxResults), 2000) : 10).toString()
|
||||
)
|
||||
searchParams.append('sortBy', 'submittedDate')
|
||||
searchParams.append('sortOrder', 'descending')
|
||||
|
||||
return `${baseUrl}?${searchParams.toString()}`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/xml',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const xmlText = await response.text()
|
||||
|
||||
// Parse XML response
|
||||
const papers = parseArxivXML(xmlText)
|
||||
const totalResults = extractTotalResults(xmlText)
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
authorPapers: papers,
|
||||
totalResults,
|
||||
authorName: '', // Will be filled by the calling code
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
authorPapers: {
|
||||
type: 'json',
|
||||
description: 'Array of papers authored by the specified author',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'string' },
|
||||
title: { type: 'string' },
|
||||
summary: { type: 'string' },
|
||||
authors: { type: 'string' },
|
||||
published: { type: 'string' },
|
||||
updated: { type: 'string' },
|
||||
link: { type: 'string' },
|
||||
pdfLink: { type: 'string' },
|
||||
categories: { type: 'string' },
|
||||
primaryCategory: { type: 'string' },
|
||||
comment: { type: 'string' },
|
||||
journalRef: { type: 'string' },
|
||||
doi: { type: 'string' },
|
||||
},
|
||||
},
|
||||
},
|
||||
totalResults: {
|
||||
type: 'number',
|
||||
description: 'Total number of papers found for the author',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import type { ArxivGetPaperParams, ArxivGetPaperResponse } from '@/tools/arxiv/types'
|
||||
import { parseArxivXML } from '@/tools/arxiv/utils'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const getPaperTool: ToolConfig<ArxivGetPaperParams, ArxivGetPaperResponse> = {
|
||||
id: 'arxiv_get_paper',
|
||||
name: 'ArXiv Get Paper',
|
||||
description: 'Get detailed information about a specific ArXiv paper by its ID.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
paperId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'ArXiv paper ID (e.g., "1706.03762")',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params: ArxivGetPaperParams) => {
|
||||
// Clean paper ID - remove arxiv.org URLs if present
|
||||
let paperId = params.paperId
|
||||
if (paperId.includes('arxiv.org/abs/')) {
|
||||
paperId = paperId.split('arxiv.org/abs/')[1]
|
||||
}
|
||||
|
||||
const baseUrl = 'https://export.arxiv.org/api/query'
|
||||
const searchParams = new URLSearchParams()
|
||||
searchParams.append('id_list', paperId)
|
||||
|
||||
return `${baseUrl}?${searchParams.toString()}`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/xml',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const xmlText = await response.text()
|
||||
const papers = parseArxivXML(xmlText)
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
paper: papers[0] || null,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
paper: {
|
||||
type: 'json',
|
||||
description: 'Detailed information about the requested ArXiv paper',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'string' },
|
||||
title: { type: 'string' },
|
||||
summary: { type: 'string' },
|
||||
authors: { type: 'string' },
|
||||
published: { type: 'string' },
|
||||
updated: { type: 'string' },
|
||||
link: { type: 'string' },
|
||||
pdfLink: { type: 'string' },
|
||||
categories: { type: 'string' },
|
||||
primaryCategory: { type: 'string' },
|
||||
comment: { type: 'string' },
|
||||
journalRef: { type: 'string' },
|
||||
doi: { type: 'string' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { getAuthorPapersTool } from '@/tools/arxiv/get_author_papers'
|
||||
import { getPaperTool } from '@/tools/arxiv/get_paper'
|
||||
import { searchTool } from '@/tools/arxiv/search'
|
||||
|
||||
export const arxivSearchTool = searchTool
|
||||
export const arxivGetPaperTool = getPaperTool
|
||||
export const arxivGetAuthorPapersTool = getAuthorPapersTool
|
||||
@@ -0,0 +1,125 @@
|
||||
import type { ArxivSearchParams, ArxivSearchResponse } from '@/tools/arxiv/types'
|
||||
import { extractTotalResults, parseArxivXML } from '@/tools/arxiv/utils'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const searchTool: ToolConfig<ArxivSearchParams, ArxivSearchResponse> = {
|
||||
id: 'arxiv_search',
|
||||
name: 'ArXiv Search',
|
||||
description: 'Search for academic papers on ArXiv by keywords, authors, titles, or other fields.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
searchQuery: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The search query to execute',
|
||||
},
|
||||
searchField: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description:
|
||||
'Field to search in: all, ti (title), au (author), abs (abstract), co (comment), jr (journal), cat (category), rn (report number)',
|
||||
},
|
||||
maxResults: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Maximum number of results to return (default: 10, max: 2000)',
|
||||
},
|
||||
sortBy: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Sort by: relevance, lastUpdatedDate, submittedDate (default: relevance)',
|
||||
},
|
||||
sortOrder: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Sort order: ascending, descending (default: descending)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params: ArxivSearchParams) => {
|
||||
const baseUrl = 'https://export.arxiv.org/api/query'
|
||||
const searchParams = new URLSearchParams()
|
||||
|
||||
// Build search query
|
||||
let searchQuery = params.searchQuery
|
||||
if (params.searchField && params.searchField !== 'all') {
|
||||
searchQuery = `${params.searchField}:${params.searchQuery}`
|
||||
}
|
||||
searchParams.append('search_query', searchQuery)
|
||||
|
||||
// Add optional parameters
|
||||
if (params.maxResults) {
|
||||
searchParams.append('max_results', Math.min(Number(params.maxResults), 2000).toString())
|
||||
} else {
|
||||
searchParams.append('max_results', '10')
|
||||
}
|
||||
|
||||
if (params.sortBy) {
|
||||
searchParams.append('sortBy', params.sortBy)
|
||||
}
|
||||
|
||||
if (params.sortOrder) {
|
||||
searchParams.append('sortOrder', params.sortOrder)
|
||||
}
|
||||
|
||||
return `${baseUrl}?${searchParams.toString()}`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/xml',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const xmlText = await response.text()
|
||||
|
||||
// Parse XML response
|
||||
const papers = parseArxivXML(xmlText)
|
||||
const totalResults = extractTotalResults(xmlText)
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
papers,
|
||||
totalResults,
|
||||
query: '', // Will be filled by the calling code
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
papers: {
|
||||
type: 'json',
|
||||
description: 'Array of papers matching the search query',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'string' },
|
||||
title: { type: 'string' },
|
||||
summary: { type: 'string' },
|
||||
authors: { type: 'string' },
|
||||
published: { type: 'string' },
|
||||
updated: { type: 'string' },
|
||||
link: { type: 'string' },
|
||||
pdfLink: { type: 'string' },
|
||||
categories: { type: 'string' },
|
||||
primaryCategory: { type: 'string' },
|
||||
comment: { type: 'string' },
|
||||
journalRef: { type: 'string' },
|
||||
doi: { type: 'string' },
|
||||
},
|
||||
},
|
||||
},
|
||||
totalResults: {
|
||||
type: 'number',
|
||||
description: 'Total number of results found for the search query',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// Common types for ArXiv tools
|
||||
import type { ToolResponse } from '@/tools/types'
|
||||
|
||||
// Search tool types
|
||||
export interface ArxivSearchParams {
|
||||
searchQuery: string
|
||||
searchField?: 'all' | 'ti' | 'au' | 'abs' | 'co' | 'jr' | 'cat' | 'rn'
|
||||
maxResults?: number
|
||||
sortBy?: 'relevance' | 'lastUpdatedDate' | 'submittedDate'
|
||||
sortOrder?: 'ascending' | 'descending'
|
||||
}
|
||||
|
||||
export interface ArxivPaper {
|
||||
id: string
|
||||
title: string
|
||||
summary: string
|
||||
authors: string[]
|
||||
published: string
|
||||
updated: string
|
||||
link: string
|
||||
pdfLink: string
|
||||
categories: string[]
|
||||
primaryCategory: string
|
||||
comment?: string
|
||||
journalRef?: string
|
||||
doi?: string
|
||||
}
|
||||
|
||||
export interface ArxivSearchResponse extends ToolResponse {
|
||||
output: {
|
||||
papers: ArxivPaper[]
|
||||
totalResults: number
|
||||
query: string
|
||||
}
|
||||
}
|
||||
|
||||
// Get Paper Details tool types
|
||||
export interface ArxivGetPaperParams {
|
||||
paperId: string
|
||||
}
|
||||
|
||||
export interface ArxivGetPaperResponse extends ToolResponse {
|
||||
output: {
|
||||
paper: ArxivPaper
|
||||
}
|
||||
}
|
||||
|
||||
// Get Author Papers tool types
|
||||
export interface ArxivGetAuthorPapersParams {
|
||||
authorName: string
|
||||
maxResults?: number
|
||||
}
|
||||
|
||||
export interface ArxivGetAuthorPapersResponse extends ToolResponse {
|
||||
output: {
|
||||
authorPapers: ArxivPaper[]
|
||||
totalResults: number
|
||||
authorName: string
|
||||
}
|
||||
}
|
||||
|
||||
export type ArxivResponse =
|
||||
| ArxivSearchResponse
|
||||
| ArxivGetPaperResponse
|
||||
| ArxivGetAuthorPapersResponse
|
||||
@@ -0,0 +1,90 @@
|
||||
import type { ArxivPaper } from '@/tools/arxiv/types'
|
||||
|
||||
export function parseArxivXML(xmlText: string): ArxivPaper[] {
|
||||
const papers: ArxivPaper[] = []
|
||||
|
||||
// Extract entries using regex (since we don't have XML parser in this environment)
|
||||
const entryRegex = /<entry>([\s\S]*?)<\/entry>/g
|
||||
let match
|
||||
|
||||
while ((match = entryRegex.exec(xmlText)) !== null) {
|
||||
const entryXml = match[1]
|
||||
|
||||
const paper: ArxivPaper = {
|
||||
id: extractXmlValue(entryXml, 'id')?.replace('http://arxiv.org/abs/', '') || '',
|
||||
title: cleanText(extractXmlValue(entryXml, 'title') || ''),
|
||||
summary: cleanText(extractXmlValue(entryXml, 'summary') || ''),
|
||||
authors: extractAuthors(entryXml),
|
||||
published: extractXmlValue(entryXml, 'published') || '',
|
||||
updated: extractXmlValue(entryXml, 'updated') || '',
|
||||
link: extractXmlValue(entryXml, 'id') || '',
|
||||
pdfLink: extractPdfLink(entryXml),
|
||||
categories: extractCategories(entryXml),
|
||||
primaryCategory: extractXmlAttribute(entryXml, 'arxiv:primary_category', 'term') || '',
|
||||
comment: extractXmlValue(entryXml, 'arxiv:comment'),
|
||||
journalRef: extractXmlValue(entryXml, 'arxiv:journal_ref'),
|
||||
doi: extractXmlValue(entryXml, 'arxiv:doi'),
|
||||
}
|
||||
|
||||
papers.push(paper)
|
||||
}
|
||||
|
||||
return papers
|
||||
}
|
||||
|
||||
export function extractTotalResults(xmlText: string): number {
|
||||
const totalResultsMatch = xmlText.match(
|
||||
/<opensearch:totalResults[^>]*>(\d+)<\/opensearch:totalResults>/
|
||||
)
|
||||
return totalResultsMatch ? Number.parseInt(totalResultsMatch[1], 10) : 0
|
||||
}
|
||||
|
||||
export function extractXmlValue(xml: string, tagName: string): string | undefined {
|
||||
const regex = new RegExp(`<${tagName}[^>]*>([\\s\\S]*?)<\/${tagName}>`)
|
||||
const match = xml.match(regex)
|
||||
return match ? match[1].trim() : undefined
|
||||
}
|
||||
|
||||
export function extractXmlAttribute(
|
||||
xml: string,
|
||||
tagName: string,
|
||||
attrName: string
|
||||
): string | undefined {
|
||||
const regex = new RegExp(`<${tagName}[^>]*${attrName}="([^"]*)"[^>]*>`)
|
||||
const match = xml.match(regex)
|
||||
return match ? match[1] : undefined
|
||||
}
|
||||
|
||||
export function extractAuthors(entryXml: string): string[] {
|
||||
const authors: string[] = []
|
||||
const authorRegex = /<author[^>]*>[\s\S]*?<name>([^<]+)<\/name>[\s\S]*?<\/author>/g
|
||||
let match
|
||||
|
||||
while ((match = authorRegex.exec(entryXml)) !== null) {
|
||||
authors.push(match[1].trim())
|
||||
}
|
||||
|
||||
return authors
|
||||
}
|
||||
|
||||
export function extractPdfLink(entryXml: string): string {
|
||||
const linkRegex = /<link[^>]*href="([^"]*)"[^>]*title="pdf"[^>]*>/
|
||||
const match = entryXml.match(linkRegex)
|
||||
return match ? match[1] : ''
|
||||
}
|
||||
|
||||
export function extractCategories(entryXml: string): string[] {
|
||||
const categories: string[] = []
|
||||
const categoryRegex = /<category[^>]*term="([^"]*)"[^>]*>/g
|
||||
let match
|
||||
|
||||
while ((match = categoryRegex.exec(entryXml)) !== null) {
|
||||
categories.push(match[1])
|
||||
}
|
||||
|
||||
return categories
|
||||
}
|
||||
|
||||
export function cleanText(text: string): string {
|
||||
return text.replace(/\s+/g, ' ').trim()
|
||||
}
|
||||
Reference in New Issue
Block a user