feat: frontend

This commit is contained in:
Florian Hönicke
2023-03-20 01:21:17 +01:00
parent 0116449082
commit d23998c0d7
3 changed files with 24 additions and 6 deletions

View File

@@ -66,6 +66,8 @@ async def main(
+ executor_example
+ docarray_example
+ client_example
+ "The user is asking you to create an executor with all the necessary files "
"and you write the complete code without leaving something out. "
)
user_query = (

View File

@@ -1,6 +1,8 @@
import React, {useState} from 'react';
import axios from 'axios';
import {Box, Button, Container, FormControl, InputLabel, MenuItem, Select, TextField, Typography,} from '@mui/material';
import {Box, Container, FormControl, InputLabel, MenuItem, Select, TextField, Typography,} from '@mui/material';
import copy from 'clipboard-copy';
import Button from '@mui/material/Button';
function App() {
const [executorName, setExecutorName] = useState('MyCoolOcrExecutor');
@@ -30,6 +32,7 @@ function App() {
try {
const response = await axios.post('http://0.0.0.0:8000/create', requestBody);
console.log(response.data)
setResponseText(response.data);
} catch (error) {
console.error(error);
@@ -37,6 +40,9 @@ function App() {
}
};
const handleCopy = (fileContent) => {
copy(fileContent);
};
return (
<Container maxWidth="md">
@@ -165,16 +171,23 @@ function App() {
Response
</Typography>
{Object.entries(responseText.result).map(([fileName, fileContent]) => (
<Box key={fileName} sx={{my: 2}}>
<Box key={fileName} sx={{my: 2, p: 2, border: '1px solid #ddd', borderRadius: '4px'}}>
<Typography variant="subtitle1" gutterBottom>
{fileName}
</Typography>
<pre>{fileContent}</pre>
<Button
onClick={() => handleCopy(fileContent)}
variant="outlined"
color="primary"
size="small"
>
Copy Code
</Button>
</Box>
))}
</Box>
)}
</Box>
</Container>
);

View File

@@ -7,10 +7,13 @@ def general_guidelines():
"General guidelines: "
"The code you write is production ready. "
"Every file starts with comments describing what the code is doing before the first import. "
"Comments can only be written between tags. "
"Then all imports are listed. "
"It is important to import all modules that could be needed in the executor code. "
"Always import BytesIO from io. "
"Comments can only be written between tags. "
"Always import: "
"from typing import Dict, List, Optional, Tuple, Union "
"from io import BytesIO "
"from jina import Executor, DocumentArray, Document, requests "
"Start from top-level and then fully implement all methods. "
"\n"
)