mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
refactored self.prompt
This commit is contained in:
parent
dcb6100ce9
commit
355e072de8
1 changed files with 24 additions and 17 deletions
41
aider/gui.py
41
aider/gui.py
|
@ -53,6 +53,11 @@ def get_coder():
|
||||||
|
|
||||||
|
|
||||||
class GUI:
|
class GUI:
|
||||||
|
prompt = None
|
||||||
|
last_undo_button = None
|
||||||
|
recent_msgs_empty = None
|
||||||
|
web_content_empty = None
|
||||||
|
|
||||||
def announce(self):
|
def announce(self):
|
||||||
lines = self.coder.get_announcements()
|
lines = self.coder.get_announcements()
|
||||||
lines = " \n".join(lines)
|
lines = " \n".join(lines)
|
||||||
|
@ -233,6 +238,8 @@ class GUI:
|
||||||
key=f"recent_msgs_{self.state.recent_msgs_num}",
|
key=f"recent_msgs_{self.state.recent_msgs_num}",
|
||||||
disabled=self.prompt_pending(),
|
disabled=self.prompt_pending(),
|
||||||
)
|
)
|
||||||
|
if self.old_prompt:
|
||||||
|
self.prompt = self.old_prompt
|
||||||
|
|
||||||
def do_messages_container(self):
|
def do_messages_container(self):
|
||||||
self.messages = st.container()
|
self.messages = st.container()
|
||||||
|
@ -252,6 +259,10 @@ class GUI:
|
||||||
self.show_edit_info(msg)
|
self.show_edit_info(msg)
|
||||||
elif role == "info":
|
elif role == "info":
|
||||||
st.info(msg["message"])
|
st.info(msg["message"])
|
||||||
|
# elif role == "text":
|
||||||
|
# text = msg["message"]
|
||||||
|
# with st.expander(text[0]):
|
||||||
|
# st.text(text)
|
||||||
elif role in ("user", "assistant"):
|
elif role in ("user", "assistant"):
|
||||||
with st.chat_message(role):
|
with st.chat_message(role):
|
||||||
st.write(msg["content"])
|
st.write(msg["content"])
|
||||||
|
@ -283,11 +294,6 @@ class GUI:
|
||||||
self.coder = coder
|
self.coder = coder
|
||||||
self.state = state
|
self.state = state
|
||||||
|
|
||||||
self.last_undo_button = None
|
|
||||||
|
|
||||||
self.recent_msgs_empty = None
|
|
||||||
self.web_content_empty = None
|
|
||||||
|
|
||||||
# Force the coder to cooperate, regardless of cmd line args
|
# Force the coder to cooperate, regardless of cmd line args
|
||||||
self.coder.yield_stream = True
|
self.coder.yield_stream = True
|
||||||
self.coder.stream = True
|
self.coder.stream = True
|
||||||
|
@ -300,26 +306,24 @@ class GUI:
|
||||||
self.do_sidebar()
|
self.do_sidebar()
|
||||||
self.do_cmd_tab()
|
self.do_cmd_tab()
|
||||||
|
|
||||||
prompt = st.chat_input("Say something")
|
user_inp = st.chat_input("Say something")
|
||||||
|
if user_inp:
|
||||||
|
self.prompt = user_inp
|
||||||
|
|
||||||
if self.prompt_pending():
|
if self.prompt_pending():
|
||||||
self.process_chat()
|
self.process_chat()
|
||||||
|
|
||||||
for prompt in [prompt, self.old_prompt, self.web_content]:
|
if not self.prompt:
|
||||||
if prompt:
|
|
||||||
break
|
|
||||||
|
|
||||||
if not prompt:
|
|
||||||
return
|
return
|
||||||
|
|
||||||
self.state.prompt = prompt
|
self.state.prompt = self.prompt
|
||||||
|
|
||||||
self.coder.io.add_to_input_history(prompt)
|
self.coder.io.add_to_input_history(self.prompt)
|
||||||
self.state.input_history.append(prompt)
|
self.state.input_history.append(self.prompt)
|
||||||
|
|
||||||
self.state.messages.append({"role": "user", "content": prompt})
|
self.state.messages.append({"role": "user", "content": self.prompt})
|
||||||
with self.messages.chat_message("user"):
|
with self.messages.chat_message("user"):
|
||||||
st.write(prompt)
|
st.write(self.prompt)
|
||||||
|
|
||||||
# re-render the UI for the prompt_pending state
|
# re-render the UI for the prompt_pending state
|
||||||
st.experimental_rerun()
|
st.experimental_rerun()
|
||||||
|
@ -404,11 +408,14 @@ class GUI:
|
||||||
content = self.scraper.scrape(url) or ""
|
content = self.scraper.scrape(url) or ""
|
||||||
if content.strip():
|
if content.strip():
|
||||||
content = f"{url}:\n\n" + content
|
content = f"{url}:\n\n" + content
|
||||||
self.web_content = content
|
self.prompt = content
|
||||||
else:
|
else:
|
||||||
self.info(f"No web content found for `{url}`.")
|
self.info(f"No web content found for `{url}`.")
|
||||||
self.web_content = None
|
self.web_content = None
|
||||||
|
|
||||||
|
# with self.messages.expander(content.splitlines()[0]):
|
||||||
|
# st.text(content)
|
||||||
|
|
||||||
|
|
||||||
def gui_main():
|
def gui_main():
|
||||||
coder = get_coder()
|
coder = get_coder()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue