MCPcopy
hub / github.com/Aider-AI/aider / send

Method send

aider/coders/base_coder.py:1783–1834  ·  view source on GitHub ↗
(self, messages, model=None, functions=None)

Source from the content-addressed store, hash-verified

1781 return prompts.added_files.format(fnames=", ".join(added_fnames))
1782
1783 def send(self, messages, model=None, functions=None):
1784 self.got_reasoning_content = False
1785 self.ended_reasoning_content = False
1786
1787 if not model:
1788 model = self.main_model
1789
1790 self.partial_response_content = ""
1791 self.partial_response_function_call = dict()
1792
1793 self.io.log_llm_history("TO LLM", format_messages(messages))
1794
1795 completion = None
1796 try:
1797 hash_object, completion = model.send_completion(
1798 messages,
1799 functions,
1800 self.stream,
1801 self.temperature,
1802 )
1803 self.chat_completion_call_hashes.append(hash_object.hexdigest())
1804
1805 if self.stream:
1806 yield from self.show_send_output_stream(completion)
1807 else:
1808 self.show_send_output(completion)
1809
1810 # Calculate costs for successful responses
1811 self.calculate_and_show_tokens_and_cost(messages, completion)
1812
1813 except LiteLLMExceptions().exceptions_tuple() as err:
1814 ex_info = LiteLLMExceptions().get_ex_info(err)
1815 if ex_info.name == "ContextWindowExceededError":
1816 # Still calculate costs for context window errors
1817 self.calculate_and_show_tokens_and_cost(messages, completion)
1818 raise
1819 except KeyboardInterrupt as kbi:
1820 self.keyboard_interrupt()
1821 raise kbi
1822 finally:
1823 self.io.log_llm_history(
1824 "LLM RESPONSE",
1825 format_content("ASSISTANT", self.partial_response_content),
1826 )
1827
1828 if self.partial_response_content:
1829 self.io.ai_output(self.partial_response_content)
1830 elif self.partial_response_function_call:
1831 # TODO: push this into subclasses
1832 args = self.parse_partial_args()
1833 if args:
1834 self.io.ai_output(json.dumps(args, indent=4))
1835
1836 def show_send_output(self, completion):
1837 # Stop spinner once we have a response

Calls 13

show_send_outputMethod · 0.95
keyboard_interruptMethod · 0.95
parse_partial_argsMethod · 0.95
format_messagesFunction · 0.90
LiteLLMExceptionsClass · 0.90
format_contentFunction · 0.90
log_llm_historyMethod · 0.80
send_completionMethod · 0.80
exceptions_tupleMethod · 0.80
get_ex_infoMethod · 0.80