Merge pull request #665 from escapade-mckv/content-length-fix

Content length fix
This commit is contained in:
Bobbie 2025-06-06 17:12:17 +05:30 committed by GitHub
commit da1ef81a2b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 28 deletions

View File

@ -1711,7 +1711,7 @@ class ResponseProcessor:
# "parsing_details": parsing_details # "parsing_details": parsing_details
# } # }
} }
} }
# STRUCTURED_OUTPUT_TOOLS = { # STRUCTURED_OUTPUT_TOOLS = {
# "str_replace", # "str_replace",

View File

@ -10,12 +10,10 @@ import Link from 'next/link';
import { useRouter } from 'next/navigation'; import { useRouter } from 'next/navigation';
import { useAuth } from '@/components/AuthProvider'; import { useAuth } from '@/components/AuthProvider';
import { import {
createProject,
createThread,
addUserMessage,
BillingError, BillingError,
} from '@/lib/api'; } 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 { 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,7 +57,9 @@ 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(); const initiateAgentMutation = useInitiateAgentMutation();
const [initiatedThreadId, setInitiatedThreadId] = useState<string | null>(null);
const threadQuery = useThreadQuery(initiatedThreadId || '');
// Auth dialog state // Auth dialog state
const [authDialogOpen, setAuthDialogOpen] = useState(false); const [authDialogOpen, setAuthDialogOpen] = useState(false);
@ -93,14 +93,12 @@ export function HeroSection() {
}; };
}, [scrollY]); }, [scrollY]);
// Store the input value when auth dialog opens
useEffect(() => { useEffect(() => {
if (authDialogOpen && inputValue.trim()) { if (authDialogOpen && inputValue.trim()) {
localStorage.setItem(PENDING_PROMPT_KEY, inputValue.trim()); localStorage.setItem(PENDING_PROMPT_KEY, inputValue.trim());
} }
}, [authDialogOpen, inputValue]); }, [authDialogOpen, inputValue]);
// Close dialog and redirect when user authenticates
useEffect(() => { useEffect(() => {
if (authDialogOpen && user && !isLoading) { if (authDialogOpen && user && !isLoading) {
setAuthDialogOpen(false); setAuthDialogOpen(false);
@ -108,38 +106,40 @@ export function HeroSection() {
} }
}, [user, isLoading, authDialogOpen, router]); }, [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 () => { const createAgentWithPrompt = async () => {
if (!inputValue.trim() || isSubmitting) return; if (!inputValue.trim() || isSubmitting) return;
setIsSubmitting(true); setIsSubmitting(true);
try { try {
// Generate a name for the project using GPT const formData = new FormData();
const projectName = await generateThreadName(inputValue); 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 result = await initiateAgentMutation.mutateAsync(formData);
const newAgent = await createProject({
name: projectName,
description: '',
});
const thread = await createThread(newAgent.id); setInitiatedThreadId(result.thread_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}`);
setInputValue(''); setInputValue('');
} catch (error: any) { } catch (error: any) {
console.error('Error creating agent:', error); console.error('Error creating agent:', error);
if (error instanceof BillingError) { if (error instanceof BillingError) {
console.log('Handling BillingError from hero section:', error.detail); console.log('Handling BillingError from hero section:', error.detail);
onOpen("paymentRequiredDialog");
} else { } else {
const isConnectionError = const isConnectionError =
error instanceof TypeError && error instanceof TypeError &&