An AI Agent that interacts with Windows OS at GUI level.
Python
Fix missing self.extra_body in ChatOpenAI and add thinking param to ChatVLLM
jeomond9ab7d7af543
diff --git a/windows_use/providers/deepseek/llm.py b/windows_use/providers/deepseek/llm.pyindex df26f7e..09fe91b 100644--- a/windows_use/providers/deepseek/llm.py+++ b/windows_use/providers/deepseek/llm.py@@ -1,6 +1,7 @@"""DeepSeek LLM provider via OpenAI-compatible API."""import os+from typing import Literalfrom windows_use.providers.openai.llm import ChatOpenAI@@ -23,17 +24,22 @@ class ChatDeepSeek(ChatOpenAI):timeout: float = 600.0,max_retries: int = 2,temperature: float | None = None,+ reasoning_effort: Literal['none','low','medium','high','xhigh','max'] = "high",+ thinking: bool = False,**kwargs,):api_key = api_key or os.environ.get("DEEPSEEK_API_KEY")base_url = base_url or os.environ.get("DEEPSEEK_API_BASE") or DEEPSEEK_BASE_URL+ extra_body = {"thinking": {"type": "enabled" if thinking else "disabled"}}super().__init__(model=model,api_key=api_key,base_url=base_url,timeout=timeout,+ reasoning_effort=reasoning_effort,max_retries=max_retries,temperature=temperature,+ extra_body=extra_body,**kwargs,)diff --git a/windows_use/providers/google/llm.py b/windows_use/providers/google/llm.pyindex fc0863d..7241bab 100644--- a/windows_use/providers/google/llm.py+++ b/windows_use/providers/google/llm.py@@ -3,7 +3,7 @@ import loggingimport osimport uuidfrom collections.abc import AsyncIterator, Iterator-from typing import Any, overload+from typing import Any, overload, Literalfrom google import genaifrom google.genai import types@@ -52,7 +52,7 @@ class ChatGoogle(BaseChatLLM):base_url: str | None = None,temperature: float | None = None,thinking_budget: int | None = None,- thinking_level: str | None = None,+ thinking_level: Literal["minimal", "low", "medium", "high"] | None = None,**kwargs,):"""diff --git a/windows_use/providers/nvidia/llm.py b/windows_use/providers/nvidia/llm.pyindex d24a3d0..410cabb 100644--- a/windows_use/providers/nvidia/llm.py+++ b/windows_use/providers/nvidia/llm.py@@ -21,6 +21,7 @@ class ChatNvidia(ChatOpenAI):api_key: str | None = None,base_url: str | None = None,timeout: float = 600.0,+ thinking: bool = False,max_retries: int = 2,temperature: float | None = None,**kwargs,@@ -29,6 +30,7 @@ class ChatNvidia(ChatOpenAI):api_key or os.environ.get("NVIDIA_NIM_API_KEY") or os.environ.get("NVIDIA_API_KEY"))base_url = base_url or os.environ.get("NVIDIA_NIM_API_BASE") or NVIDIA_NIM_BASE_URL+ extra_body = {"chat_template_kwargs": {"thinking": thinking}}super().__init__(model=model,api_key=api_key,@@ -36,6 +38,7 @@ class ChatNvidia(ChatOpenAI):timeout=timeout,max_retries=max_retries,temperature=temperature,+ extra_body=extra_body,**kwargs,)diff --git a/windows_use/providers/openai/llm.py b/windows_use/providers/openai/llm.pyindex ec749f3..68aa146 100644--- a/windows_use/providers/openai/llm.py+++ b/windows_use/providers/openai/llm.py@@ -2,7 +2,7 @@ import jsonimport loggingimport osfrom collections.abc import AsyncIterator, Iterator-from typing import Any, overload+from typing import Any, Literal, overloadfrom openai import AsyncOpenAI, OpenAIfrom pydantic import BaseModel@@ -50,7 +50,9 @@ class ChatOpenAI(BaseChatLLM):base_url: str | None = None,timeout: float = 600.0,max_retries: int = 2,+ reasoning_effort: Literal['none','low','medium','high','xhigh'] = "high",temperature: float | None = None,+ extra_body: dict | None = None,**kwargs,):"""@@ -69,6 +71,7 @@ class ChatOpenAI(BaseChatLLM):self.api_key = api_key or os.environ.get("OPENAI_API_KEY")self.base_url = base_url or os.environ.get("OPENAI_BASE_URL")self.temperature = temperature+ self.extra_body = extra_bodyself.client = OpenAI(api_key=self.api_key,@@ -263,6 +266,12 @@ class ChatOpenAI(BaseChatLLM):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_effortresponse = self.client.chat.completions.create(**params)return self._process_response(response)@@ -326,6 +335,12 @@ class ChatOpenAI(BaseChatLLM):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+response = await self.aclient.chat.completions.create(**params)return self._process_response(response)@@ -365,7 +380,13 @@ class ChatOpenAI(BaseChatLLM):if json_mode:params["response_format"] = {"type": "json_object"}- response = self.client.chat.completions.create(**params)+ if self.extra_body:+ params["extra_body"] = self.extra_body++ if self._is_reasoning_model():+ params["reasoning_effort"] = self.reasoning_effort++ response = self.client.chat.completions.create(**params, **self.kwargs)# Accumulators for streamed tool callstool_call_id = None@@ -483,6 +504,12 @@ class ChatOpenAI(BaseChatLLM):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+response = await self.aclient.chat.completions.create(**params)# Accumulators for streamed tool callsdiff --git a/windows_use/providers/vllm/llm.py b/windows_use/providers/vllm/llm.pyindex 28c4680..04deec5 100644--- a/windows_use/providers/vllm/llm.py+++ b/windows_use/providers/vllm/llm.py@@ -56,6 +56,7 @@ class ChatVLLM(BaseChatLLM):timeout: float = 600.0,max_retries: int = 2,temperature: float | None = None,+ thinking: bool = False,**kwargs,):"""@@ -70,12 +71,14 @@ class ChatVLLM(BaseChatLLM):timeout: Request timeout in seconds.max_retries: Maximum number of retries for failed requests.temperature: Sampling temperature.+ thinking: Enable thinking/reasoning via chat template kwargs.**kwargs: Additional arguments passed to the chat completions create method."""self._model = modelself.api_key = api_key or os.environ.get("VLLM_API_KEY", "EMPTY")self.base_url = base_url or os.environ.get("VLLM_BASE_URL", "http://localhost:8000/v1")self.temperature = temperature+ self.thinking = thinkingself.client = OpenAI(api_key=self.api_key,@@ -252,6 +255,7 @@ class ChatVLLM(BaseChatLLM):},}params.pop("tools", None)+ params["extra_body"] = {"chat_template_kwargs": {"enable_thinking": self.thinking}}response = self.client.chat.completions.create(**params)usage_data = response.usage@@ -292,6 +296,8 @@ class ChatVLLM(BaseChatLLM):if json_mode:params["response_format"] = {"type": "json_object"}+ params["extra_body"] = {"chat_template_kwargs": {"enable_thinking": self.thinking}}+response = self.client.chat.completions.create(**params)return self._process_response(response)@@ -335,6 +341,7 @@ class ChatVLLM(BaseChatLLM):},}params.pop("tools", None)+ params["extra_body"] = {"chat_template_kwargs": {"enable_thinking": self.thinking}}response = await self.aclient.chat.completions.create(**params)usage_data = response.usage@@ -375,6 +382,8 @@ class ChatVLLM(BaseChatLLM):if json_mode:params["response_format"] = {"type": "json_object"}+ params["extra_body"] = {"chat_template_kwargs": {"enable_thinking": self.thinking}}+response = await self.aclient.chat.completions.create(**params)return self._process_response(response)@@ -414,6 +423,8 @@ class ChatVLLM(BaseChatLLM):if json_mode:params["response_format"] = {"type": "json_object"}+ params["extra_body"] = {"chat_template_kwargs": {"enable_thinking": self.thinking}}+response = self.client.chat.completions.create(**params)tool_call_id = None@@ -527,6 +538,8 @@ class ChatVLLM(BaseChatLLM):if json_mode:params["response_format"] = {"type": "json_object"}+ params["extra_body"] = {"chat_template_kwargs": {"enable_thinking": self.thinking}}+response = await self.aclient.chat.completions.create(**params)tool_call_id = None