Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make new SDK work with evaluation #1155

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 @@ -21,6 +21,7 @@ import {testsetRowToChatMessages} from "@/lib/helpers/testset"
import EvaluationVotePanel from "../Evaluations/EvaluationCardView/EvaluationVotePanel"
import VariantAlphabet from "../Evaluations/EvaluationCardView/VariantAlphabet"
import {ParamsFormWithRun} from "./SingleModelEvaluationTable"
import {PassThrough} from "stream"

const {Title} = Typography

Expand Down Expand Up @@ -238,6 +239,9 @@ const ABTestingEvaluationTable: React.FC<EvaluationTableProps> = ({
? testsetRowToChatMessages(evaluation.testset.csvdata[rowIndex], false)
: [],
)
if (typeof result !== "string") {
result = result.message
}

setRowValue(rowIndex, variant.variantId, result)
;(outputs as KeyValuePair)[variant.variantId] = result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ Answer ONLY with one of the given grading or evaluation options.
? testsetRowToChatMessages(evaluation.testset.csvdata[rowIndex], false)
: [],
)

if (typeof result !== "string") {
result = result.message
}
if (variantData[idx].isChatVariant) {
result = contentToChatMessageString(result)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ const CustomCodeRunEvaluationTable: React.FC<CustomCodeEvaluationTableProps> = (
? testsetRowToChatMessages(evaluation.testset.csvdata[rowIndex], false)
: [],
)
if (typeof result !== "string") {
result = result.message
}

if (variantData[idx].isChatVariant) result = contentToChatMessageString(result)

setRowValue(rowIndex, columnName as any, result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ const ExactMatchEvaluationTable: React.FC<ExactMatchEvaluationTableProps> = ({
? testsetRowToChatMessages(evaluation.testset.csvdata[rowIndex], false)
: [],
)
if (typeof result !== "string") {
result = result.message
}

if (variantData[idx].isChatVariant) result = contentToChatMessageString(result)

setRowValue(rowIndex, columnName, result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ const RegexEvaluationTable: React.FC<RegexEvaluationTableProps> = ({
? testsetRowToChatMessages(evaluation.testset.csvdata[rowIndex], false)
: [],
)
if (typeof result !== "string") {
result = result.message
}

if (variantData[idx].isChatVariant) result = contentToChatMessageString(result)

const {regexPattern, regexShouldMatch} = form.getFieldsValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ const SimilarityMatchEvaluationTable: React.FC<SimilarityMatchEvaluationTablePro
? testsetRowToChatMessages(evaluation.testset.csvdata[rowIndex], false)
: [],
)
if (typeof result !== "string") {
result = result.message
}

if (variantData[idx].isChatVariant) result = contentToChatMessageString(result)

const {similarityThreshold} = form.getFieldsValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ const SingleModelEvaluationTable: React.FC<EvaluationTableProps> = ({
? testsetRowToChatMessages(evaluation.testset.csvdata[rowIndex], false)
: [],
)
if (typeof result !== "string") {
result = result.message
}

setRowValue(rowIndex, variant.variantId, result)
;(outputs as KeyValuePair)[variant.variantId] = result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ const WebhookEvaluationTable: React.FC<WebhookEvaluationTableProps> = ({
? testsetRowToChatMessages(evaluation.testset.csvdata[rowIndex], false)
: [],
)
if (typeof result !== "string") {
result = result.message
}

if (variantData[idx].isChatVariant) result = contentToChatMessageString(result)

const {webhookUrl} = form.getFieldsValue()
Expand Down
22 changes: 14 additions & 8 deletions agenta-web/src/components/Playground/Views/TestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const BoxComponent: React.FC<BoxComponentProps> = ({
imageSize="large"
/>
</Row>
{additionalData && (
{additionalData?.cost || additionalData?.latency ? (
<Space>
<p>
Tokens:{" "}
Expand All @@ -187,6 +187,8 @@ const BoxComponent: React.FC<BoxComponentProps> = ({
: "0ms"}
</p>
</Space>
) : (
""
)}
<Row className={classes.row2} style={{marginBottom: isChatVariant ? 12 : 0}}>
<Col span={24} className={classes.row2Col} id={variant.variantId}>
Expand Down Expand Up @@ -340,13 +342,17 @@ const App: React.FC<TestViewProps> = ({
variant.baseId || "",
isChatVariant ? testItem.chat : [],
)

setResultForIndex(res.message, index)
setAdditionalDataList((prev) => {
const newDataList = [...prev]
newDataList[index] = {cost: res.cost, latency: res.latency, usage: res.usage}
return newDataList
})
// check if res is an object or string
if (typeof res === "string") {
setResultForIndex(res, index)
} else {
setResultForIndex(res.message, index)
setAdditionalDataList((prev) => {
const newDataList = [...prev]
newDataList[index] = {cost: res.cost, latency: res.latency, usage: res.usage}
return newDataList
})
}
} catch (e) {
setResultForIndex(
"The code has resulted in the following error: \n\n --------------------- \n" +
Expand Down
6 changes: 4 additions & 2 deletions agenta-web/src/lib/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ export function restartAppVariantContainer(variantId: string) {
* @param inputParametersDict A dictionary of the input parameters to be passed to the variant endpoint
* @param inputParamDefinition A list of the parameters that are defined in the openapi.json (these are only part of the input params, the rest is defined by the user in the optparms)
* @param optionalParameters The optional parameters (prompt, models, AND DICTINPUTS WHICH ARE TO BE USED TO ADD INPUTS )
* @param URIPath
* @returns
* @param appId - The ID of the app.
* @param baseId - The base ID.
* @param chatMessages - An optional array of chat messages.
* @returns A Promise that resolves with the response data from the POST request.
*/
export async function callVariant(
inputParametersDict: KeyValuePair,
Expand Down
Loading