Skip to content

Commit

Permalink
Merge pull request #34 from SkywardAI/chatgpt
Browse files Browse the repository at this point in the history
invoke chatgpt & fix bugs
  • Loading branch information
cbh778899 authored Sep 17, 2024
2 parents 201d74b + e7441bf commit 25fa0ab
Show file tree
Hide file tree
Showing 12 changed files with 408 additions and 77 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "shibuya",
"author": {
"name": "Bohan Cheng",
"email": "[email protected]"
"name": "Bohan Cheng",
"email": "[email protected]"
},
"version": "0.1.11",
"main": "electron.js",
Expand All @@ -20,6 +20,7 @@
"@aws-sdk/credential-providers": "^3.650.0",
"@huggingface/jinja": "^0.3.0",
"@wllama/wllama": "^1.16.0",
"openai": "^4.61.0",
"react": "^18.3.1",
"react-bootstrap-icons": "^1.11.4",
"react-dom": "^18.3.1",
Expand Down
132 changes: 132 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions src/components/chat/Conversation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { FileImageFill, FileTextFill, Paperclip, Send, StopCircleFill } from 're
import useIDB from "../../utils/idb";
import { isModelLoaded, loadModel } from '../../utils/workers/worker'
import { getCompletionFunctions } from "../../utils/workers";
import { setClient } from "../../utils/workers/aws-worker";
import { setClient as setAwsClient } from "../../utils/workers/aws-worker";
import { setClient as setOpenaiClient } from "../../utils/workers/openai-worker";

export default function Conversation({ uid, client }) {
export default function Conversation({ uid, client, updateClient }) {

const [conversation, setConversation] = useState([]);
const [message, setMessage] = useState('');
Expand Down Expand Up @@ -130,15 +131,21 @@ export default function Conversation({ uid, client }) {
useEffect(()=>{
if(!chat_functions.current) return;

if(chat_functions.current.platform === 'AWS') {
const platform = chat_functions.current.platform
if(platform) {
(async function() {
if(await setClient(client)) {
await idb.updateOne('chat-history', {client}, [{uid}])
let set_result =
platform === "AWS" ? await setAwsClient(client) :
platform === "OpenAI" ? await setOpenaiClient(client) :
null;

if(set_result) {
updateClient(set_result);
}
})()
}
// eslint-disable-next-line
}, [chat_functions, client])
}, [client])

return (
<div className="conversation-main">
Expand Down
Loading

0 comments on commit 25fa0ab

Please sign in to comment.