From f0c3c52cf48d8124037926b12be9250c421c9bf0 Mon Sep 17 00:00:00 2001 From: Adam Cohen Hillel Date: Tue, 15 Apr 2025 19:07:31 +0100 Subject: [PATCH] exra --- backend/agent/run.py | 2 +- backend/services/llm.py | 11 ++-- backend/utils/billing.py | 6 +- .../src/components/billing/PlanComparison.tsx | 4 +- .../src/components/chat/tool-components.tsx | 66 ++++++++++++++++++- frontend/src/lib/types/tool-calls.ts | 3 +- 6 files changed, 79 insertions(+), 13 deletions(-) diff --git a/backend/agent/run.py b/backend/agent/run.py index 4f997278..7b3f7414 100644 --- a/backend/agent/run.py +++ b/backend/agent/run.py @@ -153,7 +153,7 @@ async def run_agent(thread_id: str, project_id: str, stream: bool = True, thread stream=stream, llm_model=model_name, llm_temperature=0, - llm_max_tokens=64000, + llm_max_tokens=128000, tool_choice="auto", max_xml_tool_calls=1, temporary_message=temporary_message, diff --git a/backend/services/llm.py b/backend/services/llm.py index 76c42e9a..162418b5 100644 --- a/backend/services/llm.py +++ b/backend/services/llm.py @@ -121,11 +121,12 @@ def prepare_params( logger.debug(f"Added {len(tools)} tools to API parameters") # # Add Claude-specific headers - # if "claude" in model_name.lower() or "anthropic" in model_name.lower(): - # params["extra_headers"] = { - # "anthropic-beta": "max-tokens-3-5-sonnet-2024-07-15" - # } - # logger.debug("Added Claude-specific headers") + if "claude" in model_name.lower() or "anthropic" in model_name.lower(): + params["extra_headers"] = { + # "anthropic-beta": "max-tokens-3-5-sonnet-2024-07-15" + "anthropic-beta": "output-128k-2025-02-19" + } + logger.debug("Added Claude-specific headers") # Add OpenRouter-specific parameters if model_name.startswith("openrouter/"): diff --git a/backend/utils/billing.py b/backend/utils/billing.py index ce8699c3..b3a84ec8 100644 --- a/backend/utils/billing.py +++ b/backend/utils/billing.py @@ -4,9 +4,9 @@ from services.supabase import DBConnection # Define subscription tiers and their monthly hour limits SUBSCRIPTION_TIERS = { - 'price_1RDQbOG6l1KZGqIrgrYzMbnL': {'name': 'free', 'hours': 1}, - 'price_1RC2PYG6l1KZGqIrpbzFB9Lp': {'name': 'base', 'hours': 1}, - 'price_1RDQWqG6l1KZGqIrChli4Ys4': {'name': 'extra', 'hours': 1} + 'price_1RDQbOG6l1KZGqIrgrYzMbnL': {'name': 'free', 'hours': 100}, + 'price_1RC2PYG6l1KZGqIrpbzFB9Lp': {'name': 'base', 'hours': 100}, + 'price_1RDQWqG6l1KZGqIrChli4Ys4': {'name': 'extra', 'hours': 100} } async def get_account_subscription(client, account_id: str) -> Optional[Dict]: diff --git a/frontend/src/components/billing/PlanComparison.tsx b/frontend/src/components/billing/PlanComparison.tsx index 7adc8b7a..50785ef8 100644 --- a/frontend/src/components/billing/PlanComparison.tsx +++ b/frontend/src/components/billing/PlanComparison.tsx @@ -16,12 +16,12 @@ export const SUBSCRIPTION_PLANS = { const PLAN_DETAILS = { [SUBSCRIPTION_PLANS.FREE]: { name: 'Free', - limit: 1, + limit: 100, price: 0 }, [SUBSCRIPTION_PLANS.BASIC]: { name: 'Basic', - limit: 10, + limit: 100, price: 10 }, [SUBSCRIPTION_PLANS.PRO]: { diff --git a/frontend/src/components/chat/tool-components.tsx b/frontend/src/components/chat/tool-components.tsx index cc5bc28c..edad0acf 100644 --- a/frontend/src/components/chat/tool-components.tsx +++ b/frontend/src/components/chat/tool-components.tsx @@ -4,7 +4,7 @@ import React from 'react'; import { ParsedTag, ToolComponentProps } from '@/lib/types/tool-calls'; import { File, FileText, Terminal, FolderPlus, Folder, Code, Search as SearchIcon, - Bell, Replace, Plus, Minus, Globe + Bell, Replace, Plus, Minus, Globe, Search } from 'lucide-react'; import { cn } from '@/lib/utils'; import { diffLines } from 'diff'; @@ -521,6 +521,65 @@ export const BrowserNavigateTool: React.FC = ({ tag, mode }) ); }; +/** + * Web Search Tool Component + */ +export const WebSearchTool: React.FC = ({ tag, mode }) => { + const query = tag.attributes.query || ''; + const isRunning = tag.status === 'running'; + + if (mode === 'compact') { + return ( + } + name={isRunning ? "Web search in progress..." : "Web search complete"} + input={query} + isRunning={isRunning} + /> + ); + } + + const results = tag.result?.output ? JSON.parse(tag.result.output) : []; + + return ( +
+
+ +
Web Search: {query}
+ {isRunning && ( +
+ Searching +
+
+ )} +
+
+ {results.length > 0 ? ( +
+ {results.map((result: any, index: number) => ( +
+ + {result.Title} + +
+ {result.URL} + {result['Published Date'] && ( + + ({new Date(result['Published Date']).toLocaleDateString()}) + + )} +
+
+ ))} +
+ ) : ( +
No results found
+ )} +
+
+ ); +}; + // Tool component registry export const ToolComponentRegistry: Record> = { 'create-file': CreateFileTool, @@ -547,10 +606,15 @@ export const ToolComponentRegistry: Record> 'browser-get-dropdown-options': BrowserNavigateTool, 'browser-select-dropdown-option': BrowserNavigateTool, 'browser-drag-drop': BrowserNavigateTool, + 'web-search': WebSearchTool, }; // Helper function to get the appropriate component for a tag export function getComponentForTag(tag: ParsedTag): React.FC { + console.log("getComponentForTag", tag); + if (!tag || !tag?.tagName) { + console.warn(`No tag name for tag: ${tag}`); + } if (!ToolComponentRegistry[tag.tagName]) { console.warn(`No component registered for tag type: ${tag.tagName}`); } diff --git a/frontend/src/lib/types/tool-calls.ts b/frontend/src/lib/types/tool-calls.ts index 1ecd921d..352ca31b 100644 --- a/frontend/src/lib/types/tool-calls.ts +++ b/frontend/src/lib/types/tool-calls.ts @@ -53,7 +53,8 @@ export const SUPPORTED_XML_TAGS = [ 'browser-close-tab', 'browser-get-dropdown-options', 'browser-select-dropdown-option', - 'browser-drag-drop' + 'browser-drag-drop', + 'web-search' ]; // Tool status labels