prompted workflows: send either v1 or v2 tasks to prompt endpoint (#3659)
This commit is contained in:
@@ -136,15 +136,17 @@ function PromptBox() {
|
|||||||
const { setAutoplay } = useAutoplayStore();
|
const { setAutoplay } = useAutoplayStore();
|
||||||
|
|
||||||
const generateWorkflowMutation = useMutation({
|
const generateWorkflowMutation = useMutation({
|
||||||
mutationFn: async (prompt: string) => {
|
mutationFn: async ({
|
||||||
|
prompt,
|
||||||
|
version,
|
||||||
|
}: {
|
||||||
|
prompt: string;
|
||||||
|
version: string;
|
||||||
|
}) => {
|
||||||
const client = await getClient(credentialGetter, "sans-api-v1");
|
const client = await getClient(credentialGetter, "sans-api-v1");
|
||||||
|
const v = version === "v1" ? "v1" : "v2";
|
||||||
|
|
||||||
const result = await client.post<
|
const request: Record<string, unknown> = {
|
||||||
Createv2TaskRequest,
|
|
||||||
{ data: WorkflowApiResponse }
|
|
||||||
>(
|
|
||||||
"/workflows/create-from-prompt",
|
|
||||||
{
|
|
||||||
user_prompt: prompt,
|
user_prompt: prompt,
|
||||||
webhook_callback_url: webhookCallbackUrl,
|
webhook_callback_url: webhookCallbackUrl,
|
||||||
proxy_location: proxyLocation,
|
proxy_location: proxyLocation,
|
||||||
@@ -171,6 +173,20 @@ function PromptBox() {
|
|||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
: null,
|
: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (v === "v1") {
|
||||||
|
request.url = "https://google.com"; // a stand-in value; real url is generated via prompt
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await client.post<
|
||||||
|
Createv2TaskRequest,
|
||||||
|
{ data: WorkflowApiResponse }
|
||||||
|
>(
|
||||||
|
"/workflows/create-from-prompt",
|
||||||
|
{
|
||||||
|
task_version: v,
|
||||||
|
request,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
@@ -313,7 +329,10 @@ function PromptBox() {
|
|||||||
<PaperPlaneIcon
|
<PaperPlaneIcon
|
||||||
className="size-6 cursor-pointer"
|
className="size-6 cursor-pointer"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
generateWorkflowMutation.mutate(prompt);
|
generateWorkflowMutation.mutate({
|
||||||
|
prompt,
|
||||||
|
version: selectValue,
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -514,7 +533,10 @@ function PromptBox() {
|
|||||||
icon={example.icon}
|
icon={example.icon}
|
||||||
label={example.label}
|
label={example.label}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
generateWorkflowMutation.mutate(example.prompt);
|
generateWorkflowMutation.mutate({
|
||||||
|
prompt: example.prompt,
|
||||||
|
version: "v2",
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user