You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix low_level_api_chat_cpp example to match current API (#1086)
* Fix low_level_api_chat_cpp to match current API
* Fix low_level_api_chat_cpp to match current API
* Using None instead of empty string to so that default prompt template can be used if no prompt provided
---------
Co-authored-by: Anil Pathak <[email protected]>
# Using string instead of tokens to check for antiprompt,
548
+
# It is more reliable than tokens for interactive mode.
549
+
generated_str=""
535
550
whileself.params.interactive:
536
551
self.set_color(util.CONSOLE_COLOR_USER_INPUT)
537
552
if (self.params.instruct):
@@ -546,6 +561,10 @@ def interact(self):
546
561
try:
547
562
foriinself.output():
548
563
print(i,end="",flush=True)
564
+
generated_str+=i
565
+
forapinself.params.antiprompt:
566
+
ifgenerated_str.endswith(ap):
567
+
raiseKeyboardInterrupt
549
568
exceptKeyboardInterrupt:
550
569
self.set_color(util.CONSOLE_COLOR_DEFAULT)
551
570
ifnotself.params.instruct:
@@ -561,7 +580,7 @@ def interact(self):
561
580
time_now=datetime.now()
562
581
prompt=f"""Text transcript of a never ending dialog, where {USER_NAME} interacts with an AI assistant named {AI_NAME}.
563
582
{AI_NAME} is helpful, kind, honest, friendly, good at writing and never fails to answer {USER_NAME}’s requests immediately and with details and precision.
564
-
There are no annotations like (30 seconds passed...) or (to himself), just what {USER_NAME} and {AI_NAME} say aloud to each other.
583
+
Transcript below contains only the recorded dialog between two, without any annotations like (30 seconds passed...) or (to himself), just what {USER_NAME} and {AI_NAME} say aloud to each other.
565
584
The dialog lasts for years, the entirety of it is shared below. It's 10000 pages long.
566
585
The transcript only includes text, it does not include markup like HTML and Markdown.
567
586
@@ -575,8 +594,11 @@ def interact(self):
575
594
{AI_NAME}: A cat is a domestic species of small carnivorous mammal. It is the only domesticated species in the family Felidae.
0 commit comments