Merge pull request #71 from OpenPipe/model-providers

Prep for more model providers
This commit is contained in:
Kyle Corbitt
2023-07-20 14:55:31 -07:00
committed by GitHub
43 changed files with 1195 additions and 3023 deletions

View File

@@ -48,13 +48,13 @@ export default function VariantEditor(props: { variant: PromptVariant }) {
if (!model) return;
// Make sure the user defined the prompt with the string "prompt\w*=" somewhere
const promptRegex = /prompt\s*=/;
const promptRegex = /definePrompt\(/;
if (!promptRegex.test(currentFn)) {
console.log("no prompt");
console.log(currentFn);
toast({
title: "Missing prompt",
description: "Please define the prompt (eg. `prompt = { ...`).",
description: "Please define the prompt (eg. `definePrompt(...`",
status: "error",
});
return;

View File

@@ -25,6 +25,7 @@ import CompareFunctions from "./CompareFunctions";
import { CustomInstructionsInput } from "./CustomInstructionsInput";
import { type RefineOptionLabel, refineOptions } from "./refineOptions";
import { RefineOption } from "./RefineOption";
import { isObject, isString } from "lodash-es";
export const RefinePromptModal = ({
variant,
@@ -59,7 +60,12 @@ export const RefinePromptModal = ({
const replaceVariantMutation = api.promptVariants.replaceVariant.useMutation();
const [replaceVariant, replacementInProgress] = useHandledAsyncCallback(async () => {
if (!variant.experimentId || !refinedPromptFn) return;
if (
!variant.experimentId ||
!refinedPromptFn ||
(isObject(refinedPromptFn) && "status" in refinedPromptFn)
)
return;
await replaceVariantMutation.mutateAsync({
id: variant.id,
constructFn: refinedPromptFn,
@@ -110,7 +116,7 @@ export const RefinePromptModal = ({
</VStack>
<CompareFunctions
originalFunction={variant.constructFn}
newFunction={refinedPromptFn}
newFunction={isString(refinedPromptFn) ? refinedPromptFn : undefined}
/>
</VStack>
</ModalBody>

View File

@@ -7,7 +7,7 @@ import {
SimpleGrid,
Link,
} from "@chakra-ui/react";
import { modelStats } from "~/server/modelStats";
import { modelStats } from "~/modelProviders/modelStats";
import { type SupportedModel } from "~/server/types";
export const ModelStatsCard = ({ label, model }: { label: string; model: SupportedModel }) => {