diff --git a/opentrons-ai-client/src/molecules/InputPrompt/index.tsx b/opentrons-ai-client/src/molecules/InputPrompt/index.tsx index 4bc0a803db3..041c1e7a548 100644 --- a/opentrons-ai-client/src/molecules/InputPrompt/index.tsx +++ b/opentrons-ai-client/src/molecules/InputPrompt/index.tsx @@ -16,7 +16,6 @@ import { TYPOGRAPHY, } from '@opentrons/components' import { SendButton } from '../../atoms/SendButton' -// import { useFetch } from '../../resources/hooks' import { preparedPromptAtom, chatDataAtom } from '../../resources/atoms' import type { ChatData } from '../../resources/types' @@ -44,7 +43,6 @@ export function InputPrompt(): JSX.Element { const userPrompt = watch('userPrompt') ?? '' - // const { data: responseData, loading, error } = useFetch(userPrompt) const calcTextAreaHeight = (): number => { const rowsNum = userPrompt.split('\n').length return rowsNum @@ -55,10 +53,6 @@ export function InputPrompt(): JSX.Element { setLoading(true) try { const response = await axios.post(url, { - // headers: { - // Accept: 'application/json', - // 'Content-Type': 'application/json;charset=UTF-8', - // }, headers: { 'Content-Type': 'application/json', }, @@ -75,20 +69,12 @@ export function InputPrompt(): JSX.Element { } const handleClick = (): void => { - // const userInput: ChatData = { - // role: 'user', - // content: userPrompt, - // } - // setChatData(chatData => [...chatData, userInput]) - // void fetchData(userPrompt) - // setSubmitted(true) - // reset() const userInput: ChatData = { role: 'user', content: userPrompt, } setChatData(chatData => [...chatData, userInput]) - void fetchData(userPrompt) // Call fetchData here + void fetchData(userPrompt) setSubmitted(true) reset() } diff --git a/opentrons-ai-client/src/resources/hooks.ts b/opentrons-ai-client/src/resources/hooks.ts deleted file mode 100644 index e1ce1b84a80..00000000000 --- a/opentrons-ai-client/src/resources/hooks.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { useEffect, useState } from 'react' -import axios from 'axios' - -// const url = 'https://mockgpt.wiremockapi.cloud/v1/chat/completions' -const url = 'http://localhost:8000/streaming/ask' - -interface FetchResult { - data: any - loading: boolean - error: string - fetchData: (prompt: string) => Promise -} - -export const useFetch = (prompt: string): FetchResult => { - const [data, setData] = useState(null) - const [loading, setLoading] = useState(false) - const [error, setError] = useState('') - - console.log('called') - - const fetchData = async (prompt: string): Promise => { - if (prompt !== '') { - setLoading(true) - try { - const response = await axios.post(url, { - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json;charset=UTF-8', - }, - query: { - prompt, - }, - }) - - setData(response.data) - } catch (err) { - setError('Error fetching data from the API.') - } finally { - setLoading(false) - } - } - } - - useEffect(() => { - void fetchData(prompt) - }, [prompt]) - - return { data, loading, error, fetchData } -}