@@ -129,8 +129,6 @@ class Interpreter:
129
129
API key being used
130
130
api_version : str or None
131
131
API version being used
132
- max_budget : float
133
- Maximum budget in USD (-1 for unlimited)
134
132
max_turns : int
135
133
Maximum conversation turns (-1 for unlimited)
136
134
"""
@@ -207,6 +205,7 @@ async def async_respond(self):
207
205
model_info = litellm .get_model_info (self .model )
208
206
if self .provider == None :
209
207
self .provider = model_info ["litellm_provider" ]
208
+
210
209
max_tokens = model_info ["max_tokens" ]
211
210
212
211
system_message = self .system_message + "\n \n " + self .instructions
@@ -217,7 +216,15 @@ async def async_respond(self):
217
216
text = system_message ,
218
217
)
219
218
219
+ # Count turns
220
+ turn_count = 0
221
+
220
222
while True :
223
+ turn_count += 1
224
+ if turn_count > self .max_turns and self .max_turns != - 1 :
225
+ print ("\n Max turns reached, exiting\n " )
226
+ break
227
+
221
228
self ._spinner .start ()
222
229
223
230
enable_prompt_caching = False
@@ -469,10 +476,10 @@ async def async_respond(self):
469
476
}
470
477
)
471
478
if "editor" in self .tools :
472
- # print("Editor is not supported for non-Anthropic models. ")
479
+ print ("\n Editor is not supported for non-Anthropic models yet. \n " )
473
480
pass
474
481
if "gui" in self .tools :
475
- # print("GUI is not supported for non-Anthropic models. ")
482
+ print ("\n GUI is not supported for non-Anthropic models yet. \n " )
476
483
pass
477
484
478
485
if self .model .startswith ("ollama/" ):
@@ -629,7 +636,6 @@ def _handle_command(self, cmd: str, parts: list[str]) -> bool:
629
636
"api_key" : (str , "API key" ),
630
637
"api_version" : (str , "API version" ),
631
638
"temperature" : (float , "Sampling temperature (0-1)" ),
632
- "max_budget" : (float , "Maximum budget in USD (-1 for unlimited)" ),
633
639
"max_turns" : (int , "Maximum conversation turns (-1 for unlimited)" ),
634
640
}
635
641
@@ -799,29 +805,32 @@ def chat(self):
799
805
placeholder = HTML (
800
806
f"<{ placeholder_color } >{ placeholder_text } </{ placeholder_color } >"
801
807
)
802
- if self ._prompt_session is None :
803
- self ._prompt_session = PromptSession ()
804
- user_input = self ._prompt_session .prompt (
805
- "> " , placeholder = placeholder
806
- ).strip ()
807
- print ()
808
-
809
- # Handle multi-line input
810
- if user_input == '"""' :
811
- user_input = ""
812
- print ('> """' )
813
- while True :
814
- placeholder = HTML (
815
- f'<{ placeholder_color } >Use """ again to finish</{ placeholder_color } >'
816
- )
817
- line = self ._prompt_session .prompt (
818
- "" , placeholder = placeholder
819
- ).strip ()
820
- if line == '"""' :
821
- break
822
- user_input += line + "\n "
808
+ if self .input :
809
+ user_input = self .input
810
+ else :
811
+ if self ._prompt_session is None :
812
+ self ._prompt_session = PromptSession ()
813
+ user_input = self ._prompt_session .prompt (
814
+ "> " , placeholder = placeholder
815
+ ).strip ()
823
816
print ()
824
817
818
+ # Handle multi-line input
819
+ if user_input == '"""' :
820
+ user_input = ""
821
+ print ('> """' )
822
+ while True :
823
+ placeholder = HTML (
824
+ f'<{ placeholder_color } >Use """ again to finish</{ placeholder_color } >'
825
+ )
826
+ line = self ._prompt_session .prompt (
827
+ "" , placeholder = placeholder
828
+ ).strip ()
829
+ if line == '"""' :
830
+ break
831
+ user_input += line + "\n "
832
+ print ()
833
+
825
834
message_count += 1 # Increment counter after each message
826
835
827
836
if user_input .startswith ("/" ):
0 commit comments