mirror of https://github.com/kortix-ai/suna.git
Merge pull request #665 from escapade-mckv/content-length-fix
Content length fix
This commit is contained in:
commit
da1ef81a2b
|
@ -1711,7 +1711,7 @@ class ResponseProcessor:
|
|||
# "parsing_details": parsing_details
|
||||
# }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# STRUCTURED_OUTPUT_TOOLS = {
|
||||
# "str_replace",
|
||||
|
|
|
@ -10,12 +10,10 @@ import Link from 'next/link';
|
|||
import { useRouter } from 'next/navigation';
|
||||
import { useAuth } from '@/components/AuthProvider';
|
||||
import {
|
||||
createProject,
|
||||
createThread,
|
||||
addUserMessage,
|
||||
BillingError,
|
||||
} from '@/lib/api';
|
||||
import { useStartAgentMutation } from '@/hooks/react-query/threads/use-agent-run';
|
||||
import { useInitiateAgentMutation } from '@/hooks/react-query/dashboard/use-initiate-agent';
|
||||
import { useThreadQuery } from '@/hooks/react-query/threads/use-threads';
|
||||
import { generateThreadName } from '@/lib/actions/threads';
|
||||
import GoogleSignIn from '@/components/GoogleSignIn';
|
||||
import { Input } from '@/components/ui/input';
|
||||
|
@ -59,7 +57,9 @@ export function HeroSection() {
|
|||
const { data: accounts } = useAccounts();
|
||||
const personalAccount = accounts?.find((account) => account.personal_account);
|
||||
const { onOpen } = useModal();
|
||||
const startAgentMutation = useStartAgentMutation();
|
||||
const initiateAgentMutation = useInitiateAgentMutation();
|
||||
const [initiatedThreadId, setInitiatedThreadId] = useState<string | null>(null);
|
||||
const threadQuery = useThreadQuery(initiatedThreadId || '');
|
||||
|
||||
// Auth dialog state
|
||||
const [authDialogOpen, setAuthDialogOpen] = useState(false);
|
||||
|
@ -93,14 +93,12 @@ export function HeroSection() {
|
|||
};
|
||||
}, [scrollY]);
|
||||
|
||||
// Store the input value when auth dialog opens
|
||||
useEffect(() => {
|
||||
if (authDialogOpen && inputValue.trim()) {
|
||||
localStorage.setItem(PENDING_PROMPT_KEY, inputValue.trim());
|
||||
}
|
||||
}, [authDialogOpen, inputValue]);
|
||||
|
||||
// Close dialog and redirect when user authenticates
|
||||
useEffect(() => {
|
||||
if (authDialogOpen && user && !isLoading) {
|
||||
setAuthDialogOpen(false);
|
||||
|
@ -108,38 +106,40 @@ export function HeroSection() {
|
|||
}
|
||||
}, [user, isLoading, authDialogOpen, router]);
|
||||
|
||||
// Create an agent with the provided prompt
|
||||
useEffect(() => {
|
||||
if (threadQuery.data && initiatedThreadId) {
|
||||
const thread = threadQuery.data;
|
||||
if (thread.project_id) {
|
||||
router.push(`/projects/${thread.project_id}/thread/${initiatedThreadId}`);
|
||||
} else {
|
||||
router.push(`/thread/${initiatedThreadId}`);
|
||||
}
|
||||
setInitiatedThreadId(null);
|
||||
}
|
||||
}, [threadQuery.data, initiatedThreadId, router]);
|
||||
|
||||
const createAgentWithPrompt = async () => {
|
||||
if (!inputValue.trim() || isSubmitting) return;
|
||||
|
||||
setIsSubmitting(true);
|
||||
|
||||
try {
|
||||
// Generate a name for the project using GPT
|
||||
const projectName = await generateThreadName(inputValue);
|
||||
const formData = new FormData();
|
||||
formData.append('prompt', inputValue.trim());
|
||||
formData.append('model_name', 'openrouter/deepseek/deepseek-chat');
|
||||
formData.append('enable_thinking', 'false');
|
||||
formData.append('reasoning_effort', 'low');
|
||||
formData.append('stream', 'true');
|
||||
formData.append('enable_context_manager', 'false');
|
||||
|
||||
// 1. Create a new project with the GPT-generated name
|
||||
const newAgent = await createProject({
|
||||
name: projectName,
|
||||
description: '',
|
||||
});
|
||||
const result = await initiateAgentMutation.mutateAsync(formData);
|
||||
|
||||
const thread = await createThread(newAgent.id);
|
||||
await addUserMessage(thread.thread_id, inputValue.trim());
|
||||
await startAgentMutation.mutateAsync({
|
||||
threadId: thread.thread_id,
|
||||
options: {
|
||||
model_name: 'openrouter/deepseek/deepseek-chat',
|
||||
stream: true,
|
||||
},
|
||||
});
|
||||
router.push(`/projects/${newAgent.id}/thread/${thread.thread_id}`);
|
||||
setInitiatedThreadId(result.thread_id);
|
||||
setInputValue('');
|
||||
} catch (error: any) {
|
||||
console.error('Error creating agent:', error);
|
||||
|
||||
if (error instanceof BillingError) {
|
||||
console.log('Handling BillingError from hero section:', error.detail);
|
||||
onOpen("paymentRequiredDialog");
|
||||
} else {
|
||||
const isConnectionError =
|
||||
error instanceof TypeError &&
|
||||
|
|
Loading…
Reference in New Issue