Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions windows_use/agent/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion windows_use/providers/azure_openai/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion windows_use/providers/cerebras/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
}
)
Expand Down
2 changes: 1 addition & 1 deletion windows_use/providers/deepseek/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
):
Expand Down
2 changes: 1 addition & 1 deletion windows_use/providers/google/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion windows_use/providers/groq/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 16 additions & 4 deletions windows_use/providers/ollama/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand Down
12 changes: 8 additions & 4 deletions windows_use/providers/openai/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down