wxgeorge commited on
Commit
056acd4
1 Parent(s): 995256c

:speaker: debug logging for translations.

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -95,7 +95,9 @@ def memoized_klimbr(message, percentage, extra, last=False):
95
 
96
  return klimbr_cache[key]
97
 
98
- def klimberize_conversation(message, history, percentage):
 
 
99
  # we memoize the klimbrization of strings.
100
  # this is to work with the gradio chat interface model
101
  # so that messages are not _re_-randomized at each conversation turn
@@ -107,6 +109,10 @@ def klimberize_conversation(message, history, percentage):
107
 
108
  klimbred_message = memoized_klimbr(message, percentage, len(history), last=True)
109
 
 
 
 
 
110
  return (klimbred_message, klimbred_history)
111
 
112
  def respond(message, history, model, klimbr_percentage):
 
95
 
96
  return klimbr_cache[key]
97
 
98
+ LOG_TRANSLATIONS=os.environ.get('LOG_TRANSLATIONS', True)
99
+
100
+ def klimberize_conversation(message, history, percentage, log=LOG_TRANSLATIONS):
101
  # we memoize the klimbrization of strings.
102
  # this is to work with the gradio chat interface model
103
  # so that messages are not _re_-randomized at each conversation turn
 
109
 
110
  klimbred_message = memoized_klimbr(message, percentage, len(history), last=True)
111
 
112
+ if log:
113
+ for original, kbed in zip([*[u for u,a in history], message], [*[u for u,a in klimbred_history], klimbred_message]):
114
+ print(f"Translated '{original}' as '{kbed}'")
115
+
116
  return (klimbred_message, klimbred_history)
117
 
118
  def respond(message, history, model, klimbr_percentage):