Open
Conversation
Implement ChatGPT App specification v0.5 output format to enable rich UI widgets in ChatGPT. This allows NLWeb to display search results using ChatGPT's native list widgets.
Backend changes:
- Add output_format parameter to NLWebHandler (default: "default")
- Transform responses to ChatGPT App format when output_format=chatgptapp
- Send _meta block once with conversation_id, version, openai/outputTemplate, query_rewrite, and decontextualized_query
- Stream content blocks as {"type": "resource", "resource": {"data": [...]}}
- Filter out non-essential messages (begin/end-nlweb-response, query_rewrite, decontextualized_query, etc.)
- Only _meta and content messages are sent for chatgptapp format
- MCP defaults to chatgptapp format
Frontend changes:
- Set SSE as default connection type (was WebSocket)
- Users can still use WebSocket with ?mode=websocket
Key features:
- Full backward compatibility - default format unchanged
- Preserves all data fields from original format
- Enables ChatGPT Apps SDK generic list widget (ui://widget/list.html)
- Works with any schema.org type (Restaurant, Recipe, Article, Product, etc.)
- Clean output with only _meta and content blocks
Change field names in _meta to use nlweb/ prefix for NLWeb-specific fields: - conversation_id -> nlweb/conversationId - version -> nlweb/version - query_rewrite -> nlweb/queryRewrite - decontextualized_query -> nlweb/decontextualizedQuery This follows the ChatGPT App SDK convention of namespacing custom fields to avoid conflicts with OpenAI fields like openai/outputTemplate.
- Skip nlweb/conversationId if empty - Skip nlweb/decontextualizedQuery if same as original query - Remove nlweb/queryRewrite field entirely (not needed) This keeps the _meta block minimal with only relevant fields.
For output_format=chatgptapp, transform each result item:
- Flatten all schema_object fields to top level
- Replace schema_object with grounding field containing the URL
- Preserve all existing top-level fields
Example: {schema_object: {headline: ...}} → {grounding: url, headline: ...}
This provides richer structured data for ChatGPT Apps widgets.
When transforming for chatgptapp format: - If top-level @type is 'Item' and schema_object has @type, replace with schema @type - Preserves specific schema.org types (Article, Recipe, etc.) instead of generic Item - Non-Item @type values are preserved as-is Example: {@type: 'Item', schema_object: {@type: ['Article']}} → {@type: ['Article']}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement ChatGPT App specification v0.5 output format to enable rich UI widgets in ChatGPT Apps. This allows NLWeb to display search results using ChatGPT's native list widgets.
Backend Changes
Core Files Modified
core/baseHandler.py: Addoutput_formatparameter (default: "default")core/schemas.py: Addformat_response_to_chatgpt_spec()utility functioncore/utils/message_senders.py: Transform responses and filter messages for chatgptapp formatwebserver/mcp_wrapper.py: Add output_format to MCP ask tool (defaults to "chatgptapp")Response Format
When
output_format=chatgptapp:SSE Stream:
Filtered Messages:
_meta(sent once) andcontentblocks are includedFrontend Changes
static/index.html: Set SSE as default connection type (was WebSocket)?mode=websocketKey Features
Usage
HTTP/SSE:
MCP:
{ "name": "ask", "arguments": { "query": "pizza", "site": ["seriouseats"], "output_format": "chatgptapp" } }Test Plan