Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -13,26 +13,14 @@ def format_prompt(message, history):
|
|
13 |
return prompt
|
14 |
|
15 |
def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=9048, top_p=0.95, repetition_penalty=1.0):
|
16 |
-
|
17 |
-
top_p = float(top_p)
|
18 |
-
|
19 |
-
generate_kwargs = dict(
|
20 |
-
temperature=temperature,
|
21 |
-
max_new_tokens=max_new_tokens,
|
22 |
-
top_p=top_p,
|
23 |
-
repetition_penalty=repetition_penalty,
|
24 |
-
do_sample=True,
|
25 |
-
seed=42,
|
26 |
-
)
|
27 |
-
|
28 |
-
formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
|
29 |
-
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
30 |
-
output = ""
|
31 |
|
32 |
for response in stream:
|
33 |
output += response.token.text
|
34 |
-
|
35 |
-
|
|
|
|
|
36 |
|
37 |
additional_inputs = [
|
38 |
gr.Textbox(label="System Prompt", max_lines=1, interactive=True),
|
@@ -46,7 +34,7 @@ gr.ChatInterface(
|
|
46 |
fn=generate,
|
47 |
chatbot=gr.Chatbot(show_label=False, show_share_button=True, show_copy_button=True, likeable=True, layout="panel"),
|
48 |
additional_inputs=additional_inputs,
|
49 |
-
title="
|
50 |
concurrency_limit=20,
|
51 |
|
52 |
).launch(show_api=False,)
|
|
|
13 |
return prompt
|
14 |
|
15 |
def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=9048, top_p=0.95, repetition_penalty=1.0):
|
16 |
+
# ... existing code ...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
for response in stream:
|
19 |
output += response.token.text
|
20 |
+
if "http" in output: # assuming the AI writes a direct image link in its response
|
21 |
+
yield {"image": output} # Gradio will display the image
|
22 |
+
else:
|
23 |
+
yield output
|
24 |
|
25 |
additional_inputs = [
|
26 |
gr.Textbox(label="System Prompt", max_lines=1, interactive=True),
|
|
|
34 |
fn=generate,
|
35 |
chatbot=gr.Chatbot(show_label=False, show_share_button=True, show_copy_button=True, likeable=True, layout="panel"),
|
36 |
additional_inputs=additional_inputs,
|
37 |
+
title="ConvoLite",
|
38 |
concurrency_limit=20,
|
39 |
|
40 |
).launch(show_api=False,)
|