@@ -14,31 +14,54 @@ export function App() {
1414 const outputDataSchema = outputSchema ?. data ?. schema ;
1515 const isLoading = inputProps === undefined || outputDataSchema === undefined ;
1616 const inputKeys = Object . keys ( inputProps ?? { } ) ;
17- const isSupported = isLoading || (
17+ const inputSchemaSupported = (
1818 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"
19+ inputProps ?. [ inputKeys [ 0 ] ] . type === "array"
20+ ) || (
21+ inputKeys . length === 2 && (
22+ (
23+ inputProps ?. [ inputKeys [ 0 ] ] . type === "array" ||
24+ inputProps ?. [ inputKeys [ 1 ] ] . type === "string"
25+ ) || (
26+ inputProps ?. [ inputKeys [ 0 ] ] . type === "string" ||
27+ inputProps ?. [ inputKeys [ 1 ] ] . type === "array"
28+ )
2329 )
2430 ) ;
31+ const outputSchemaSupported = (
32+ outputDataSchema ?. anyOf ?. find ( ( option ) => option . properties ?. type ?. enum ?. includes ( "ai" ) ) ||
33+ outputDataSchema ?. type === "string"
34+ ) ;
35+ const isSupported = isLoading || ( inputSchemaSupported && outputSchemaSupported ) ;
2536 return (
2637 < div className = "flex items-center flex-col text-ls-black bg-background" >
2738 < AppCallbackContext . Provider value = { context } >
2839 { isSupported
2940 ? < ChatWindow
3041 startStream = { startStream }
3142 stopStream = { stopStream }
32- inputKey = { inputKeys [ 0 ] }
43+ messagesInputKey = { inputProps ?. [ inputKeys [ 0 ] ] . type === "array" ? inputKeys [ 0 ] : inputKeys [ 1 ] }
44+ inputKey = { inputProps ?. [ inputKeys [ 0 ] ] . type === "string" ? inputKeys [ 0 ] : inputKeys [ 1 ] }
3345 > </ ChatWindow >
34- : < div className = "h-[100vh] w-[100vw] flex justify-center items-center text-xl" >
35- < span className = "text-center" >
36- The chat playground is only supported for chains that take a single array of messages as input
37- < br />
38- and return either an AIMessage or a string.
46+ : < div className = "h-[100vh] w-[100vw] flex justify-center items-center text-xl p-16" >
47+ < span >
48+ The chat playground is only supported for chains that take one of the following as input:
49+ < ul className = "mt-8 list-disc ml-6" >
50+ < li >
51+ a dict with a single key containing a list of messages
52+ </ li >
53+ < li >
54+ a dict with two keys: one a string input, one an list of messages
55+ </ li >
56+ </ ul >
57+ < br />
58+ and which return either an < code > AIMessage</ code > or a string.
59+ < br />
60+ < br />
61+ You can test this chain in the default LangServe playground instead.
3962 < br />
4063 < br />
41- You can test this chain in the default LangServe playground instead. Please set < code > playground_type="default"</ code > .
64+ To use the default playground, set < code > playground_type="default"</ code > when adding the route in your backend .
4265 </ span >
4366 </ div > }
4467 </ AppCallbackContext . Provider >
0 commit comments