Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
82ce984
style: create application style
LucasLuccaCode Feb 12, 2023
fdb23c5
feat: add event to the form to post the question asked on the page
LucasLuccaCode Feb 12, 2023
242deac
feat: create function to send question and get answer
LucasLuccaCode Feb 12, 2023
e5017f1
feat: add stop request button
LucasLuccaCode Feb 12, 2023
d82ffa4
feat: add functionality to write response
LucasLuccaCode Feb 12, 2023
1a21f03
feat: add cache to data
LucasLuccaCode Feb 12, 2023
7f3016c
feat(settings): add settings for application control
LucasLuccaCode Feb 15, 2023
fed17a9
fix: handle errors when the api returns an error message
LucasLuccaCode Feb 15, 2023
59cfdc9
style: header layout changes
LucasLuccaCode Feb 15, 2023
dd192ec
refactor(settings): change how to set text size in settings
LucasLuccaCode Feb 15, 2023
2e8d8cc
feat: apply logic to save queries and include context in requests whe…
LucasLuccaCode Feb 15, 2023
3b47f40
feat: add layout to show consultation chats on the application's home…
LucasLuccaCode Feb 16, 2023
3ca31a6
refactor(styles): separate application styles into other files
LucasLuccaCode Feb 16, 2023
a715003
feat: add functionality to the button to start a new chat
LucasLuccaCode Feb 16, 2023
2139513
feat(chat): apply edit and delete functionality to chat buttons
LucasLuccaCode Feb 16, 2023
ce2cd54
refactor: change header images by cdn icons from bootstrap icons
LucasLuccaCode Feb 16, 2023
26d9759
fix(chats): fix error when editing chat name save duplicate
LucasLuccaCode Feb 17, 2023
0a4e5a7
refactor: refactor the code of the sendQuestion function to eliminate…
LucasLuccaCode Feb 17, 2023
b57c684
fix: fix error when clicking back button was not hiding footer
LucasLuccaCode Feb 17, 2023
dc2b218
feat: add .gitignore
LucasLuccaCode Feb 19, 2023
094ee7c
style: change style of error message
LucasLuccaCode Mar 2, 2023
f06c9c9
docs: add README.md
LucasLuccaCode Mar 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules

*.local
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ChatGPT Html Interface

Este projeto é uma interface inicial de chatbot para consumir a API do ChatGPT, utilizando Html, Css3, JavaScript. A API do ChatGPT é uma API de processamento de linguagem natural (NLP) que permite a criação de chatbots.

