Spaces:
Sleeping
Sleeping
fix 6
Browse files
app.py
CHANGED
@@ -26,6 +26,33 @@ output = query({
|
|
26 |
})
|
27 |
'''
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
def respond(
|
30 |
message,
|
31 |
history: list[tuple[str, str]],
|
@@ -63,7 +90,8 @@ def respond(
|
|
63 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
64 |
"""
|
65 |
demo = gr.ChatInterface(
|
66 |
-
respond,
|
|
|
67 |
additional_inputs=[
|
68 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
69 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
|
|
26 |
})
|
27 |
'''
|
28 |
|
29 |
+
def generate_text(
|
30 |
+
prompt,
|
31 |
+
system_message,
|
32 |
+
max_tokens,
|
33 |
+
temperature,
|
34 |
+
top_p,
|
35 |
+
):
|
36 |
+
try:
|
37 |
+
logger.info(f"Attempting to generate text for prompt: {prompt[:50]}...")
|
38 |
+
|
39 |
+
response = client.text_generation(
|
40 |
+
prompt,
|
41 |
+
max_new_tokens=max_tokens,
|
42 |
+
temperature=temperature,
|
43 |
+
top_k=50,
|
44 |
+
top_p=top_p,
|
45 |
+
do_sample=True
|
46 |
+
)
|
47 |
+
|
48 |
+
logger.info(f"Generated text: {response[:100]}...")
|
49 |
+
return response
|
50 |
+
except Exception as e:
|
51 |
+
logger.error(f"Error in generate_text: {type(e).__name__}: {str(e)}")
|
52 |
+
return f"An error occurred: {type(e).__name__}: {str(e)}"
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
def respond(
|
57 |
message,
|
58 |
history: list[tuple[str, str]],
|
|
|
90 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
91 |
"""
|
92 |
demo = gr.ChatInterface(
|
93 |
+
#respond,
|
94 |
+
generate_text,
|
95 |
additional_inputs=[
|
96 |
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
97 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|