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
import highdicom as hd | |
from pydicom.sr.codedict import codes | |
# Define three textual findings | |
finding = hd.sr.TextContentItem( | |
name=codes.DCM.Finding, | |
value="FINDING TEXTUAL CONTENT GOES HERE", | |
relationship_type=hd.sr.RelationshipTypeValues.CONTAINS) | |
# Subsection of the Report. |
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
// This is a custom implementation of the POST-based stream fetching for streaming via FastAPI | |
// https://stackoverflow.com/questions/78826168/how-to-stream-llm-response-from-fastapi-to-react | |
async function* streamIterator(apiUrl, requestBody, extraHeaders) { | |
let response = await fetch(apiUrl, { | |
method: 'POST', | |
headers: { ...{'Content-Type': 'application/json'}, ...(extraHeaders || {}) }, | |
body: JSON.stringify(requestBody), | |
}); |
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
// This is a customized version of the original script: | |
// https://til.simonwillison.net/llms/streaming-llm-apis | |
// Adapted for Replicate Streaming API documentation: | |
// https://replicate.com/docs/topics/predictions/streaming | |
async function* sseStreamIterator(apiUrl, requestBody, extraHeaders) { | |
// POST. | |
let response = await fetch(apiUrl, { | |
method: 'POST', |