Skip to content

Commit 5aa7131

Browse files
committed
basic styling
1 parent d594109 commit 5aa7131

File tree

4 files changed

+61
-18
lines changed

4 files changed

+61
-18
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
# LLM React App Javascript Template
22

3+
## What is a LLM React App Javascript Template?
4+
35
This a template project for a simple chat app connected to a Large Language Model (LLM). This is built on top of [the React template app from nano-react-app](https://github.com/nano-react-app/template-js). To connect the React app to an LLM, a Node server has been added to the project.
46

7+
These are the available commands:
8+
59
- `npm start-server` — This will start a development node backend server with a default port of `3100`.
610
- `npm start` — This will start a development server for the react frontend app with a default port of `5173`.
711
- `npm run build` — This will output a production build in the `dist` directory.
812
- `npm run preview` — This will run the production build locally with a default port of `5173` (this will not work if you haven't generated the production build yet).
913

14+
## Getting Started
15+
16+
To get started, create a `.env` file by copying the `SAMPLE_env` file. Then, add your Open API key to the file.
17+
Now you are ready to run the server and the web app.
18+
1019
## Custom port
1120

1221
You can use the `-p` flag to specify a port for development. To do this, you can either run `npm start` with an additional flag:

server/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import logger from 'koa-logger';
88
// instantiate app
99
const app = new Koa();
1010

11-
console.log('process ', process.env.OPENAI_API_KEY);
1211
app.use(koaBody({
1312
jsonLimit: '10mb',
1413
formLimit: '10mb',

src/App.jsx

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1-
import React from "react";
2-
import { Chat } from "./Chat";
3-
export default () => (
4-
<>
5-
<h1>Welcome to the LLM React App</h1>
6-
<p>This app is connected to a large language model and ready to go. Ask it anything below.</p>
7-
<Chat/>
8-
</>
9-
);
1+
import React from 'react';
2+
import { Chat } from './Chat';
3+
4+
export default () => {
5+
const gridStyle = {
6+
alignItems: 'center',
7+
display: 'flex',
8+
flexDirection: 'column',
9+
justifyContent: 'center',
10+
};
11+
12+
return (
13+
<>
14+
<div style={gridStyle}>
15+
<h1>Welcome to the LLM React App</h1>
16+
<p>This app is connected to a large language model and ready to go. Ask it anything below.</p>
17+
<Chat/>
18+
</div>
19+
20+
</>
21+
)
22+
};

src/Chat.jsx

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useState } from 'react';
22
import { chatServices } from './services/chat-services';
3-
import { CircularProgress, Typography } from '@mui/material';
3+
import { Grid, CircularProgress, Typography } from '@mui/material';
44
import { KeyboardReturn } from '@mui/icons-material';
55

66
const Chat = () => {
@@ -23,10 +23,8 @@ const Chat = () => {
2323
try {
2424
setLoading(true);
2525
const { response } = await chatServices.create({ userInput });
26-
console.log('the chat bot res ', response);
2726
setAnswer(response);
2827
} catch (err) {
29-
console.log('err ', err);
3028
setError(err);
3129
return;
3230
} finally {
@@ -39,23 +37,47 @@ const Chat = () => {
3937
setAnswer('');
4038
}
4139
}, [userInput]);
40+
41+
const gridStyle = {
42+
alignItems: 'center',
43+
display: 'flex',
44+
flexDirection: 'column',
45+
justifyContent: 'center',
46+
};
47+
48+
const inputStyle = {
49+
boxShadow: 24,
50+
height: '25px',
51+
width: '300px',
52+
minWidth: '100px',
53+
}
4254

4355
return (
44-
<div>
45-
<input style={{ width: '50%', boxShadow: 24 }}
56+
<Grid container spacing={2} style={gridStyle}>
57+
<Grid item xs={8} style={{ display: 'flex', flexDirection: 'row' }}>
58+
<input style={inputStyle}
4659
value={userInput}
4760
onChange={handleInputChange}
4861
onKeyDown={handlSendUserInput}
4962
disabled={loading}
5063
>
5164
</input>
52-
<KeyboardReturn style={{ cursor: 'pointer' }}/>
65+
<div style={{ marginLeft: '5px', marginTop: '5px' }}>
66+
<KeyboardReturn />
67+
</div>
68+
</Grid>
69+
<Grid item xs={8}>
5370
<div>
54-
{loading && <CircularProgress />}
71+
{loading && <div>
72+
<CircularProgress color="secondary" />
73+
<CircularProgress color="success" />
74+
<CircularProgress color="inherit" />
75+
</div>}
5576
{answer && <Typography>{answer}</Typography>}
5677
{error && <p>Something bad happened</p>}
5778
</div>
58-
</div>
79+
</Grid>
80+
</Grid>
5981
);
6082
};
6183

0 commit comments

Comments
 (0)