@@ -2,32 +2,43 @@ import "./App.css";
22
33import { ChatWindow } from "./components/ChatWindow" ;
44import { AppCallbackContext , useAppStreamCallbacks } from "./useStreamCallback" ;
5- import { useInputSchema } from "./useSchemas" ;
5+ import { useInputSchema , useOutputSchema } from "./useSchemas" ;
66import { useStreamLog } from "./useStreamLog" ;
7- import { resolveApiUrl } from "./utils/url" ;
87
98export function App ( ) {
109 const { context, callbacks } = useAppStreamCallbacks ( ) ;
1110 const { startStream, stopStream } = useStreamLog ( callbacks ) ;
1211 const inputSchema = useInputSchema ( { } ) ;
12+ const outputSchema = useOutputSchema ( { } ) ;
1313 const inputProps = inputSchema ?. data ?. schema ?. properties ;
14- const isLoading = inputProps === undefined ;
14+ const outputDataSchema = outputSchema ?. data ?. schema ;
15+ const isLoading = inputProps === undefined || outputDataSchema === undefined ;
1516 const inputKeys = Object . keys ( inputProps ?? { } ) ;
16- const isSupported = isLoading || ( inputKeys . length === 1 && inputProps [ inputKeys [ 0 ] ] . type === "array" ) ;
17+ const isSupported = isLoading || (
18+ inputKeys . length === 1 &&
19+ inputProps [ inputKeys [ 0 ] ] . type === "array" &&
20+ (
21+ outputDataSchema . anyOf ?. find ( ( option ) => option . properties ?. type ?. enum ?. includes ( "ai" ) ) ||
22+ outputDataSchema . type === "string"
23+ )
24+ ) ;
1725 return (
1826 < div className = "flex items-center flex-col text-ls-black bg-background" >
1927 < AppCallbackContext . Provider value = { context } >
20- { isSupported
21- ? < ChatWindow
28+ { isSupported
29+ ? < ChatWindow
2230 startStream = { startStream }
2331 stopStream = { stopStream }
2432 inputKey = { inputKeys [ 0 ] }
25- > </ ChatWindow >
33+ > </ ChatWindow >
2634 : < div className = "h-[100vh] w-[100vw] flex justify-center items-center text-xl" >
2735 < span className = "text-center" >
28- The chat playground is only supported for chains that take a single array of messages as input.
36+ The chat playground is only supported for chains that take a single array of messages as input
2937 < br />
30- You can test this chain in the standard < a href = { resolveApiUrl ( "/playground" ) . toString ( ) } > LangServe playground</ a > .
38+ and return either an AIMessage or a string.
39+ < br />
40+ < br />
41+ You can test this chain in the default LangServe playground instead. Please set < code > playground_type="default"</ code > .
3142 </ span >
3243 </ div > }
3344 </ AppCallbackContext . Provider >
0 commit comments