Skip to content

Commit 33883c6

Browse files
Robbie1977claude
andcommitted
Fix link display, strip citation artifacts, improve prompt clarity
- Fix dark blue links: remove ChatMessage override that replaced custom renderLink with unstyled <a> tags — all links now consistently cyan #66d9ff - Strip OpenAI Responses API citation artifacts (citeturn*, PUA-bracketed citations U+E200-E2FF, 【...】 brackets) in linkifyVfbTerms - Auto-linkify FBrf IDs to FlyBase (alongside existing VFB_/FBbt_ linking) - Simplify DISPLAYING RESULTS prompt to avoid LLM outputting literal template text like "Thumbnail:" or "link to VFB page" - Update CITATIONS prompt: use author/year as link text for FBrf references, markdown links for DOI and PubMed — never show bare reference IDs - Bump version to 3.0.4 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 73e2be4 commit 33883c6

3 files changed

Lines changed: 24 additions & 14 deletions

File tree

app/api/chat/route.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,10 @@ CITATIONS:
695695
- ONLY cite publications that are explicitly returned in VFB data Publications field or from PubMed/bioRxiv tool results
696696
- Do NOT generate citations from general knowledge or invent DOIs
697697
- If no publications are available in VFB data, do not include any citations
698-
- For publications from VFB data, convert DOI or FBrf IDs to proper links:
699-
- DOI format: https://doi.org/XXXXXXX
700-
- FBrf format: https://flybase.org/reports/FBrfXXXXXXX
698+
- For FlyBase references (FBrf IDs), use markdown link format with the citation as link text: [Nern et al., 2025](https://flybase.org/reports/FBrf0262545). Do NOT show the bare FBrf ID — use the author/year as the clickable link text.
699+
- For DOIs, use markdown link format: [Paper Title](https://doi.org/XXXXXXX)
700+
- For PubMed results, use markdown link format: [Paper Title](https://pubmed.ncbi.nlm.nih.gov/PMID/)
701+
- Never show bare reference IDs (FBrf, PMID, DOI) when you have the author names and year — always make the human-readable citation the clickable link.
701702
- Do not reference "common Drosophila neuroscience papers" unless they appear in the actual VFB data for the specific entity being discussed
702703
703704
VFB TOOLS:
@@ -737,11 +738,11 @@ STRATEGY:
737738
6. For connectivity queries: If a neuron class (IsClass: true) doesn't have connectivity data, look at individual neuron instances from connectomes.
738739
7. Construct VFB URLs: https://v2.virtualflybrain.org/org.geppetto.frontend/geppetto?id=<id>&i=<template_id>,<image_ids>
739740
740-
DISPLAYING IMAGES:
741-
ONLY show thumbnail images when they are actually available AND validated to exist in the VFB data. NEVER make up or invent thumbnail URLs.
742-
When vfb_get_term_info returns visual data, include thumbnail URLs in your response using markdown image syntax:
743-
![label](thumbnail_url)
744-
Do NOT show any images if no validated thumbnail URLs are available in the data. The user's chat interface renders these as compact thumbnails that expand on hover.
741+
DISPLAYING RESULTS:
742+
- Use the human-readable name as markdown link text, not bare IDs. Example: [medulla](https://virtualflybrain.org/reports/FBbt_00003748) not FBbt_00003748.
743+
- When vfb_get_term_info returns thumbnail URLs, include them using markdown image syntax: ![label](thumbnail_url)
744+
- Only use thumbnail URLs actually present in the tool response data. Never invent URLs.
745+
- The chat UI renders thumbnails as compact images that expand on hover.
745746
746747
SUGGESTED FOLLOW-UP QUESTIONS:
747748
At the end of your responses, when appropriate (not always necessary), suggest 2-4 follow-up questions the user might want to ask next. Include these as plain-text URLs in one of these formats:

app/page.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ const ChatMessage = memo(function ChatMessage({ msg, markdownComponents }) {
3838
style={msg.role === 'reasoning' ? { fontSize: '0.85em', fontStyle: 'italic', color: '#999' } : {}}
3939
>
4040
<ReactMarkdown
41-
components={{
42-
...markdownComponents,
43-
a: ({ node, ...props }) => <a {...props} target="_blank" rel="noreferrer" />
44-
}}
41+
components={markdownComponents}
4542
>
4643
{msg.content}
4744
</ReactMarkdown>
@@ -95,15 +92,27 @@ export default function Home() {
9592
const linkifyVfbTerms = (text) => {
9693
if (!text) return text
9794

95+
// Strip OpenAI Responses API citation artifacts in all known formats
96+
// Private Use Area chars (U+E200-E2FF) used as citation delimiters by OpenAI
97+
let cleaned = text.replace(/[\uE200-\uE2FF]cite[\uE200-\uE2FF]\w*[\uE200-\uE2FF]/g, '') // PUA-bracketed citations e.g. \uE200cite\uE202turn1data\uE201
98+
cleaned = cleaned.replace(/\u3010[^\u3011]*\u3011/g, '') // 【...】 bracketed citations
99+
cleaned = cleaned.replace(/[\uE200-\uE2FF]/g, '') // any remaining PUA chars
100+
cleaned = cleaned.replace(/citeturn[\w?]*/g, '') // bare citeturn artifacts
101+
cleaned = cleaned.replace(/\bcite(?=\[|https?:\/\/)/g, '') // orphaned "cite" before links
102+
// Clean up leftover whitespace from stripped artifacts
103+
cleaned = cleaned.replace(/ {2,}/g, ' ')
104+
98105
const urlPlaceholders = []
99106
const URL_PLACEHOLDER = '\x00URL'
100-
let result = text.replace(/https?:\/\/[^\s)]+/g, (url) => {
107+
let result = cleaned.replace(/https?:\/\/[^\s)]+/g, (url) => {
101108
urlPlaceholders.push(url)
102109
return `${URL_PLACEHOLDER}${urlPlaceholders.length - 1}\x00`
103110
})
104111

105112
// Avoid double-linking IDs that are already inside markdown links.
113+
// Link VFB and FBbt IDs to VFB, FBrf IDs to FlyBase
106114
result = result.replace(/(?<!\[)(?<!\]\()(\b(FBbt_\d{8}|VFB_\d{8})\b)/g, '[$1](https://virtualflybrain.org/reports/$1)')
115+
result = result.replace(/(?<!\[)(?<!\]\()(\b(FBrf\d{7})\b)/g, '[$1](https://flybase.org/reports/$1)')
107116

108117
// Restore protected URLs
109118
result = result.replace(new RegExp(`${URL_PLACEHOLDER}(\\d+)\\x00`, 'g'), (_, idx) => urlPlaceholders[Number(idx)])

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vfb-chat-client",
3-
"version": "3.0.3",
3+
"version": "3.0.4",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",

0 commit comments

Comments
 (0)