mirror of https://github.com/kortix-ai/suna.git
fix(lp): fix agent start on landing page
This commit is contained in:
parent
1186ffefa3
commit
3535c157b7
|
@ -13,9 +13,9 @@ import {
|
||||||
createProject,
|
createProject,
|
||||||
createThread,
|
createThread,
|
||||||
addUserMessage,
|
addUserMessage,
|
||||||
startAgent,
|
|
||||||
BillingError,
|
BillingError,
|
||||||
} from '@/lib/api';
|
} from '@/lib/api';
|
||||||
|
import { useStartAgentMutation } from '@/hooks/react-query/threads/use-agent-run';
|
||||||
import { generateThreadName } from '@/lib/actions/threads';
|
import { generateThreadName } from '@/lib/actions/threads';
|
||||||
import GoogleSignIn from '@/components/GoogleSignIn';
|
import GoogleSignIn from '@/components/GoogleSignIn';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
|
@ -59,6 +59,7 @@ export function HeroSection() {
|
||||||
const { data: accounts } = useAccounts();
|
const { data: accounts } = useAccounts();
|
||||||
const personalAccount = accounts?.find((account) => account.personal_account);
|
const personalAccount = accounts?.find((account) => account.personal_account);
|
||||||
const { onOpen } = useModal();
|
const { onOpen } = useModal();
|
||||||
|
const startAgentMutation = useStartAgentMutation();
|
||||||
|
|
||||||
// Auth dialog state
|
// Auth dialog state
|
||||||
const [authDialogOpen, setAuthDialogOpen] = useState(false);
|
const [authDialogOpen, setAuthDialogOpen] = useState(false);
|
||||||
|
@ -123,20 +124,16 @@ export function HeroSection() {
|
||||||
description: '',
|
description: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
// 2. Create a new thread for this project
|
|
||||||
const thread = await createThread(newAgent.id);
|
const thread = await createThread(newAgent.id);
|
||||||
|
|
||||||
// 3. Add the user message to the thread
|
|
||||||
await addUserMessage(thread.thread_id, inputValue.trim());
|
await addUserMessage(thread.thread_id, inputValue.trim());
|
||||||
|
await startAgentMutation.mutateAsync({
|
||||||
// 4. Start the agent with the thread ID
|
threadId: thread.thread_id,
|
||||||
await startAgent(thread.thread_id, {
|
options: {
|
||||||
stream: true,
|
model_name: 'openrouter/deepseek/deepseek-chat',
|
||||||
|
stream: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
router.push(`/projects/${newAgent.id}/thread/${thread.thread_id}`);
|
||||||
// 5. Navigate to the new agent's thread page
|
|
||||||
router.push(`/agents/${thread.thread_id}`);
|
|
||||||
// Clear input on success
|
|
||||||
setInputValue('');
|
setInputValue('');
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('Error creating agent:', error);
|
console.error('Error creating agent:', error);
|
||||||
|
|
Loading…
Reference in New Issue