include sessionId in tool request (#5394)
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
|||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
} from '../../ui/dropdown-menu';
|
} from '../../ui/dropdown-menu';
|
||||||
|
import { useChatContext } from '../../../contexts/ChatContext';
|
||||||
|
|
||||||
function getFirstSentence(text: string): string {
|
function getFirstSentence(text: string): string {
|
||||||
const match = text.match(/^([^.?!]+[.?!])/);
|
const match = text.match(/^([^.?!]+[.?!])/);
|
||||||
@@ -27,6 +28,9 @@ export default function PermissionModal({ extensionName, onClose }: PermissionMo
|
|||||||
{ value: 'never_allow', label: 'Never allow' },
|
{ value: 'never_allow', label: 'Never allow' },
|
||||||
] as { value: PermissionLevel; label: string }[];
|
] as { value: PermissionLevel; label: string }[];
|
||||||
|
|
||||||
|
const chatContext = useChatContext();
|
||||||
|
const sessionId = chatContext?.chat.sessionId || '';
|
||||||
|
|
||||||
const [tools, setTools] = useState<ToolInfo[]>([]);
|
const [tools, setTools] = useState<ToolInfo[]>([]);
|
||||||
const [updatedPermissions, setUpdatedPermissions] = useState<Record<string, string>>({});
|
const [updatedPermissions, setUpdatedPermissions] = useState<Record<string, string>>({});
|
||||||
|
|
||||||
@@ -41,8 +45,7 @@ export default function PermissionModal({ extensionName, onClose }: PermissionMo
|
|||||||
const fetchTools = async () => {
|
const fetchTools = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await getTools({
|
const response = await getTools({
|
||||||
// TODO(Douwe): pass session ID or maybe? do we configure the tools for the agent or globally?
|
query: { extension_name: extensionName, session_id: sessionId },
|
||||||
query: { extension_name: extensionName, session_id: '' },
|
|
||||||
});
|
});
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
console.error('Failed to get tools');
|
console.error('Failed to get tools');
|
||||||
@@ -59,7 +62,7 @@ export default function PermissionModal({ extensionName, onClose }: PermissionMo
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchTools();
|
fetchTools();
|
||||||
}, [extensionName]);
|
}, [extensionName, sessionId]);
|
||||||
|
|
||||||
const handleSettingChange = (toolName: string, newPermission: PermissionLevel) => {
|
const handleSettingChange = (toolName: string, newPermission: PermissionLevel) => {
|
||||||
setUpdatedPermissions((prev) => ({
|
setUpdatedPermissions((prev) => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user