Skip to content

Commit

Permalink
Merge pull request #1 from susom/vite-config
Browse files Browse the repository at this point in the history
Vite config
  • Loading branch information
Jordan-M-Schultz authored Jun 19, 2024
2 parents 4463bd0 + 92c7876 commit 440e959
Show file tree
Hide file tree
Showing 46 changed files with 6,777 additions and 14 deletions.
4 changes: 2 additions & 2 deletions MICA.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function redcap_module_ajax($action, $payload, $project_id, $record, $ins
// }

//CALL API ENDPOINT WITH AUGMENTED CHATML
$response = $this->getSecureChatInstance()->callAI("gpt-4o",$messages);
$response = $this->getSecureChatInstance()->callAI("gpt-4o",array("messages" =>$messages) );
$result = $this->formatResponse($response);

$this->emDebug("calling SecureChatAI.callAI()", $result);
Expand All @@ -191,7 +191,7 @@ public function redcap_module_ajax($action, $payload, $project_id, $record, $ins

private function getEmbedding($text) {
try {
$result = $this->getSecureChatInstance()->callAI("ada-002", $text);
$result = $this->getSecureChatInstance()->callAI("ada-002", array("input" => $text) );
return $result['data'][0]['embedding'];
} catch (GuzzleException $e) {
$this->emError("Embedding error: " . $e->getMessage());
Expand Down
6 changes: 3 additions & 3 deletions chatbot_ui/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"files": {
"main.css": "/static/css/main.da89d019.css",
"main.js": "/static/js/main.05320a56.js",
"main.js": "/static/js/main.0a989e88.js",
"static/js/488.5c64e536.chunk.js": "/static/js/488.5c64e536.chunk.js",
"service-worker.js": "/service-worker.js",
"index.html": "/index.html",
"main.da89d019.css.map": "/static/css/main.da89d019.css.map",
"main.05320a56.js.map": "/static/js/main.05320a56.js.map",
"main.0a989e88.js.map": "/static/js/main.0a989e88.js.map",
"488.5c64e536.chunk.js.map": "/static/js/488.5c64e536.chunk.js.map"
},
"entrypoints": [
"static/css/main.da89d019.css",
"static/js/main.05320a56.js"
"static/js/main.0a989e88.js"
]
}
2 changes: 1 addition & 1 deletion chatbot_ui/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><script src="https://cdn.jsdelivr.net/npm/react-bootstrap@next/dist/react-bootstrap.min.js" crossorigin></script><title>REDCap Chat GPT Powered Support Chatbot</title><script defer="defer" src="/static/js/main.05320a56.js"></script><link href="/static/css/main.da89d019.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><script src="https://cdn.jsdelivr.net/npm/react-bootstrap@next/dist/react-bootstrap.min.js" crossorigin></script><title>REDCap Chat GPT Powered Support Chatbot</title><script defer="defer" src="/static/js/main.0a989e88.js"></script><link href="/static/css/main.da89d019.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"></body></html>
2 changes: 1 addition & 1 deletion chatbot_ui/build/service-worker.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion chatbot_ui/build/static/js/main.05320a56.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions chatbot_ui/build/static/js/main.0a989e88.js.map

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions chatbot_ui/src/contexts/Chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,14 @@ export const ChatContextProvider = ({ children }) => {
setMsgCount(0);
setMessages([]);
setSessionId(newSessionId);
// Clear chatContext and apiContext without saving

// Filter apiContext to keep only "system" roles
const filteredApiContext = apiContextRef.current.filter(entry => entry.role === "system");
chatContextRef.current = [];
apiContextRef.current = [];
apiContextRef.current = filteredApiContext;

setChatContext([]);
setApiContext([]);
setApiContext(filteredApiContext);
};

const replaceSession = async (session) => {
Expand Down
21 changes: 21 additions & 0 deletions mica-chatbot/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react/jsx-no-target-blank': 'off',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
24 changes: 24 additions & 0 deletions mica-chatbot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
8 changes: 8 additions & 0 deletions mica-chatbot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# React + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
13 changes: 13 additions & 0 deletions mica-chatbot/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
Loading

0 comments on commit 440e959

Please sign in to comment.