Skip to content

Commit

Permalink
Merge pull request #673 from openchatai/pass-query-params
Browse files Browse the repository at this point in the history
pass query params
  • Loading branch information
ah7255703 committed Mar 4, 2024
2 parents b417c29 + 0a959bb commit 4e76f1e
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 86 deletions.
12 changes: 8 additions & 4 deletions copilot-widget/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ <h2>
<div id="opencopilot-root"></div>

<script>
const token = "NtITS4Z07ZrdctTN";
const apiUrl = "http://localhost:8888/backend";
const socketUrl = "http://localhost:8888";
const token = "D3BCYwikexJ0hF1Z";
const apiUrl = "https://api.opencopilot.so/backend";
const socketUrl = "https://api.opencopilot.so";
const sharedConfig = {
initialMessage: "Welcome back! How can I help you today?", // optional
token: token, // required
Expand All @@ -78,13 +78,17 @@ <h2>
// optional
// Authorization: "Bearer BQAlIe479yo16aXf",
},
queryParams: {
// optional
// passing extra query params to the backend along with every user message.
},
bot: {
name: "AI Bot",
},
user: {
// optional
name: "John Doe",
avatarUrl: "https://i.pravatar.cc/[email protected]"
avatarUrl: "https://i.pravatar.cc/[email protected]",
},
};

Expand Down
2 changes: 2 additions & 0 deletions copilot-widget/lib/contexts/Controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const ChatProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
const userMessage: UserMessage & {
session_id: string;
headers: Record<string, string>;
query_params: Record<string, string>;
bot_token: string;
} = {
timestamp: now(),
Expand All @@ -87,6 +88,7 @@ const ChatProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
from: "user",
session_id: sessionId,
headers: config.headers ?? {},
query_params: config?.queryParams ?? {},
bot_token: config.token,
};
socket.emit("send_chat", userMessage);
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 @@ -3,6 +3,7 @@ import type { LangType } from "@lib/locales";
export type Options = {
token: string;
headers?: Record<string, string>;
queryParams?: Record<string, string>;
initialMessage: string;
triggerSelector: string;
apiUrl: string;
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.5.5",
"version": "2.6.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
16 changes: 0 additions & 16 deletions copilot-widget/tsup.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@hookform/resolvers": "^3.3.1",
"@kbox-labs/react-echarts": "^1.0.3",
"@openchatai/copilot-widget": "^2.5.5",
"@openchatai/copilot-widget": "^2.6.0",
"@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.

120 changes: 60 additions & 60 deletions dashboard/public/pilot.js

Large diffs are not rendered by default.

0 comments on commit 4e76f1e

Please sign in to comment.