-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Scaffold model invocation params form (#5040)
- Loading branch information
1 parent
4df3f8a
commit 055e1a9
Showing
5 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React from "react"; | ||
|
||
import { Flex, Slider, TextField } from "@arizeai/components"; | ||
|
||
import { ModelConfig } from "@phoenix/store"; | ||
|
||
export type InvocationParametersChangeHandler = < | ||
T extends keyof ModelConfig["invocationParameters"], | ||
>( | ||
parameter: T, | ||
value: ModelConfig["invocationParameters"][T] | ||
) => void; | ||
|
||
type InvocationParametersFormProps = { | ||
model: ModelConfig; | ||
onChange: InvocationParametersChangeHandler; | ||
}; | ||
|
||
export const InvocationParametersForm = ({ | ||
model, | ||
onChange, | ||
}: InvocationParametersFormProps) => { | ||
const { invocationParameters, provider, modelName } = model; | ||
return ( | ||
<Flex direction="column" gap="size-200"> | ||
<Slider | ||
label="Temperature" | ||
value={invocationParameters.temperature || 0} | ||
step={0.1} | ||
minValue={0} | ||
maxValue={2} | ||
onChange={(value) => onChange("temperature", value)} | ||
/> | ||
<Slider | ||
label="Top P" | ||
value={invocationParameters.topP || 0} | ||
step={0.1} | ||
minValue={0} | ||
maxValue={1} | ||
onChange={(value) => onChange("topP", value)} | ||
/> | ||
{/* TODO(apowell): there's likely a better way. Do we maintain a map of provider:model to form field overrides? */} | ||
{modelName?.startsWith("o1") && provider === "OPENAI" ? ( | ||
<TextField | ||
label="Max Completion Tokens" | ||
value={invocationParameters.maxCompletionTokens?.toString() || ""} | ||
type="number" | ||
onChange={(value) => onChange("maxCompletionTokens", Number(value))} | ||
description="The maximum number of tokens to generate" | ||
/> | ||
) : ( | ||
<TextField | ||
label="Max Tokens" | ||
value={invocationParameters.maxTokens?.toString() || ""} | ||
type="number" | ||
onChange={(value) => onChange("maxTokens", Number(value))} | ||
description="The maximum number of tokens to generate" | ||
/> | ||
)} | ||
{/* TODO(apowell): Combobox / Tag input? Bespoke add/remove menu? */} | ||
<TextField | ||
label="Stop" | ||
defaultValue={invocationParameters.stop?.join(", ") || ""} | ||
onChange={(value) => onChange("stop", value.split(/, */g))} | ||
description="Comma-separated list of tokens to stop on" | ||
/> | ||
<TextField | ||
label="Seed" | ||
value={invocationParameters.seed?.toString() || ""} | ||
type="number" | ||
onChange={(value) => onChange("seed", Number(value))} | ||
description="Any integer that can be reused to produce semi-deterministic outputs" | ||
/> | ||
</Flex> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters