Skip to content

Commit 7344860

Browse files
Fix: Agent Configuration and UI Improvements (#36)
* update configs to increase speed * fix keywords in utils * fix chat fragment warnings * increase max tokens for agents
1 parent 1b349eb commit 7344860

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

assistant/core/agents.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pydantic_ai import Agent
88
from pydantic_ai.common_tools.tavily import tavily_search_tool
99
from pydantic_ai.messages import ModelMessage, ModelResponse, ThinkingPart
10+
from pydantic_ai.settings import ModelSettings
1011

1112
from assistant.core.models import ModelFactory
1213
from assistant.core.schemas import Deps, ExperimentDefinition, OrchestrationResult, RouterOutput
@@ -71,6 +72,7 @@ def _create_experiment_creator_agent(self) -> Agent[Deps, ExperimentDefinition]:
7172
instructions=load_prompt("experiment_creator_instructions.md").render(),
7273
output_type=ExperimentDefinition,
7374
deps_type=Deps,
75+
model_settings=ModelSettings(max_tokens=10_000),
7476
tools=[
7577
retrieve_metrics_docs,
7678
],
@@ -89,6 +91,7 @@ def _create_internal_database_agent(self) -> Agent[Deps, str]:
8991
instructions=load_prompt("sql_expert_instructions.md").render(),
9092
output_type=str,
9193
deps_type=Deps,
94+
model_settings=ModelSettings(max_tokens=10_000),
9295
tools=[
9396
retrieve_internal_db,
9497
],
@@ -108,6 +111,7 @@ def _create_experiment_analyst_agent(self) -> Agent[Deps, str]:
108111
instructions=load_prompt("experiment_analyst_instructions.md").render(),
109112
output_type=str,
110113
deps_type=Deps,
114+
model_settings=ModelSettings(max_tokens=20_000),
111115
tools=[
112116
get_expanto_app_context,
113117
],
@@ -127,6 +131,7 @@ def _create_internet_search_agent(self) -> Agent[Deps, str]:
127131
instructions=load_prompt("internet_search_instructions.md").render(),
128132
output_type=str,
129133
deps_type=Deps,
134+
model_settings=ModelSettings(max_tokens=10_000),
130135
tools=[tavily_search_tool(self.tavily_api_key)],
131136
)
132137

@@ -139,6 +144,7 @@ def _create_expanto_assistant(self) -> Agent[Deps, str]:
139144
instructions="Use as many tool call as you needed",
140145
output_type=str,
141146
deps_type=Deps,
147+
model_settings=ModelSettings(max_tokens=10_000),
142148
tools=[
143149
retrieve_relevant_docs,
144150
retrieve_codebase_docs,
@@ -160,6 +166,7 @@ def _create_universal_agent(self) -> Agent[Deps, str]:
160166
"Use any tools if you need to answer user question or execute user task",
161167
output_type=str,
162168
deps_type=Deps,
169+
model_settings=ModelSettings(max_tokens=10_000),
163170
tools=[
164171
retrieve_metrics_docs,
165172
retrieve_relevant_docs,

demo_and_setup/configs/config.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ backgroundColor = "#F0F2F6"
2121
gatherUsageStats = false
2222

2323
[server]
24-
showEmailPrompt = false
24+
showEmailPrompt = false
25+
fileWatcherType = "none"
26+
runOnSave = false
27+
folderWatchList = ["src"]
28+
folderWatchBlacklist = [".git", ".venv", "venv", "node_modules",
29+
"__pycache__", ".pytest_cache", "data", "dist", "build"]

src/ui/chat/chat.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,24 @@ def render() -> None:
5959
is_stream_output=assistant_cfg.enable_streaming,
6060
)
6161
agent_placeholder = history_container.agent_placeholder
62+
if chat_state.future_result:
63+
agent_placeholder.show_status()
64+
6265
# TODO: feature - select mode for agent (auto, create, multipurpose)
6366
UserInputField.render(controller) # if user input: save to chat state and rerun
6467

6568
# Handle input and response logic
66-
run_every = 0.5 if chat_state.future_result else None
69+
run_every = 2 if chat_state.future_result else None
6770

6871
@st.fragment(run_every=run_every)
69-
def handle_future_response(placeholder):
72+
def handle_future_response():
7073
state = ChatStateManager.get_or_create_state()
7174
if not state.future_result:
7275
return
7376
if state.future_result.done():
7477
try:
7578
response = state.future_result.result() # get result
7679
state.future_result = None
77-
agent_placeholder.handle_response(response)
7880
ChatStateManager.update_state(response)
7981
except Exception as e:
8082
ChatStateManager.add_message(
@@ -83,10 +85,10 @@ def handle_future_response(placeholder):
8385
content=str(e),
8486
thinking=None,
8587
)
88+
chat_scroll()
8689
finally: # prevent eternal loop
8790
st.rerun()
8891
else:
89-
placeholder.show_status()
90-
chat_scroll()
92+
return
9193

92-
handle_future_response(agent_placeholder)
94+
handle_future_response()

src/ui/chat/elements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def handle_response(self, response: ChatResponse) -> None:
174174

175175
def show_status(self) -> None:
176176
"""Show thinking status message."""
177-
self.placeholder.status("Thinking... Please, don't change the page. It may take a while.")
177+
self.placeholder.status("Thinking... ", expanded=False)
178178

179179
def show_error(self, error_msg: str | None) -> None:
180180
"""Show error message.

src/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ def validate_sql_query(sql: str | None) -> None:
122122
"DO",
123123
"VACUUM",
124124
"ANALYZE",
125-
"SET",
126125
"RESET",
127126
"LOCK",
128127
"UNLOCK",

0 commit comments

Comments
 (0)