Skip to content

Commit a63318c

Browse files
authored
Merge pull request #24 from BrunoV21/process-patch
refactored send_reasoning_msg into utils
2 parents 792ac24 + 56bae32 commit a63318c

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

codetide/agents/tide/ui/app.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
from aicore.config import Config
1010
from aicore.llm import Llm, LlmConfig
1111
from aicore.models import AuthenticationError, ModelError
12-
from aicore.const import STREAM_END_TOKEN, STREAM_START_TOKEN#, REASONING_START_TOKEN, REASONING_STOP_TOKEN
12+
from aicore.const import STREAM_END_TOKEN, STREAM_START_TOKEN#, REASONING_START_TOKEN, REASONING_STOP_TOKEN
13+
from codetide.agents.tide.ui.utils import process_thread, run_concurrent_tasks, send_reasoning_msg
1314
from codetide.agents.tide.ui.stream_processor import StreamProcessor, MarkerConfig
14-
from codetide.agents.tide.ui.utils import process_thread, run_concurrent_tasks
1515
from codetide.agents.tide.ui.defaults import AGENT_TIDE_PORT, STARTERS
1616
from codetide.agents.tide.ui.agent_tide_ui import AgentTideUi
1717
from chainlit.data.sql_alchemy import SQLAlchemyDataLayer
@@ -265,28 +265,6 @@ async def on_inspect_context(action :cl.Action):
265265

266266
await inspect_msg.send()
267267

268-
async def send_reasoning_msg(loading_msg :cl.message, context_msg :cl.Message, agent_tide_ui :AgentTideUi, st :float)->bool:
269-
await loading_msg.remove()
270-
271-
context_data = {
272-
key: value for key in ["contextIdentifiers", "modifyIdentifiers"]
273-
if (value := getattr(agent_tide_ui.agent_tide, key, None))
274-
}
275-
context_msg.elements.append(
276-
cl.CustomElement(
277-
name="ReasoningMessage",
278-
props={
279-
"reasoning": agent_tide_ui.agent_tide.reasoning,
280-
"data": context_data,
281-
"title": f"Thought for {time.time()-st:.2f} seconds",
282-
"defaultExpanded": False,
283-
"showControls": False
284-
}
285-
)
286-
)
287-
await context_msg.send()
288-
return True
289-
290268
@cl.on_message
291269
async def agent_loop(message: Optional[cl.Message]=None, codeIdentifiers: Optional[list] = None, agent_tide_ui :Optional[AgentTideUi]=None):
292270

@@ -510,3 +488,8 @@ def main():
510488
# TODO need to test project path is working as expected...
511489

512490
# TODO need to revisit logic
491+
# TODO there's a bug that is leaving step messages holding for some reason
492+
# TODO check initialzie codetide logic, seems to be deserialzied a bit too often
493+
# TODO review codetide check for updat4es - continously readding untracked files
494+
495+
# TODO check why HF-DEMO-SPACE Auth is being triggereds

codetide/agents/tide/ui/utils.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
from chainlit.types import ThreadDict
55
from aicore.logger import _logger
66
from aicore.llm import LlmConfig
7+
import chainlit as cl
78
import asyncio
89
import orjson
10+
import time
911

1012
def process_thread(thread :ThreadDict)->Tuple[List[dict], Optional[LlmConfig], str]:
1113
### type: tool
@@ -69,4 +71,26 @@ async def run_concurrent_tasks(agent_tide_ui: AgentTideUi, codeIdentifiers :Opti
6971
asyncio.create_task(_logger.distribute())
7072
while True:
7173
async for chunk in _logger.get_session_logs(agent_tide_ui.agent_tide.llm.session_id):
72-
yield chunk
74+
yield chunk
75+
76+
async def send_reasoning_msg(loading_msg :cl.message, context_msg :cl.Message, agent_tide_ui :AgentTideUi, st :float)->bool:
77+
await loading_msg.remove()
78+
79+
context_data = {
80+
key: value for key in ["contextIdentifiers", "modifyIdentifiers"]
81+
if (value := getattr(agent_tide_ui.agent_tide, key, None))
82+
}
83+
context_msg.elements.append(
84+
cl.CustomElement(
85+
name="ReasoningMessage",
86+
props={
87+
"reasoning": agent_tide_ui.agent_tide.reasoning,
88+
"data": context_data,
89+
"title": f"Thought for {time.time()-st:.2f} seconds",
90+
"defaultExpanded": False,
91+
"showControls": False
92+
}
93+
)
94+
)
95+
await context_msg.send()
96+
return True

examples/hf_demo_space/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77

88
from codetide.agents.tide.ui.defaults import AICORE_CONFIG_EXAMPLE, EXCEPTION_MESSAGE, MISSING_CONFIG_MESSAGE, STARTERS
99
from codetide.agents.tide.ui.stream_processor import StreamProcessor, MarkerConfig
10-
from codetide.agents.tide.ui.utils import run_concurrent_tasks
10+
from codetide.agents.tide.ui.utils import run_concurrent_tasks, send_reasoning_msg
1111
from codetide.agents.tide.ui.agent_tide_ui import AgentTideUi
12-
from codetide.agents.tide.ui.app import send_reasoning_msg
1312
from codetide.core.defaults import DEFAULT_ENCODING
1413
from codetide.core.logs import logger
1514
from codetide.agents.tide.models import Step

0 commit comments

Comments
 (0)