-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
147 additions
and
0 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,33 @@ | ||
// app/client/FluxProxy.ts | ||
|
||
export interface FluxImageRequest { | ||
prompt: string; | ||
width: number; | ||
height: number; | ||
} | ||
|
||
export interface FluxImageResponse { | ||
id: string | ||
} | ||
|
||
export interface FluxGetRequest { | ||
request_id: string; | ||
} | ||
|
||
export interface FluxGetResponse { | ||
id: string; | ||
status: string | "Ready"; | ||
result: string; | ||
} | ||
|
||
export class FluxAPI { | ||
private readonly apiKey: string; | ||
|
||
private readonly website = "https://blackforestlabs.ai"; | ||
|
||
constructor(apiKey: string) { | ||
this.apiKey = apiKey; | ||
} | ||
|
||
|
||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,75 @@ | ||
// /app/pages/Flux.tsx | ||
|
||
import {api2Provider, useAppConfig} from "@/app/store"; | ||
import {FluxAPI} from "@/app/client/FluxProxy"; | ||
import {ProForm} from "@ant-design/pro-components"; | ||
import React, {ReactNode, useState} from "react"; | ||
import {UnorderedListOutlined} from "@ant-design/icons"; | ||
import {Col, Divider, Segmented} from "antd"; | ||
import {COL_SCROLL_STYLE} from "@/constant"; | ||
import {renderCode} from "@/app/render"; | ||
import {safeJsonStringify} from "@/app/utils"; | ||
|
||
export function FluxPage() { | ||
const appConfig = useAppConfig(); | ||
const fluxApi = new FluxAPI(appConfig.getFirstApiKey(api2Provider.Flux)); | ||
const [generationForm] = ProForm.useForm(); | ||
|
||
const [taskData, setTaskData] = useState<any[]>([]); | ||
const [errorData, setErrorData] = useState<any>(null) | ||
|
||
const type_options = [ | ||
{label: "Generate", value: "generate", icon: <UnorderedListOutlined/>}, | ||
] | ||
|
||
const [formType, setFormType] = useState<"generate" | "query" | "upscale">("generate"); | ||
|
||
const updateTaskData = (data: any) => { | ||
const updatedTaskData = taskData.slice(); // 创建 taskData 的副本 | ||
|
||
const index = updatedTaskData.findIndex((c: any) => c.id === data.id); | ||
|
||
if (index === -1) { | ||
// 如果 id 不存在,添加新数据 | ||
updatedTaskData.push(data); | ||
} else { | ||
// 如果 id 已存在,更新数据 | ||
updatedTaskData[index] = data; | ||
} | ||
|
||
setTaskData(updatedTaskData); | ||
} | ||
|
||
const RenderFluxForms: { [key in typeof formType]: ReactNode } = { | ||
"generate": null, | ||
"upscale": null, | ||
"query": null, | ||
} | ||
|
||
return ( | ||
<> | ||
<Col flex="400px" style={COL_SCROLL_STYLE}> | ||
<Segmented | ||
value={formType} | ||
style={{marginBottom: 20}} | ||
options={type_options} | ||
block | ||
onChange={(value) => setFormType(value as typeof formType)} | ||
/> | ||
</Col> | ||
|
||
<Col flex={"none"}> | ||
<Divider type={"vertical"} style={{height: "100%"}}/> | ||
</Col> | ||
|
||
<Col flex="auto" style={COL_SCROLL_STYLE}> | ||
<h1>Tasks Info</h1> | ||
|
||
{errorData && <> | ||
<h1>Error</h1> | ||
{renderCode(safeJsonStringify(errorData, errorData.toString()))} | ||
</>} | ||
</Col> | ||
</> | ||
) | ||
} |
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