From 8d724d55f443a5da823d4acba42f859fc1dad05c Mon Sep 17 00:00:00 2001 From: mrkirthi-24 Date: Mon, 18 Sep 2023 13:46:00 +0530 Subject: [PATCH 1/3] Fix: Code Evaluation View --- agenta-web/src/components/Evaluations/CustomPythonCode.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/agenta-web/src/components/Evaluations/CustomPythonCode.tsx b/agenta-web/src/components/Evaluations/CustomPythonCode.tsx index 5547fc5aef..ca9d4d8bf6 100644 --- a/agenta-web/src/components/Evaluations/CustomPythonCode.tsx +++ b/agenta-web/src/components/Evaluations/CustomPythonCode.tsx @@ -145,11 +145,6 @@ def evaluate( className={classes.copyBtn} /> -

Evaluation Function Description:

@@ -180,6 +175,7 @@ def evaluate( theme={switchEditorThemeBasedOnTheme()} value={form.getFieldValue("pythonCode")} onChange={(code) => form.setFieldsValue({pythonCode: code})} + defaultValue={pythonDefaultEvalCode()} /> From 0d0b1125de6663da64aaae9e31308f88bb3f6a93 Mon Sep 17 00:00:00 2001 From: Mahmoud Mabrouk Date: Mon, 18 Sep 2023 10:41:45 +0200 Subject: [PATCH 2/3] minor improvements --- .../Evaluations/CustomPythonCode.tsx | 54 ++++++++----------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/agenta-web/src/components/Evaluations/CustomPythonCode.tsx b/agenta-web/src/components/Evaluations/CustomPythonCode.tsx index ca9d4d8bf6..9e66fab9f3 100644 --- a/agenta-web/src/components/Evaluations/CustomPythonCode.tsx +++ b/agenta-web/src/components/Evaluations/CustomPythonCode.tsx @@ -1,8 +1,8 @@ -import React, {useState, useEffect} from "react" -import {useRouter} from "next/router" -import {Input, Form, Button, Row, Col, Typography, notification} from "antd" -import {CreateCustomEvaluationSuccessResponse} from "@/lib/Types" -import {saveCustomCodeEvaluation, fetchCustomEvaluationNames} from "@/lib/services/api" +import React, { useState, useEffect } from "react" +import { useRouter } from "next/router" +import { Input, Form, Button, Row, Col, Typography, notification } from "antd" +import { CreateCustomEvaluationSuccessResponse } from "@/lib/Types" +import { saveCustomCodeEvaluation, fetchCustomEvaluationNames } from "@/lib/services/api" import CodeBlock from "@/components/DynamicCodeBlock/CodeBlock" import CopyButton from "../CopyButton/CopyButton" import Editor from "@monaco-editor/react" @@ -18,8 +18,8 @@ interface ICustomEvalNames { evaluation_name: string } -const CustomPythonCode: React.FC = ({classes, appName, appTheme}) => { - const {Title} = Typography +const CustomPythonCode: React.FC = ({ classes, appName, appTheme }) => { + const { Title } = Typography const [form] = Form.useForm() const router = useRouter() @@ -75,7 +75,7 @@ const CustomPythonCode: React.FC = ({classes, appName, appTh return ( evalNameExist || !form.isFieldsTouched(true) || - form.getFieldsError().filter(({errors}) => errors.length).length > 0 + form.getFieldsError().filter(({ errors }) => errors.length).length > 0 ) } @@ -122,11 +122,11 @@ def evaluate(
- +
-

- Example Evaluation Function: - -

- Evaluation Function Description: + Writing the custom evaluation code:

- The code must accept: + The function name of your code evaluation must be + "evaluate". and must accept the following parameters:
    -
  • The app variant parameters
  • -
  • A list of inputs
  • -
  • An output
  • -
  • A target or correct answer
  • +
  • The variant parameters (prompt, etc..) as a Dict[str,str]
  • +
  • A list of inputs as List[str]
  • +
  • The output of the LLM app as a string
  • +
  • A target or correct answer as a string
+ And return a float value indicating the score of the evaluation.
-

- NOTE: The function name of your code evaluation must be - "evaluate". -

- + form.setFieldsValue({pythonCode: code})} + onChange={(code) => form.setFieldsValue({ pythonCode: code })} defaultValue={pythonDefaultEvalCode()} /> From 961b8a11886f1813a83dc57218e9cf2e78848d36 Mon Sep 17 00:00:00 2001 From: Mahmoud Mabrouk Date: Mon, 18 Sep 2023 10:42:46 +0200 Subject: [PATCH 3/3] format fix --- .../Evaluations/CustomPythonCode.tsx | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/agenta-web/src/components/Evaluations/CustomPythonCode.tsx b/agenta-web/src/components/Evaluations/CustomPythonCode.tsx index 9e66fab9f3..169eaebc1a 100644 --- a/agenta-web/src/components/Evaluations/CustomPythonCode.tsx +++ b/agenta-web/src/components/Evaluations/CustomPythonCode.tsx @@ -1,8 +1,8 @@ -import React, { useState, useEffect } from "react" -import { useRouter } from "next/router" -import { Input, Form, Button, Row, Col, Typography, notification } from "antd" -import { CreateCustomEvaluationSuccessResponse } from "@/lib/Types" -import { saveCustomCodeEvaluation, fetchCustomEvaluationNames } from "@/lib/services/api" +import React, {useState, useEffect} from "react" +import {useRouter} from "next/router" +import {Input, Form, Button, Row, Col, Typography, notification} from "antd" +import {CreateCustomEvaluationSuccessResponse} from "@/lib/Types" +import {saveCustomCodeEvaluation, fetchCustomEvaluationNames} from "@/lib/services/api" import CodeBlock from "@/components/DynamicCodeBlock/CodeBlock" import CopyButton from "../CopyButton/CopyButton" import Editor from "@monaco-editor/react" @@ -18,8 +18,8 @@ interface ICustomEvalNames { evaluation_name: string } -const CustomPythonCode: React.FC = ({ classes, appName, appTheme }) => { - const { Title } = Typography +const CustomPythonCode: React.FC = ({classes, appName, appTheme}) => { + const {Title} = Typography const [form] = Form.useForm() const router = useRouter() @@ -75,7 +75,7 @@ const CustomPythonCode: React.FC = ({ classes, appName, appT return ( evalNameExist || !form.isFieldsTouched(true) || - form.getFieldsError().filter(({ errors }) => errors.length).length > 0 + form.getFieldsError().filter(({errors}) => errors.length).length > 0 ) } @@ -126,7 +126,7 @@ def evaluate( - The function name of your code evaluation must be - "evaluate". and must accept the following parameters: + The function name of your code evaluation must be "evaluate". and + must accept the following parameters:
    -
  • The variant parameters (prompt, etc..) as a Dict[str,str]
  • +
  • + The variant parameters (prompt, etc..) as a Dict[str,str] +
  • A list of inputs as List[str]
  • The output of the LLM app as a string
  • A target or correct answer as a string
  • @@ -154,7 +156,7 @@ def evaluate( form.setFieldsValue({ pythonCode: code })} + onChange={(code) => form.setFieldsValue({pythonCode: code})} defaultValue={pythonDefaultEvalCode()} />