Skip to content

Commit

Permalink
Update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 authored and dqbd committed Oct 19, 2023
1 parent a54d7df commit 37f4f3c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion examples/chain/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""Example LangChain server exposes a chain composed of a prompt and an LLM."""
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Optional, Tuple

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
Expand Down Expand Up @@ -62,6 +62,8 @@ class ChainInput(BaseModel):
topic: str
"""The topic of the joke."""
chat_history: List[str]
chat_history_tuples: List[Tuple[str, str]]
chat_history_object_list: List[Dict[str, str]]
tester: Optional[Dict[str, Any]] = None


Expand Down
11 changes: 9 additions & 2 deletions langserve/playground/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
IntegerCell,
NumberCell,
SliderCell,
// TextAreaCell,
TimeCell,
booleanCellTester,
dateCellTester,
Expand All @@ -53,7 +52,7 @@ import {

import { useSchemas } from "./useSchemas";
import { RunState, useStreamLog } from "./useStreamLog";
import { JsonFormsCore } from "@jsonforms/core";
import { JsonFormsCore, RankedTester, rankWith } from "@jsonforms/core";
import CustomArrayControlRenderer, { materialArrayControlTester } from "./components/CustomArrayControlRenderer";
import CustomTextAreaCell from "./components/CustomTextAreaCell";

Expand Down Expand Up @@ -82,6 +81,13 @@ const renderers = [
{ tester: materialArrayControlTester, renderer: CustomArrayControlRenderer }
];

export const nestedArrayControlTester: RankedTester = rankWith(
1,
(_, jsonSchema) => {
return jsonSchema.type === "array";
}
);

const cells = [
{ tester: booleanCellTester, cell: BooleanCell },
{ tester: dateCellTester, cell: DateCell },
Expand All @@ -93,6 +99,7 @@ const cells = [
{ tester: textAreaCellTester, cell: CustomTextAreaCell },
{ tester: textCellTester, cell: CustomTextAreaCell },
{ tester: timeCellTester, cell: TimeCell },
{ tester: nestedArrayControlTester, cell: CustomArrayControlRenderer },
];

function IntermediateSteps(props: { latest: RunState }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
ArrayLayoutProps,
RankedTester,
isObjectArrayControl,
isObjectArrayWithNesting,
isPrimitiveArrayControl,
or,
rankWith,
Expand Down Expand Up @@ -80,7 +81,7 @@ export const MaterialArrayControlRenderer = (props: ArrayLayoutProps) => {

export const materialArrayControlTester: RankedTester = rankWith(
999,
or(isObjectArrayControl, isPrimitiveArrayControl)
or(isObjectArrayControl, isPrimitiveArrayControl, isObjectArrayWithNesting)
);

export default withJsonFormsArrayLayoutProps(MaterialArrayControlRenderer);
1 change: 0 additions & 1 deletion langserve/playground/src/components/CustomTextAreaCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const TextAreaCell = (props: CellProps & VanillaRendererProps) => {
const { data, className, id, enabled, config, uischema, path, handleChange } =
props;
const appliedUiSchemaOptions = merge({}, config, uischema.options);
console.log(config, uischema);
return (
<textarea
value={data || ''}
Expand Down

0 comments on commit 37f4f3c

Please sign in to comment.