Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -626,14 +626,8 @@ class XylariaChat:
|
|
626 |
|
627 |
if isinstance(image_bytes, bytes):
|
628 |
base64_image = base64.b64encode(image_bytes).decode("utf-8")
|
629 |
-
|
630 |
-
|
631 |
-
image_html = f"""
|
632 |
-
<details>
|
633 |
-
<summary>Generated Image</summary>
|
634 |
-
<img src="data:image/png;base64,{base64_image}" alt="Generated Image" style="max-width: 100%; max-height: 400px;">
|
635 |
-
</details>
|
636 |
-
"""
|
637 |
# Append the /image command and generated image to chat history
|
638 |
chat_history.append([message, ""])
|
639 |
chat_history.append(["", image_html])
|
@@ -682,25 +676,7 @@ class XylariaChat:
|
|
682 |
chunk_content = chunk.choices[0].delta.content
|
683 |
full_response += chunk_content
|
684 |
|
685 |
-
|
686 |
-
if "```" in full_response:
|
687 |
-
parts = full_response.split("```")
|
688 |
-
formatted_response = ""
|
689 |
-
for i, part in enumerate(parts):
|
690 |
-
if i % 2 == 0:
|
691 |
-
formatted_response += part
|
692 |
-
else:
|
693 |
-
|
694 |
-
formatted_response += f"""
|
695 |
-
<details>
|
696 |
-
<summary>Code Output</summary>
|
697 |
-
```{part}```
|
698 |
-
</details>
|
699 |
-
"""
|
700 |
-
updated_history[-1][1] = formatted_response
|
701 |
-
else:
|
702 |
-
updated_history[-1][1] = full_response
|
703 |
-
|
704 |
yield "", updated_history, None, None, None
|
705 |
except Exception as e:
|
706 |
print(f"Streaming error: {e}")
|
@@ -867,22 +843,6 @@ class XylariaChat:
|
|
867 |
#main-content {
|
868 |
flex: 1;
|
869 |
transition: flex 0.3s ease;
|
870 |
-
}
|
871 |
-
.output-markdown {
|
872 |
-
padding: 10px;
|
873 |
-
border: 1px solid #ccc;
|
874 |
-
border-radius: 5px;
|
875 |
-
margin-bottom: 10px;
|
876 |
-
}
|
877 |
-
.output-markdown summary {
|
878 |
-
font-weight: bold;
|
879 |
-
cursor: pointer;
|
880 |
-
}
|
881 |
-
.output-markdown code {
|
882 |
-
background-color: #f7f7f7;
|
883 |
-
padding: 2px 4px;
|
884 |
-
border-radius: 3px;
|
885 |
-
font-family: monospace;
|
886 |
}
|
887 |
"""
|
888 |
|
|
|
626 |
|
627 |
if isinstance(image_bytes, bytes):
|
628 |
base64_image = base64.b64encode(image_bytes).decode("utf-8")
|
629 |
+
image_html = f'<img src="data:image/png;base64,{base64_image}" alt="Generated Image" style="max-width: 100%; max-height: 400px;">'
|
630 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
631 |
# Append the /image command and generated image to chat history
|
632 |
chat_history.append([message, ""])
|
633 |
chat_history.append(["", image_html])
|
|
|
676 |
chunk_content = chunk.choices[0].delta.content
|
677 |
full_response += chunk_content
|
678 |
|
679 |
+
updated_history[-1][1] = full_response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
680 |
yield "", updated_history, None, None, None
|
681 |
except Exception as e:
|
682 |
print(f"Streaming error: {e}")
|
|
|
843 |
#main-content {
|
844 |
flex: 1;
|
845 |
transition: flex 0.3s ease;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
846 |
}
|
847 |
"""
|
848 |
|