Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
Merge pull request #475 from openchatai/fix/streaming-url
Browse files Browse the repository at this point in the history
Update Copilot widget HTML and Controller context
  • Loading branch information
faltawy authored Dec 29, 2023
2 parents e072f08 + 70b4543 commit eee6e6f
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 48 deletions.
79 changes: 40 additions & 39 deletions copilot-widget/index.html
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Openchat AI-Copilot</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1,maximum-scale=1"
/>
</head>

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Openchat AI-Copilot</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1" />
</head>

<body>
<button id="triggerSelector">toggle the chat widget</button>
<script type="module" src="/src/main.tsx"></script>
<script>
window.onload = () => {
initAiCoPilot({
initialMessage: "Hi Sir",
token: "5AciN2ZUgIxh43BH",
triggerSelector: "#triggerSelector",
apiUrl: "http://localhost:8888/backend",
defaultOpen: true,
headers:
{
Authorization: "Bearer BQAlIe479yo16aXf",
},
user: {
name: "John Doe",
},
containerProps: {
style: {
position: "fixed",
height: "100%",
bottom: "0",
right: "0",
width: "400px",
<body>
<button id="triggerSelector">toggle the chat widget</button>
<script type="module" src="/src/main.tsx"></script>
<script>
window.onload = () => {
initAiCoPilot({
initialMessage: "Hi Sir",
token: "5AciN2ZUgIxh43BH",
triggerSelector: "#triggerSelector",
apiUrl: "http://localhost:8888/backend",
socketUrl: "http://localhost:8888",
defaultOpen: true,
headers: {
Authorization: "Bearer BQAlIe479yo16aXf",
},
},
});
};
</script>
</body>

</html>
user: {
name: "John Doe",
},
containerProps: {
style: {
position: "fixed",
height: "100%",
bottom: "0",
right: "0",
width: "400px",
},
},
});
};
</script>
</body>
</html>
3 changes: 1 addition & 2 deletions copilot-widget/lib/contexts/Controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ const ChatProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
const config = useConfigData();
const { sessionId } = useSessionId(config.token);
const [conversationInfo, setConversationInfo] = useState<string | null>(null);

useEffect(() => {
getInitialData(axiosInstance).then((data) => {
setMessages(historyToMessages(data.history))
})
}, [axiosInstance]);

const socket = useMemo(() => io('http://localhost:8888', {
const socket = useMemo(() => io(config.socketUrl, {
extraHeaders: {
"X-Bot-Token": config.token,
"X-Session-Id": sessionId,
Expand Down
1 change: 1 addition & 0 deletions copilot-widget/lib/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export type Options = {
initialMessage: string;
triggerSelector: string;
apiUrl: string;
socketUrl: string;
defaultOpen?: boolean;
containerProps?: React.DetailedHTMLProps<
React.HTMLAttributes<HTMLDivElement>,
Expand Down
2 changes: 1 addition & 1 deletion copilot-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openchatai/copilot-widget",
"private": false,
"version": "2.0.0",
"version": "2.0.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@hookform/resolvers": "^3.3.1",
"@openchatai/copilot-widget": "^2.0.0",
"@openchatai/copilot-widget": "^2.0.1",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-avatar": "^1.0.4",
Expand Down
8 changes: 4 additions & 4 deletions dashboard/pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion dashboard/public/pilot.js

Large diffs are not rendered by default.

0 comments on commit eee6e6f

Please sign in to comment.