Spaces:
Sleeping
Sleeping
NCTCMumbai
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -101,12 +101,14 @@ def bot(history, api_kind):
|
|
101 |
gr.Warning(f"API {api_kind} is not supported")
|
102 |
raise ValueError(f"API {api_kind} is not supported")
|
103 |
try:
|
104 |
-
|
|
|
105 |
history[-1][1] = ""
|
106 |
for character in generate_fn(prompt, history[:-1]):
|
107 |
history[-1][1] = character
|
108 |
yield history, prompt_html
|
109 |
except Exception as e: # Catch any exception
|
|
|
110 |
yield f"An unexpected error occurred during generation: {str(e)}"
|
111 |
|
112 |
with gr.Blocks() as demo:
|
|
|
101 |
gr.Warning(f"API {api_kind} is not supported")
|
102 |
raise ValueError(f"API {api_kind} is not supported")
|
103 |
try:
|
104 |
+
count_tokens = lambda text: len([token.strip() for token in text.split() if token.strip()])
|
105 |
+
print(prompt_html,'token count is',count_tokens)
|
106 |
history[-1][1] = ""
|
107 |
for character in generate_fn(prompt, history[:-1]):
|
108 |
history[-1][1] = character
|
109 |
yield history, prompt_html
|
110 |
except Exception as e: # Catch any exception
|
111 |
+
print('An unexpected error occurred during generation:', str(e))
|
112 |
yield f"An unexpected error occurred during generation: {str(e)}"
|
113 |
|
114 |
with gr.Blocks() as demo:
|