diff --git a/windows_use/agent/service.py b/windows_use/agent/service.py index e1f045b..1e58234 100644 --- a/windows_use/agent/service.py +++ b/windows_use/agent/service.py @@ -232,7 +232,9 @@ def loop(self) -> AgentResult: name=llm_event.tool_call.name, params=llm_event.tool_call.params, thinking=llm_event.thinking.content if llm_event.thinking else None, - thinking_signature=llm_event.thinking.signature if llm_event.thinking else None, + thinking_signature=llm_event.thinking.signature + if llm_event.thinking + else None, ) break case LLMEventType.TEXT: @@ -486,7 +488,9 @@ async def aloop(self) -> AgentResult: name=llm_event.tool_call.name, params=llm_event.tool_call.params, thinking=llm_event.thinking.content if llm_event.thinking else None, - thinking_signature=llm_event.thinking.signature if llm_event.thinking else None, + thinking_signature=llm_event.thinking.signature + if llm_event.thinking + else None, ) break case LLMEventType.TEXT: diff --git a/windows_use/providers/azure_openai/llm.py b/windows_use/providers/azure_openai/llm.py index 07acc38..f3323e2 100644 --- a/windows_use/providers/azure_openai/llm.py +++ b/windows_use/providers/azure_openai/llm.py @@ -128,7 +128,11 @@ def _convert_messages(self, messages: list[BaseMessage]) -> list[dict]: "type": "function", "function": {"name": msg.name, "arguments": json.dumps(msg.params)}, } - assistant_msg: dict = {"role": "assistant", "content": None, "tool_calls": [tool_call]} + assistant_msg: dict = { + "role": "assistant", + "content": None, + "tool_calls": [tool_call], + } if getattr(msg, "thinking", None): assistant_msg["reasoning_content"] = msg.thinking openai_messages.append(assistant_msg) diff --git a/windows_use/providers/cerebras/llm.py b/windows_use/providers/cerebras/llm.py index d1e5875..a917db7 100644 --- a/windows_use/providers/cerebras/llm.py +++ b/windows_use/providers/cerebras/llm.py @@ -138,7 +138,9 @@ def _convert_messages(self, messages: list[BaseMessage]) -> list[dict]: cerebras_messages.append( { "role": "assistant", - "content": self._format_assistant_content(None, thinking) if thinking else None, + "content": self._format_assistant_content(None, thinking) + if thinking + else None, "tool_calls": [tool_call], } ) diff --git a/windows_use/providers/deepseek/llm.py b/windows_use/providers/deepseek/llm.py index 09fe91b..1f6657b 100644 --- a/windows_use/providers/deepseek/llm.py +++ b/windows_use/providers/deepseek/llm.py @@ -24,7 +24,7 @@ def __init__( timeout: float = 600.0, max_retries: int = 2, temperature: float | None = None, - reasoning_effort: Literal['none','low','medium','high','xhigh','max'] = "high", + reasoning_effort: Literal["none", "low", "medium", "high", "xhigh", "max"] = "high", thinking: bool = False, **kwargs, ): diff --git a/windows_use/providers/google/llm.py b/windows_use/providers/google/llm.py index 7241bab..fb7927c 100644 --- a/windows_use/providers/google/llm.py +++ b/windows_use/providers/google/llm.py @@ -3,7 +3,7 @@ import os import uuid from collections.abc import AsyncIterator, Iterator -from typing import Any, overload, Literal +from typing import Any, Literal, overload from google import genai from google.genai import types diff --git a/windows_use/providers/groq/llm.py b/windows_use/providers/groq/llm.py index 326d3d2..20346cf 100644 --- a/windows_use/providers/groq/llm.py +++ b/windows_use/providers/groq/llm.py @@ -130,7 +130,11 @@ def _convert_messages(self, messages: list[BaseMessage]) -> list[dict]: "type": "function", "function": {"name": msg.name, "arguments": json.dumps(msg.params)}, } - assistant_msg: dict = {"role": "assistant", "content": None, "tool_calls": [tool_call]} + assistant_msg: dict = { + "role": "assistant", + "content": None, + "tool_calls": [tool_call], + } if getattr(msg, "thinking", None): assistant_msg["reasoning"] = msg.thinking groq_messages.append(assistant_msg) diff --git a/windows_use/providers/ollama/llm.py b/windows_use/providers/ollama/llm.py index aff0df6..1749dda 100644 --- a/windows_use/providers/ollama/llm.py +++ b/windows_use/providers/ollama/llm.py @@ -323,7 +323,11 @@ def stream( message = chunk.get("message", {}) # Ollama may send usage in the final chunk if "eval_count" in chunk or "prompt_eval_count" in chunk: - thinking_tokens = max(1, sum(len(t) for t in accumulated_thinking) // 4) if accumulated_thinking else None + thinking_tokens = ( + max(1, sum(len(t) for t in accumulated_thinking) // 4) + if accumulated_thinking + else None + ) usage = TokenUsage( prompt_tokens=chunk.get("prompt_eval_count", 0), completion_tokens=chunk.get("eval_count", 0), @@ -362,7 +366,9 @@ def stream( yield LLMStreamEvent(type=LLMStreamEventType.THINK_END) think_started = False thinking_content = "".join(accumulated_thinking) or None - thinking_obj = Thinking(content=thinking_content, signature=None) if thinking_content else None + thinking_obj = ( + Thinking(content=thinking_content, signature=None) if thinking_content else None + ) yield LLMStreamEvent( type=LLMStreamEventType.TOOL_CALL, tool_call=ToolCall( @@ -422,7 +428,11 @@ async def astream( message = chunk.get("message", {}) # Ollama may send usage in the final chunk if "eval_count" in chunk or "prompt_eval_count" in chunk: - thinking_tokens = max(1, sum(len(t) for t in accumulated_thinking) // 4) if accumulated_thinking else None + thinking_tokens = ( + max(1, sum(len(t) for t in accumulated_thinking) // 4) + if accumulated_thinking + else None + ) usage = TokenUsage( prompt_tokens=chunk.get("prompt_eval_count", 0), completion_tokens=chunk.get("eval_count", 0), @@ -461,7 +471,9 @@ async def astream( yield LLMStreamEvent(type=LLMStreamEventType.THINK_END) think_started = False thinking_content = "".join(accumulated_thinking) or None - thinking_obj = Thinking(content=thinking_content, signature=None) if thinking_content else None + thinking_obj = ( + Thinking(content=thinking_content, signature=None) if thinking_content else None + ) yield LLMStreamEvent( type=LLMStreamEventType.TOOL_CALL, tool_call=ToolCall( diff --git a/windows_use/providers/openai/llm.py b/windows_use/providers/openai/llm.py index 85f902f..6782ee2 100644 --- a/windows_use/providers/openai/llm.py +++ b/windows_use/providers/openai/llm.py @@ -50,7 +50,7 @@ def __init__( base_url: str | None = None, timeout: float = 600.0, max_retries: int = 2, - reasoning_effort: Literal['none','low','medium','high','xhigh'] = "high", + reasoning_effort: Literal["none", "low", "medium", "high", "xhigh"] = "high", temperature: float | None = None, extra_body: dict | None = None, **kwargs, @@ -140,7 +140,11 @@ def _convert_messages(self, messages: list[BaseMessage]) -> list[dict]: "type": "function", "function": {"name": msg.name, "arguments": json.dumps(msg.params)}, } - assistant_msg: dict = {"role": "assistant", "content": None, "tool_calls": [tool_call]} + assistant_msg: dict = { + "role": "assistant", + "content": None, + "tool_calls": [tool_call], + } if getattr(msg, "thinking", None): assistant_msg["reasoning_content"] = msg.thinking openai_messages.append(assistant_msg) @@ -267,10 +271,10 @@ def invoke( if json_mode: params["response_format"] = {"type": "json_object"} - + if self.extra_body: params["extra_body"] = self.extra_body - + if self._is_reasoning_model(): params["reasoning_effort"] = self.reasoning_effort