Spaces:
Runtime error
Runtime error
Fixed a display issue in the markdown with dollar signs in prices
Browse files- pages/010_LLM_Architectures.py +2 -2
- src/architectures.py +3 -3
- src/common.py +10 -0
pages/010_LLM_Architectures.py
CHANGED
@@ -2,7 +2,7 @@ import pandas as pd
|
|
2 |
import streamlit as st
|
3 |
|
4 |
from src.st_helpers import st_setup
|
5 |
-
from src.common import img_dir
|
6 |
from src.architectures import *
|
7 |
|
8 |
|
@@ -51,7 +51,7 @@ def show_architecture(architecture: str) -> None:
|
|
51 |
request = ArchitectureRequest(query=prompt)
|
52 |
trace = arch(request)
|
53 |
with st.chat_message("assistant"):
|
54 |
-
st.write(request.response)
|
55 |
with trace_col:
|
56 |
st.write("#### Architecture Trace")
|
57 |
st.markdown(trace.as_markdown())
|
|
|
2 |
import streamlit as st
|
3 |
|
4 |
from src.st_helpers import st_setup
|
5 |
+
from src.common import img_dir, escape_dollars
|
6 |
from src.architectures import *
|
7 |
|
8 |
|
|
|
51 |
request = ArchitectureRequest(query=prompt)
|
52 |
trace = arch(request)
|
53 |
with st.chat_message("assistant"):
|
54 |
+
st.write(escape_dollars(request.response))
|
55 |
with trace_col:
|
56 |
st.write("#### Architecture Trace")
|
57 |
st.markdown(trace.as_markdown())
|
src/architectures.py
CHANGED
@@ -14,7 +14,7 @@ from time import time
|
|
14 |
from typing import List, Optional
|
15 |
from better_profanity import profanity
|
16 |
|
17 |
-
from src.common import config_dir, data_dir, hf_api_token
|
18 |
from src.models import HFLlamaChatModel
|
19 |
|
20 |
|
@@ -59,7 +59,7 @@ class ArchitectureRequest:
|
|
59 |
md += "\n- **Response evolution**"
|
60 |
for r in self._response:
|
61 |
md += f"\n - {r}"
|
62 |
-
return md
|
63 |
|
64 |
|
65 |
class ArchitectureTraceOutcome(Enum):
|
@@ -112,7 +112,7 @@ class ArchitectureTraceStep:
|
|
112 |
elif self.outcome == ArchitectureTraceOutcome.EXCEPTION:
|
113 |
outcome = f"Exception ({self._exception})"
|
114 |
md += f" - **Outcome**: {outcome}"
|
115 |
-
return md
|
116 |
|
117 |
|
118 |
class ArchitectureTrace:
|
|
|
14 |
from typing import List, Optional
|
15 |
from better_profanity import profanity
|
16 |
|
17 |
+
from src.common import config_dir, data_dir, hf_api_token, escape_dollars
|
18 |
from src.models import HFLlamaChatModel
|
19 |
|
20 |
|
|
|
59 |
md += "\n- **Response evolution**"
|
60 |
for r in self._response:
|
61 |
md += f"\n - {r}"
|
62 |
+
return escape_dollars(md)
|
63 |
|
64 |
|
65 |
class ArchitectureTraceOutcome(Enum):
|
|
|
112 |
elif self.outcome == ArchitectureTraceOutcome.EXCEPTION:
|
113 |
outcome = f"Exception ({self._exception})"
|
114 |
md += f" - **Outcome**: {outcome}"
|
115 |
+
return escape_dollars(md)
|
116 |
|
117 |
|
118 |
class ArchitectureTrace:
|
src/common.py
CHANGED
@@ -30,3 +30,13 @@ def join_items_comma_and(items: List[str]) -> str:
|
|
30 |
if string_count == 1:
|
31 |
return items[0]
|
32 |
return f"{', '.join(items[:-1])} and {items[-1]}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
if string_count == 1:
|
31 |
return items[0]
|
32 |
return f"{', '.join(items[:-1])} and {items[-1]}"
|
33 |
+
|
34 |
+
|
35 |
+
def escape_dollars(text: str) -> str:
|
36 |
+
"""
|
37 |
+
Convenience function to escape dollar signs for prices in markdown
|
38 |
+
"""
|
39 |
+
if text is None:
|
40 |
+
return text
|
41 |
+
return text.replace("$", "\\$")
|
42 |
+
|