diff --git a/.gitignore b/.gitignore index 1de8943..fd3dbb5 100644 --- a/.gitignore +++ b/.gitignore @@ -34,5 +34,3 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts - -api_key.txt \ No newline at end of file diff --git a/app/ConversationFrontend.tsx b/app/Conversation.tsx similarity index 91% rename from app/ConversationFrontend.tsx rename to app/Conversation.tsx index 8b3e560..1caa836 100644 --- a/app/ConversationFrontend.tsx +++ b/app/Conversation.tsx @@ -7,7 +7,7 @@ interface ConversationProps { onCopyClick: () => void; } -const ConversationFrontend = React.forwardRef( +const Conversation = React.forwardRef( ({ messages, onResendClick, onEditClick, onCopyClick }, ref: ForwardedRef) => { return (
@@ -40,4 +40,4 @@ const ConversationFrontend = React.forwardRef } ); -export default ConversationFrontend; +export default Conversation; diff --git a/app/InputBackend.tsx b/app/InputBackend.tsx deleted file mode 100644 index 9576490..0000000 --- a/app/InputBackend.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import React from 'react'; -import InputFrontend from './InputFrontend'; -import ConversationFrontend from './ConversationFrontend'; -import { Mistral } from '@mistralai/mistralai'; - -async function prompt_mistral(model: string, prompt: string, system: string) { - const apiKey = "m3kZRjN8DRSIo88r8Iti9hmKGWIklrLY"; - - const client = new Mistral({ apiKey: apiKey }); - - var chatResponse = await client.chat.complete({ - model: model, - messages: [{ role: 'user', content: prompt }, { role: 'system', content: system, }], - }); - - if (chatResponse && chatResponse.choices && chatResponse.choices.length > 0) { - if (chatResponse.choices[0].message.content) { - messages.push('AI: ', chatResponse.choices[0].message.content); - console.error('Error: Brain Not Found'); - } - } else { - console.error('Error: Unexpected API response:', chatResponse); - } -} - -const handleSendClick = (message: string) => { - messages.push('User: ', message); - prompt_mistral("mistral-large-latest", message, "You are a helpful assistant.") -}; - -const handleMicClick = () => { - console.log('Mic clicked!'); - // Do something when the mic button is clicked -}; - -var messages = [ - 'User: Hello!', - 'AI: Hi there!', - 'User: How are you?', - 'AI: I’m good, thank you!' -]; - -const handleResendClick = () => { - console.log('Resend button clicked'); - // Handle resend action -}; - -const handleEditClick = () => { - console.log('Edit button clicked'); - // Handle edit action -}; - -const handleCopyClick = () => { - console.log('Copy button clicked'); - // Handle copy action -}; - -const InputBackend = () => { - return ( -
- - -
- ); -}; - -export default InputBackend; diff --git a/app/InputForm.tsx b/app/InputForm.tsx new file mode 100644 index 0000000..6abfc64 --- /dev/null +++ b/app/InputForm.tsx @@ -0,0 +1,21 @@ +import React from 'react'; + +const InputForm: React.FC = () => { + return ( +
+ + + +
+ ); +}; + +export default InputForm; diff --git a/app/InputFrontend.tsx b/app/InputFrontend.tsx deleted file mode 100644 index c3cdea8..0000000 --- a/app/InputFrontend.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React, { useState, ForwardedRef } from 'react'; - -interface InputProps { - message: string; - onSendClick: (message: string) => void; - onMicClick: () => void; -} - -const InputFrontend = React.forwardRef( - ({ message, onSendClick, onMicClick }, ref: ForwardedRef) => { - const [inputValue, setInputValue] = useState(''); - - const handleInputChange = (e: React.ChangeEvent) => { - setInputValue(e.target.value); - }; - - return ( -
- - - -
- ); - } -); - -export default InputFrontend; diff --git a/app/backend/ai_api.ts b/app/backend/ai_api.ts new file mode 100644 index 0000000..5cafa54 --- /dev/null +++ b/app/backend/ai_api.ts @@ -0,0 +1,12 @@ +import ollama from 'ollama' + +async function name(model: string, prompt: string, system: string,) { + var message = [{ role: 'user', content: prompt }, { role: 'system', content: system }] + var response = await ollama.chat({ model: model, messages: message, stream: true }) + for await (const part of response) { + process.stdout.write(part.message.content) + } +} + + + diff --git a/app/page.tsx b/app/page.tsx index 05030cd..a53edbb 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -4,7 +4,8 @@ import React, { useState, useEffect, useRef } from 'react'; import Header from './Header'; import History from './History'; import Models from './Models'; -import InputBackend from './InputBackend'; +import Conversation from './Conversation'; +import InputForm from './InputForm'; import './styles/master.css'; const LandingPage: React.FC = () => { @@ -40,6 +41,28 @@ const LandingPage: React.FC = () => { setShowDivs(prevState => !prevState); }; + const messages = [ + 'User: Hello!', + 'AI: Hi there!', + 'User: How are you?', + 'AI: I’m good, thank you!' + ]; + + const handleResendClick = () => { + console.log('Resend button clicked'); + // Handle resend action + }; + + const handleEditClick = () => { + console.log('Edit button clicked'); + // Handle edit action + }; + + const handleCopyClick = () => { + console.log('Copy button clicked'); + // Handle copy action + }; + return (
@@ -49,7 +72,14 @@ const LandingPage: React.FC = () => {
- + +
diff --git a/package-lock.json b/package-lock.json index 64403cd..ec2f85c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,8 +8,6 @@ "name": "interstellar_ai", "version": "0.1.0", "dependencies": { - "@mistralai/mistralai": "^1.0.4", - "fs": "^0.0.1-security", "next": "14.2.12", "ollama": "^0.5.9", "react": "^18", @@ -237,14 +235,6 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@mistralai/mistralai": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@mistralai/mistralai/-/mistralai-1.0.4.tgz", - "integrity": "sha512-fLFBD8r4KvITCkKlKcq2ievnNyLd7Oob4xMY7MkY04BqR4nffkTS49DqapnVkemuldtrmHidwPzwD7UT+yFC4A==", - "peerDependencies": { - "zod": ">= 3" - } - }, "node_modules/@next/env": { "version": "14.2.12", "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.12.tgz", @@ -2333,12 +2323,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/fs": { - "version": "0.0.1-security", - "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", - "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==", - "license": "ISC" - }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -5335,16 +5319,6 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } - }, - "node_modules/zod": { - "version": "3.23.8", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", - "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", - "license": "MIT", - "peer": true, - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } } } } diff --git a/package.json b/package.json index b1b9f3c..2aea3c5 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,6 @@ "lint": "next lint" }, "dependencies": { - "@mistralai/mistralai": "^1.0.4", - "fs": "^0.0.1-security", "next": "14.2.12", "ollama": "^0.5.9", "react": "^18",