Spaces:
Runtime error
Runtime error
:speaker: debug logging for translations.
Browse files
app.py
CHANGED
@@ -95,7 +95,9 @@ def memoized_klimbr(message, percentage, extra, last=False):
|
|
95 |
|
96 |
return klimbr_cache[key]
|
97 |
|
98 |
-
|
|
|
|
|
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):
|