![Preview](https://github.com/LucasLuccaCode/chatgpt-react-interface/blob/main/.github/preview.png)

## Como utilizar

Clone este repositório:

```
git clone https://github.com/LucasLuccaCode/chatgpt-react-interface.git
```

Navegue para a pasta do projeto:

```
cd chatgpt-react-interface
```

Mude para a branch `main` para ter acesso ao projeto usando somente JavaScript puro:

```
git checkout main
```

Antes de executar o projeto, preencha a variável `API_KEY` no arquivo `index.js`, com sua chave de autorização para a API do ChatGPT. A chave pode ser obtida através do site da [OpenAI](https://platform.openai.com/account/api-keys).


```js
const API_KEY = "sua-chave-api"
```

Em seguida poderá abrir o projeto no navegador.

## Principais funcionalidades

- Perguntas e Respostas
- Chats
- Contexto contendo respostas anteriores do chat(experimental)
- Redimensionamento dos textos e espaços

## Tecnologias e serviços usados

- Html
- Css3
- JavaScript
71 changes: 71 additions & 0 deletions assets/css/chats.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.c-chats {
width: 100%;
}

.c-chats__card {
cursor: pointer;
display: flex;
align-items: center;
width: 100%;
padding: .5rem .8rem;
border: 2px solid rgba(255, 255, 255, .05);
border-radius: .4rem;
margin-top: .8rem;
background: rgba(255, 255, 255, .1);
}

.c-chats__card:hover {
background: rgba(255, 255, 255, .2);
}

.c-chats__card__title {
pointer-events: none;
flex: 1;
font-size: .8rem;
color: #efefff;
padding: .3rem 0rem;
border-radius: .2rem;
transition: all .3s;
}

.c-chats__card__title:focus {
outline: 1.8px solid rgba(255, 255, 255, .1);
text-overflow: initial;
}

.c-chats__card__title.editing {
pointer-events: auto;
padding: .3rem .5rem;
}

.c-chats__card__title::first-letter {
text-transform: capitalize;
}

.c-chats__card__actions {
display: flex;
gap: .5rem;
margin-left: .5rem;
}

.c-chats__card__actions button {
border-radius: .3rem;
padding: .3rem;
background: rgba(255, 255, 255, .1);
transition: .3s;
}

.c-chats__card__actions button:hover {
background: rgba(255, 255, 255, .2);
box-shadow: 0 0 1px 2px var(--details-color);
}

.c-chats__card__actions button i {
pointer-events: none;
font-size: .7rem;
color: #dadae0;
}

.c-chats__card__actions button:hover i {
color: #fff;
}
93 changes: 93 additions & 0 deletions assets/css/footer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/* FOOTER */

.c-footer {
margin: 0 var(--margin-h);
margin-top: 1rem;
}

.c-footer.hide {
display: none;
}
/* STATUS */

.c-status {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: .5rem;
}

.c-status__progress {
font-size: .8rem;
color: rgba(255, 255, 255, .5);
}

.c-status__stop {
font-size: .7rem;
padding: .3rem .5rem;
color: #fff;
font-weight: bold;
border-radius: .2rem;
background: var(--details-color);
opacity: 1;
transition: opacity .4s ease;
}

.c-status__stop.hide {
opacity: 0;
}

.c-status__stop:hover {
background: #059ddf;
}

/* QUESTION */

.c-ask_form {
display: flex;
align-items: center;
background: var(--secondary-color);
border-radius: .3rem;
border: 2px solid transparent;
transition: border .3s;
}

.c-ask_form:focus-within {
border: 2px solid var(--details-color);
}

.c-ask_form textarea {
flex: 1;
padding: .5rem;
height: 100%;
font-size: .8rem;
color: #babac0;
border-radius: .3rem;
border: 2px solid transparent;
background: transparent;
}

.c-ask_form textarea:disabled {
opacity: .5;
}

.c-ask_form button {
padding: .25rem;
border-radius: .2rem;
margin: 0 .3rem 0 .5rem;
background: transparent;
transition: background-color .3s ease;
}

.c-ask_form button:hover {
background: rgba(0, 0, 0, .2);
}

.c-ask_form button:focus {
border: 2px solid rgba(255, 255, 255, .1);
}

.c-ask_form button i {
font-size: 1rem;
color: var(--details-color);
}
55 changes: 55 additions & 0 deletions assets/css/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
:root {
--primary-color: #2a2a30;
--secondary-color: #3a3a40;
--details-color: #00b1ff;
--margin-h: .8rem;
--font-size: 18px;
}

*, *::before {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
}

body,
html {
width: 100%;
height: 100%;
font-size: var(--font-size);
/* background-color: #222225; */
background: var(--primary-color);
}

textarea,
button {
border: none;
outline: none;
resize: none;
}

button {
cursor: pointer;
}

li {
list-style: none;
}

.nowrap {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}

.c-container {
display: flex;
flex-direction: column;
width: 100%;
max-width: 600px;
height: 100%;
margin: 0 auto;
padding-bottom: var(--margin-h);
background: var(--primary-color);
}
29 changes: 29 additions & 0 deletions assets/css/header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.c-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: .5rem var(--margin-h);
background: var(--secondary-color);
}

.c-header h1 {
color: #efefff;
font-size: 1rem;
}

.c-header button {
justify-content: center;
background: transparent;
border-radius: .2rem;
}

.c-header button:hover {
background: rgba(255, 255, 255, .1);
}

.c-header button i {
display: flex;
align-items: center;
font-size: 1.5rem;
color: #efefff;
}
29 changes: 29 additions & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.c-main {
flex: 1;
margin-top: 1rem;
margin-right: .3rem;
margin-left: var(--margin-h);
padding-right: calc(var(--margin-h) - .3rem);
overflow-y: auto;
}

.c-main::-webkit-scrollbar {
width: .3rem;
}

.c-main::-webkit-scrollbar-track {
background: transparent;
}

.c-main::-webkit-scrollbar-thumb {
background-color: var(--details-color);
border-radius: 20px;
}

.placeholder {
text-align: center;
font-size: .8rem;
width: 100%;
color: #afafbf;
margin-top: 1rem;
}
Loading