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

Please implement a recursive function in the chat.tsx file #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions src/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import ReactTextareaAutosize from "react-textarea-autosize";
import { scrollToBottom } from "../../utils/scrollToBottom";
import { v4 as uuid } from "uuid";
import { useQuery } from "@tanstack/react-query";

Check warning on line 7 in src/components/Chat/Chat.tsx

View workflow job for this annotation

GitHub Actions / Lint with ESLint and Prettier

'useQuery' is defined but never used
import { useMutation, useQueryClient } from "react-query";

Check warning on line 8 in src/components/Chat/Chat.tsx

View workflow job for this annotation

GitHub Actions / Lint with ESLint and Prettier

'useQueryClient' is defined but never used
import { chatUserIdAtom } from "src/pages/_app";

const supportedLanguages = [

Check warning on line 11 in src/components/Chat/Chat.tsx

View workflow job for this annotation

GitHub Actions / Lint with ESLint and Prettier

'supportedLanguages' is assigned a value but never used
{
id: "py",
name: "python",
Expand Down Expand Up @@ -41,9 +41,23 @@
};
};



export default function Chat() {

useEffect(() => {
// Implement the recursive function that sums an array of integers
const recursiveArraySum = (arr: number[]): number => {

Check warning on line 50 in src/components/Chat/Chat.tsx

View workflow job for this annotation

GitHub Actions / Lint with ESLint and Prettier

'recursiveArraySum' is assigned a value but never used
if (arr.length === 0) {
return 0;
}
return arr[0] + recursiveArraySum(arr.slice(1));
};
}, []);

const userId = useAtomValue(chatUserIdAtom);


// ref to track text area and scroll text into view
const ref = useRef<HTMLParagraphElement | null>(null);

Expand All @@ -61,7 +75,7 @@

const [userInput, setUserInput] = useState("");

const getAgentReply = async (userData: any) => {

Check warning on line 78 in src/components/Chat/Chat.tsx

View workflow job for this annotation

GitHub Actions / Lint with ESLint and Prettier

Unexpected any. Specify a different type
return await fetch("/api/chat", {
method: "POST",
body: JSON.stringify({
Expand All @@ -74,7 +88,7 @@
});
};

const clearChatHistory = async (userData: any) => {

Check warning on line 91 in src/components/Chat/Chat.tsx

View workflow job for this annotation

GitHub Actions / Lint with ESLint and Prettier

Unexpected any. Specify a different type
return await fetch("/api/clear", {
method: "POST",
body: JSON.stringify({
Expand Down
Loading