import { Configuration, DalleResponse, DefaultApi, RobertaEmotionResponse, RobertaHateResponse, RobertaIronyResponse, RobertaOffensiveResponse, RobertaSentimentResponse } from "../service/openapi"; import { Accordion, Button, Card, Col, Container, Dropdown, DropdownButton, Form, FormControl, FormGroup, FormLabel, Image, InputGroup, Row, Spinner, Table } from "react-bootstrap"; import styles from "../styles/TextInput.module.scss"; import {createRef, FormEvent, forwardRef, useCallback, useEffect, useState} from "react"; import _ from "lodash"; let debounce = _.debounce(async (fn) => await fn(), 10000) export default function Artsy(props) { const [text, setText] = useState(""); const [calculating, setCalculating] = useState(false) const [model, setModel] = useState("1"); const [count, setCount] = useState("5"); const [prompt, setPrompt] = useState("") const [artery, setArtery] = useState>(Array.of()); interface History { model: string, count: string, prompt: string artery: Array } const [history, setHistory] = useState>(Array.of()) const configuration = new Configuration({ basePath: 'https://warp2.friedl.net' }); const api = new DefaultApi(configuration); let handleSubmit = async (e: FormEvent) => { e.preventDefault(); if (!text) { setText(undefined); return; } setCalculating(true); setPrompt(""); setArtery(Array.of()); try { const r: DalleResponse = await api.getImageDalleGenerateGet({text: text, count: parseInt(count)}); setPrompt(text); setArtery(r.imagePaths); history.push({ model: model, count: count, prompt: prompt, artery: [...artery]}); setHistory(history) } catch (error) { console.error(error) } setCalculating(false); return false; } let renderCards = () => { let cards = [] for(const p of artery) { cards.push( ) } return ( <>{cards} ); } let renderHistory = () => { let hist = [] let idx = 0 for(const h of history) { let cards = [] for(const p of h.artery) { cards.push( ) } hist.push( <>
{h.prompt}
{cards} ) idx++; } return( <> {hist} ) } return ( <>

ALAS

setText(e.target.value)} className={`${styles.textBox} mb-3`} as="textarea" disabled={calculating}/> Model setModel(e.currentTarget.value)}> # of Images setCount(e.currentTarget.value)} value={count} disabled={calculating}>

Artery

{prompt}
{ calculating ? : renderCards() } { history.length > 1 &&

History

} { history.length > 1 && renderHistory() }
) }