Skip to content
This repository was archived by the owner on Mar 19, 2026. It is now read-only.

Commit 739b165

Browse files
authored
Merge pull request #406 from PrefectHQ/temp-none
Set temperature to None by default
2 parents ca4adb0 + 9fe8e1b commit 739b165

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-14
lines changed

src/controlflow/agents/agent.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Agent(ControlFlowModel, abc.ABC):
8383
default=False,
8484
description="If True, the agent is given tools for interacting with a human user.",
8585
)
86-
memories: list[Memory] | list[AsyncMemory] = Field(
86+
memories: list[Union[Memory, AsyncMemory]] = Field(
8787
default=[],
8888
description="A list of memory modules for the agent to use.",
8989
)
@@ -345,7 +345,7 @@ def _run_model(
345345

346346
create_markdown_artifact(
347347
markdown=f"""
348-
{response.content or '(No content)'}
348+
{response.content or "(No content)"}
349349
350350
#### Payload
351351
```json
@@ -409,7 +409,7 @@ async def _run_model_async(
409409

410410
create_markdown_artifact(
411411
markdown=f"""
412-
{response.content or '(No content)'}
412+
{response.content or "(No content)"}
413413
414414
#### Payload
415415
```json

src/controlflow/defaults.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ class Defaults(ControlFlowModel):
4040
model: Optional[Any]
4141
history: History
4242
agent: Agent
43-
memory_provider: (
44-
Optional[Union[MemoryProvider, str]] | Optional[Union[AsyncMemoryProvider, str]]
45-
)
43+
memory_provider: Optional[Union[MemoryProvider, AsyncMemoryProvider, str]]
4644

4745
# add more defaults here
4846
def __repr__(self) -> str:

src/controlflow/llm/models.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def get_model(
5252
"To use Google as an LLM provider, please install the `langchain_google_genai` package."
5353
)
5454
cls = ChatGoogleGenerativeAI
55+
if temperature is None:
56+
temperature = 0.7
5557
elif provider == "groq":
5658
try:
5759
from langchain_groq import ChatGroq
@@ -60,6 +62,8 @@ def get_model(
6062
"To use Groq as an LLM provider, please install the `langchain_groq` package."
6163
)
6264
cls = ChatGroq
65+
if temperature is None:
66+
temperature = 0.7
6367
elif provider == "ollama":
6468
try:
6569
from langchain_ollama import ChatOllama
@@ -73,7 +77,9 @@ def get_model(
7377
f"Could not load provider `{provider}` automatically. Please provide the LLM class manually."
7478
)
7579

76-
return cls(model=model, temperature=temperature, **kwargs)
80+
if temperature is not None:
81+
kwargs["temperature"] = temperature
82+
return cls(model=model, **kwargs)
7783

7884

7985
def _get_initial_default_model() -> BaseChatModel:

src/controlflow/orchestration/orchestrator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def get_tools(self) -> list[Tool]:
188188
tools = as_tools(tools)
189189
return tools
190190

191-
def get_memories(self) -> list[Memory] | list[AsyncMemory]:
191+
def get_memories(self) -> list[Union[Memory, AsyncMemory]]:
192192
memories = set()
193193

194194
memories.update(self.agent.memories)
@@ -525,7 +525,7 @@ def compile_prompt(self) -> str:
525525
]
526526

527527
prompt = "\n\n".join([p for p in prompts if p])
528-
logger.debug(f"{'='*10}\nCompiled prompt: {prompt}\n{'='*10}")
528+
logger.debug(f"{'=' * 10}\nCompiled prompt: {prompt}\n{'=' * 10}")
529529
return prompt
530530

531531
def compile_messages(self) -> list[BaseMessage]:

src/controlflow/orchestration/prompt_templates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, List, Optional
1+
from typing import Any, Dict, List, Optional, Union
22

33
from pydantic import model_validator
44

@@ -98,7 +98,7 @@ def should_render(self) -> bool:
9898

9999
class MemoryTemplate(Template):
100100
template_path: str = "memories.jinja"
101-
memories: list[Memory] | list[AsyncMemory]
101+
memories: list[Union[Memory, AsyncMemory]]
102102

103103
def should_render(self) -> bool:
104104
return bool(self.memories)

src/controlflow/settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ def _validate_pretty_print_agent_events(cls, data: dict) -> dict:
109109
default="openai/gpt-4o",
110110
description="The default LLM model for agents.",
111111
)
112-
llm_temperature: float = Field(0.7, description="The temperature for LLM sampling.")
112+
llm_temperature: Union[float, None] = Field(
113+
None, description="The temperature for LLM sampling."
114+
)
113115
max_input_tokens: int = Field(
114116
100_000, description="The maximum number of tokens to send to an LLM."
115117
)

src/controlflow/tasks/task.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __getitem__(self, item):
7575
return self.root[item]
7676

7777
def __repr__(self) -> str:
78-
return f'Labels: {", ".join(self.root)}'
78+
return f"Labels: {', '.join(self.root)}"
7979

8080

8181
class TaskStatus(Enum):
@@ -162,7 +162,7 @@ class Task(ControlFlowModel):
162162
description="Agents that are allowed to mark this task as complete. If None, all agents are allowed.",
163163
)
164164
interactive: bool = False
165-
memories: list[Memory] | list[AsyncMemory] = Field(
165+
memories: list[Union[Memory, AsyncMemory]] = Field(
166166
default=[],
167167
description="A list of memory modules for the task to use.",
168168
)

0 commit comments

Comments
 (0)