Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const EditorFactory = (props: FormFieldEditorProps) => {
fieldInputType.fieldType === "RECORD_MAP_EXPRESSION" ||
fieldInputType.fieldType === "SQL_QUERY" ||
fieldInputType.fieldType === "NUMBER" ||
fieldInputType.fieldType === "PROMPT" ||
(fieldInputType.fieldType === "FLAG" && field.types?.length > 1)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
export const CONNECTION_TYPE_CONFIGS: Record<ConnectionKind, ConnectionKindConfig> = {
MODEL_PROVIDER: {
displayName: "Model Provider",
types: [{ fieldType: "EXPRESSION", ballerinaType: "ai:ModelProvider", selected: true }],
types: [{ fieldType: "ACTION_EXPRESSION", ballerinaType: "ai:ModelProvider", selected: true }],
nodePropertyKey: ["model", "modelProvider"],
categoryConverter: convertModelProviderCategoriesToSidePanelCategories,
searchConfig: (aiModuleOrg?: string): ConnectionSearchConfig => ({
Expand All @@ -39,25 +39,25 @@ export const CONNECTION_TYPE_CONFIGS: Record<ConnectionKind, ConnectionKindConfi
},
VECTOR_STORE: {
displayName: "Vector Store",
types: [{ fieldType: "EXPRESSION", ballerinaType: "ai:VectorStore", selected: true }],
types: [{ fieldType: "ACTION_EXPRESSION", ballerinaType: "ai:VectorStore", selected: true }],
nodePropertyKey: "vectorStore",
categoryConverter: convertVectorStoreCategoriesToSidePanelCategories,
},
EMBEDDING_PROVIDER: {
displayName: "Embedding Provider",
types: [{ fieldType: "EXPRESSION", ballerinaType: "ai:EmbeddingProvider", selected: true }],
types: [{ fieldType: "ACTION_EXPRESSION", ballerinaType: "ai:EmbeddingProvider", selected: true }],
nodePropertyKey: "embeddingModel",
categoryConverter: convertEmbeddingProviderCategoriesToSidePanelCategories,
},
CHUNKER: {
displayName: "Chunker",
types: [{ fieldType: "EXPRESSION", ballerinaType: "ai:Chunker", selected: true }],
types: [{ fieldType: "ACTION_EXPRESSION", ballerinaType: "ai:Chunker", selected: true }],
nodePropertyKey: "chunker",
categoryConverter: convertChunkerCategoriesToSidePanelCategories,
},
MEMORY_STORE: {
displayName: "Memory Store",
types: [{ fieldType: "EXPRESSION", ballerinaType: "ai:MemoryStore", selected: true }],
types: [{ fieldType: "ACTION_EXPRESSION", ballerinaType: "ai:MemoryStore", selected: true }],
nodePropertyKey: "store",
categoryConverter: convertMemoryStoreCategoriesToSidePanelCategories,
searchConfig: (): ConnectionSearchConfig => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ export function MemoryManagerConfig(props: MemoryConfigProps): JSX.Element {
fieldOverrides={{
store: {
type: "ACTION_EXPRESSION",
types: [{ fieldType: "ACTION_EXPRESSION", selected: false }],
actionCallback: handleOpenStoreSelection,
defaultValue: "In-Memory Short Term Memory Store",
actionLabel: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export function AIEvaluationForm(props: TestFunctionDefProps) {
const [targetLineRange, setTargetLineRange] = useState<LineRange>();
const [dataProviderMode, setDataProviderMode] = useState<string>('evalSet');
const [evalsetOptions, setEvalsetOptions] = useState<Array<{ value: string; content: string }>>([]);
const [isSaving, setIsSaving] = useState<boolean>(false);

// Helper function to apply field visibility rules based on data provider mode
const applyFieldVisibility = (fields: FormField[], mode: string): FormField[] => {
Expand Down Expand Up @@ -234,7 +235,7 @@ export function AIEvaluationForm(props: TestFunctionDefProps) {
}

const onFormSubmit = async (data: FormValues, formImports: FormImports) => {
// Include the dataProviderMode from CardSelector state
setIsSaving(true);
const formData = {
...data,
dataProviderMode: dataProviderMode
Expand All @@ -245,16 +246,22 @@ export function AIEvaluationForm(props: TestFunctionDefProps) {
} else {
await rpcClient.getTestManagerRpcClient().addTestFunction({ function: updatedTestFunction, filePath });
}
const res = await rpcClient.getTestManagerRpcClient().getTestFunction(
{ functionName: updatedTestFunction.functionName.value, filePath });
const nodePosition = {
startLine: res.function.codedata.lineRange.startLine.line,
startColumn: res.function.codedata.lineRange.startLine.offset,
endLine: res.function.codedata.lineRange.endLine.line,
endColumn: res.function.codedata.lineRange.endLine.offset
};
rpcClient.getVisualizerRpcClient().openView(
{ type: EVENT_TYPE.OPEN_VIEW, location: { position: nodePosition, documentUri: filePath } })
try {
const res = await rpcClient.getTestManagerRpcClient().getTestFunction(
{ functionName: updatedTestFunction.functionName.value, filePath });
const nodePosition = {
startLine: res.function.codedata.lineRange.startLine.line,
startColumn: res.function.codedata.lineRange.startLine.offset,
endLine: res.function.codedata.lineRange.endLine.line,
endColumn: res.function.codedata.lineRange.endLine.offset
};
rpcClient.getVisualizerRpcClient().openView(
{ type: EVENT_TYPE.OPEN_VIEW, location: { position: nodePosition, documentUri: filePath } })
}
catch (error) {
console.error('Failed to open function in diagram:', error);
setIsSaving(false);
}
};

// Helper function to modify and set the visual information
Expand Down Expand Up @@ -307,6 +314,7 @@ export function AIEvaluationForm(props: TestFunctionDefProps) {
fields.push({
...generatedField,
type: 'SLIDER',
types: [{ fieldType: 'SLIDER', selected: false }],
sliderProps: {
min: 0,
max: 100,
Expand All @@ -323,6 +331,7 @@ export function AIEvaluationForm(props: TestFunctionDefProps) {
fields.push({
...generateFieldFromProperty('evalSetFile', evalSetFileField),
type: 'SINGLE_SELECT',
types: [{ fieldType: 'SINGLE_SELECT', selected: false }],
itemOptions: evalsetOptions
});
}
Expand Down Expand Up @@ -820,6 +829,7 @@ export function AIEvaluationForm(props: TestFunctionDefProps) {
onSubmit={onFormSubmit}
preserveFieldOrder={true}
onChange={handleFieldChange}
isSaving={isSaving}
injectedComponents={[
{
component: <CardSelector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export function KnowledgeBaseForm(props: KnowledgeBaseFormProps) {
const originalName = field?.codedata?.originalName;
if (actionFields.includes(originalName)) {
field.type = "ACTION_EXPRESSION";
field.types = [{ fieldType: "ACTION_EXPRESSION", selected: false }];
field.advanced = false;
field.actionCallback = () => {
props.navigateToPanel?.(SidePanelView.CONNECTION_SELECT, getConnectionKind(originalName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function TestFunctionForm(props: TestFunctionDefProps) {
const [testFunction, setTestFunction] = useState<TestFunction>();
const [formTitle, setFormTitle] = useState<string>('Create New Test Case');
const [targetLineRange, setTargetLineRange] = useState<LineRange>();
const [isSaving, setIsSaving] = useState<boolean>(false);

const updateTargetLineRange = () => {
rpcClient
Expand Down Expand Up @@ -102,6 +103,7 @@ export function TestFunctionForm(props: TestFunctionDefProps) {
}

const onFormSubmit = async (data: FormValues, formImports: FormImports) => {
setIsSaving(true);
console.log("Test Function Form Data: ", data);
const updatedTestFunction = fillFunctionModel(data, formImports);
console.log("Test Function: ", updatedTestFunction);
Expand All @@ -110,17 +112,21 @@ export function TestFunctionForm(props: TestFunctionDefProps) {
} else {
await rpcClient.getTestManagerRpcClient().addTestFunction({ function: updatedTestFunction, filePath });
}
const res = await rpcClient.getTestManagerRpcClient().getTestFunction(
{ functionName: updatedTestFunction.functionName.value, filePath });
const nodePosition = {
startLine: res.function.codedata.lineRange.startLine.line,
startColumn: res.function.codedata.lineRange.startLine.offset,
endLine: res.function.codedata.lineRange.endLine.line,
endColumn: res.function.codedata.lineRange.endLine.offset
};
console.log("Node Position: ", nodePosition);
await rpcClient.getVisualizerRpcClient().openView(
{ type: EVENT_TYPE.OPEN_VIEW, location: { position: nodePosition, documentUri: filePath } })
try {
const res = await rpcClient.getTestManagerRpcClient().getTestFunction(
{ functionName: updatedTestFunction.functionName.value, filePath });
const nodePosition = {
startLine: res.function.codedata.lineRange.startLine.line,
startColumn: res.function.codedata.lineRange.startLine.offset,
endLine: res.function.codedata.lineRange.endLine.line,
endColumn: res.function.codedata.lineRange.endLine.offset
};
await rpcClient.getVisualizerRpcClient().openView(
{ type: EVENT_TYPE.OPEN_VIEW, location: { position: nodePosition, documentUri: filePath } })
} catch (error) {
console.error("Error opening test function in editor: ", error);
setIsSaving(false);
}
};

// Helper function to modify and set the visual information
Expand Down Expand Up @@ -173,6 +179,7 @@ export function TestFunctionForm(props: TestFunctionDefProps) {
fields.push({
...generatedField,
type: 'SLIDER',
types: [{ fieldType: 'SLIDER', selected: false }],
advanced: true,
sliderProps: {
min: 0,
Expand Down Expand Up @@ -603,6 +610,7 @@ export function TestFunctionForm(props: TestFunctionDefProps) {
targetLineRange={targetLineRange}
onSubmit={onFormSubmit}
preserveFieldOrder={true}
isSaving={isSaving}
/>
)}
</FormContainer>
Expand Down
Loading