Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linter warnings #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ const nextConfig = {
},
};

export default nextConfig;
export default nextConfig;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "prettier --check '{*,pages/*,public/*,utils/*}.{ts,tsx,js,jsx,json}' && next lint",
"prettier": "prettier --write '{*,pages/*,public/*,utils/*}.{ts,tsx,js,jsx,json}'"
},
"dependencies": {
"@emotion/react": "^11.10.8",
Expand Down
6 changes: 3 additions & 3 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '@/styles/globals.css'
import type { AppProps } from 'next/app'
import "@/styles/globals.css";
import type { AppProps } from "next/app";

export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
return <Component {...pageProps} />;
}
4 changes: 2 additions & 2 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Html, Head, Main, NextScript } from 'next/document'
import { Html, Head, Main, NextScript } from "next/document";

export default function Document() {
return (
Expand All @@ -9,5 +9,5 @@ export default function Document() {
<NextScript />
</body>
</Html>
)
);
}
10 changes: 3 additions & 7 deletions pages/api/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@
import {
Configuration,
OpenAIApi,
ChatCompletionRequestMessageRoleEnum,} from "openai";
ChatCompletionRequestMessageRoleEnum,
} from "openai";
import type { NextApiRequest, NextApiResponse } from "next";


const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});

const openai = new OpenAIApi(configuration);

async function chatHandler(
req: NextApiRequest,
res: NextApiResponse
) {
async function chatHandler(req: NextApiRequest, res: NextApiResponse) {
const completion = await openai.createChatCompletion({
// Downgraded to GPT-3.5 due to high traffic. Sorry for the inconvenience.
// If you have access to GPT-4, simply change the model to "gpt-4"
Expand All @@ -26,7 +23,6 @@ async function chatHandler(
role: ChatCompletionRequestMessageRoleEnum.System,
content: "You are a helpful assistant.",
},

].concat(req.body.messages),
temperature: 0,
});
Expand Down
19 changes: 8 additions & 11 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useRef, useEffect, FormEvent, KeyboardEvent} from "react";
import { useState, useRef, useEffect, FormEvent, KeyboardEvent } from "react";
import Head from "next/head";
import styles from "../styles/Home.module.css";
import Image from "next/image";
Expand All @@ -16,7 +16,6 @@ export default function Home() {
const messageListRef = useRef<HTMLDivElement>(null);
const textAreaRef = useRef<HTMLTextAreaElement>(null);


// Auto scroll chat to bottom
useEffect(() => {
if (messageListRef.current) {
Expand All @@ -25,12 +24,12 @@ export default function Home() {
}
}, [messages]);

// Focus on input field
useEffect(() => {
if (textAreaRef.current) {
textAreaRef.current.focus();
}
}, []);
// Focus on input field
useEffect(() => {
if (textAreaRef.current) {
textAreaRef.current.focus();
}
}, []);

// Handle errors
const handleError = () => {
Expand Down Expand Up @@ -113,7 +112,6 @@ useEffect(() => {
>
Docs
</a>

</div>
</div>
<main className={styles.main}>
Expand Down Expand Up @@ -175,7 +173,6 @@ useEffect(() => {
autoFocus={false}
rows={1}
maxLength={512}

id="userInput"
name="userInput"
placeholder={
Expand Down Expand Up @@ -213,7 +210,7 @@ useEffect(() => {
<a href="https://openai.com/" target="_blank">
OpenAI
</a>
.
.
</p>
</div>
</div>
Expand Down