Skip to content

Commit 726ad30

Browse files
committed
Fix "'dict' object has no attribute 'temperature'" for log agent
1 parent 1878f53 commit 726ad30

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

lisa/ai/common.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,13 @@
33

44
import os
55

6-
from agent_framework import ChatOptions
7-
86
# Constants used in the code
97
VERBOSITY_LENGTH_THRESHOLD = 1000 # Max length for verbose log messages
108

11-
12-
def create_agent_chat_options() -> ChatOptions:
13-
"""
14-
Build default ChatOptions for MAF chat agents.
15-
- Low temperature for consistent analysis
16-
- Balanced top_p for nuanced interpretation
17-
- Large max_output_tokens for comprehensive responses
18-
"""
19-
return ChatOptions(temperature=0.1, top_p=0.6, max_tokens=8000)
9+
# Default chat model options used by AI agents.
10+
AGENT_TEMPERATURE = 0.1
11+
AGENT_TOP_P = 0.6
12+
AGENT_MAX_TOKENS = 8000
2013

2114

2215
def get_current_directory() -> str:

lisa/ai/default_flow.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
from agent_framework.azure import AzureOpenAIChatClient
1818

1919
from . import logger
20-
from .common import create_agent_chat_options, get_current_directory
20+
from .common import (
21+
AGENT_MAX_TOKENS,
22+
AGENT_TEMPERATURE,
23+
AGENT_TOP_P,
24+
get_current_directory,
25+
)
2126

2227
# Define agent name constants
2328
LOG_SEARCH_AGENT_NAME = "LogSearchAgent"
@@ -448,16 +453,15 @@ def __init__(
448453
plugin.read_text_file,
449454
plugin.list_files,
450455
]
451-
chat_options = create_agent_chat_options()
452456
super().__init__(
453457
chat_client=chat_client,
454458
name=name,
455459
description=description,
456460
instructions=instructions,
457461
tools=tools,
458-
temperature=chat_options.temperature,
459-
top_p=chat_options.top_p,
460-
additional_properties={"max_completion_tokens": chat_options.max_tokens},
462+
temperature=AGENT_TEMPERATURE,
463+
top_p=AGENT_TOP_P,
464+
additional_properties={"max_completion_tokens": AGENT_MAX_TOKENS},
461465
)
462466

463467
def _create_chat_client(
@@ -621,7 +625,6 @@ async def async_analyze_default(
621625

622626
# Create summary agent for final answer synthesis
623627
final_answer_prompt = _load_prompt("final_answer.txt", flow="default")
624-
chat_options = create_agent_chat_options()
625628
summary_chat_client = AzureOpenAIChatClient(
626629
api_key=azure_openai_api_key,
627630
endpoint=azure_openai_endpoint,
@@ -633,9 +636,9 @@ async def async_analyze_default(
633636
description="Summarizes and formats final answer.",
634637
instructions=final_answer_prompt,
635638
tools=[],
636-
temperature=chat_options.temperature,
637-
top_p=chat_options.top_p,
638-
additional_properties={"max_completion_tokens": chat_options.max_tokens},
639+
temperature=AGENT_TEMPERATURE,
640+
top_p=AGENT_TOP_P,
641+
additional_properties={"max_completion_tokens": AGENT_MAX_TOKENS},
639642
)
640643

641644
logger.info("Building Sequential workflow...")

0 commit comments

Comments
 (0)