Add session to agents (#4216)
Co-authored-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Jack Amadeo <jackamadeo@squareup.com> Co-authored-by: Jack Amadeo <jackamadeo@block.xyz>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Sliders, ChefHat, Bot, Eye, Save } from 'lucide-react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useModelAndProvider } from '../../../ModelAndProviderContext';
|
||||
import { AddModelModal } from '../subcomponents/AddModelModal';
|
||||
import { SwitchModelModal } from '../subcomponents/SwitchModelModal';
|
||||
import { LeadWorkerSettings } from '../subcomponents/LeadWorkerSettings';
|
||||
import { View } from '../../../../utils/navigationUtils';
|
||||
import {
|
||||
@@ -22,6 +22,7 @@ import { toastSuccess, toastError } from '../../../../toasts';
|
||||
import ViewRecipeModal from '../../../ViewRecipeModal';
|
||||
|
||||
interface ModelsBottomBarProps {
|
||||
sessionId: string | null;
|
||||
dropdownRef: React.RefObject<HTMLDivElement>;
|
||||
setView: (view: View) => void;
|
||||
alerts: Alert[];
|
||||
@@ -30,6 +31,7 @@ interface ModelsBottomBarProps {
|
||||
}
|
||||
|
||||
export default function ModelsBottomBar({
|
||||
sessionId,
|
||||
dropdownRef,
|
||||
setView,
|
||||
alerts,
|
||||
@@ -284,7 +286,11 @@ export default function ModelsBottomBar({
|
||||
</DropdownMenu>
|
||||
|
||||
{isAddModelModalOpen ? (
|
||||
<AddModelModal setView={setView} onClose={() => setIsAddModelModalOpen(false)} />
|
||||
<SwitchModelModal
|
||||
sessionId={sessionId}
|
||||
setView={setView}
|
||||
onClose={() => setIsAddModelModalOpen(false)}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{isLeadWorkerModalOpen ? (
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { Button } from '../../../ui/button';
|
||||
import { AddModelModal } from './AddModelModal';
|
||||
import { SwitchModelModal } from './SwitchModelModal';
|
||||
import type { View } from '../../../../utils/navigationUtils';
|
||||
import { shouldShowPredefinedModels } from '../predefinedModelsUtils';
|
||||
|
||||
@@ -23,7 +23,11 @@ export default function ModelSettingsButtons({ setView }: ConfigureModelButtonsP
|
||||
Switch models
|
||||
</Button>
|
||||
{isAddModelModalOpen ? (
|
||||
<AddModelModal setView={setView} onClose={() => setIsAddModelModalOpen(false)} />
|
||||
<SwitchModelModal
|
||||
sessionId={null}
|
||||
setView={setView}
|
||||
onClose={() => setIsAddModelModalOpen(false)}
|
||||
/>
|
||||
) : null}
|
||||
{!hasPredefinedModels && (
|
||||
<Button
|
||||
|
||||
+4
-3
@@ -19,11 +19,12 @@ import type { View } from '../../../../utils/navigationUtils';
|
||||
import Model, { getProviderMetadata } from '../modelInterface';
|
||||
import { getPredefinedModelsFromEnv, shouldShowPredefinedModels } from '../predefinedModelsUtils';
|
||||
|
||||
type AddModelModalProps = {
|
||||
type SwitchModelModalProps = {
|
||||
sessionId: string | null;
|
||||
onClose: () => void;
|
||||
setView: (view: View) => void;
|
||||
};
|
||||
export const AddModelModal = ({ onClose, setView }: AddModelModalProps) => {
|
||||
export const SwitchModelModal = ({ sessionId, onClose, setView }: SwitchModelModalProps) => {
|
||||
const { getProviders, getProviderModels, read } = useConfig();
|
||||
const { changeModel } = useModelAndProvider();
|
||||
const [providerOptions, setProviderOptions] = useState<{ value: string; label: string }[]>([]);
|
||||
@@ -92,7 +93,7 @@ export const AddModelModal = ({ onClose, setView }: AddModelModalProps) => {
|
||||
modelObj = { name: model, provider: provider, subtext: providerDisplayName } as Model;
|
||||
}
|
||||
|
||||
await changeModel(modelObj);
|
||||
await changeModel(sessionId, modelObj);
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user