Skip to content

Commit ca5a970

Browse files
committed
🎨 docstrings to 90 characters and remove whitespaces
1 parent 9558a7d commit ca5a970

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

src/vuegen/streamlit_reportview.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ def run_report(self, output_dir: str = SECTIONS_DIR) -> None:
260260
self.report.logger.debug(
261261
f"Running Streamlit report from directory: {output_dir}"
262262
)
263-
# ! using pyinstaller: vuegen main script as executable, not the Python Interpreter
263+
# ! using pyinstaller: vuegen main script as executable,
264+
# ! not the Python Interpreter
264265
msg = f"{sys.executable = }"
265266
self.report.logger.debug(msg)
266267
try:
@@ -326,7 +327,8 @@ def _format_text(
326327
type : str
327328
The type of the text (e.g., 'header', 'paragraph').
328329
level : int, optional
329-
If the text is a header, the level of the header (e.g., 1 for h1, 2 for h2, etc.).
330+
If the text is a header, the level of the header
331+
(e.g., 1 for h1, 2 for h2, etc.).
330332
color : str, optional
331333
The color of the header text.
332334
text_align : str, optional
@@ -521,8 +523,9 @@ def _combine_components(self, components: list[dict]) -> tuple[list, list, bool]
521523

522524
def _generate_subsection(self, subsection) -> tuple[List[str], List[str]]:
523525
"""
524-
Generate code to render components (plots, dataframes, markdown) in the given subsection,
525-
creating imports and content for the subsection based on the component type.
526+
Generate code to render components (plots, dataframes, markdown) in the given
527+
subsection, creating imports and content for the subsection based on the
528+
component type.
526529
527530
Parameters
528531
----------
@@ -564,7 +567,8 @@ def _generate_subsection(self, subsection) -> tuple[List[str], List[str]]:
564567

565568
def _generate_plot_content(self, plot) -> List[str]:
566569
"""
567-
Generate content for a plot component based on the plot type (static or interactive).
570+
Generate content for a plot component based on the plot type
571+
(static or interactive).
568572
569573
Parameters
570574
----------
@@ -938,8 +942,8 @@ def _generate_html_content(self, html) -> List[str]:
938942

939943
def _generate_apicall_content(self, apicall) -> List[str]:
940944
"""
941-
Generate content for an API component. This method handles the API call and formats
942-
the response for display in the Streamlit app.
945+
Generate content for an API component. This method handles the API call and
946+
formats the response for display in the Streamlit app.
943947
944948
Parameters
945949
----------
@@ -983,23 +987,26 @@ def _generate_apicall_content(self, apicall) -> List[str]:
983987

984988
def _generate_chatbot_content(self, chatbot) -> List[str]:
985989
"""
986-
Generate content to render a ChatBot component, supporting standard and Ollama-style streaming APIs.
990+
Generate content to render a ChatBot component, supporting standard and
991+
Ollama-style streaming APIs.
987992
988-
This method builds and returns a list of strings, which are later executed to create the chatbot
989-
interface in a Streamlit app. It includes user input handling, API interaction logic, response parsing,
993+
This method builds and returns a list of strings, which are later executed to
994+
create the chatbot interface in a Streamlit app. It includes user input handling,
995+
API interaction logic, response parsing,
990996
and conditional rendering of text, source links, and HTML subgraphs.
991997
992998
The function distinguishes between two chatbot modes:
993-
- **Ollama-style streaming API**: Identified by the presence of `chatbot.model`. Uses streaming
994-
JSON chunks from the server to simulate a real-time response.
995-
- **Standard API**: Assumes a simple POST request with a prompt and a full JSON response with text,
999+
- **Ollama-style streaming API**: Identified by the presence of `chatbot.model`.
1000+
Uses streaming JSON chunks from the server to simulate a real-time response.
1001+
- **Standard API**: Assumes a simple POST request with a prompt and a full JSON
1002+
response with text,
9961003
and other fields like links, HTML graphs, etc.
9971004
9981005
Parameters
9991006
----------
10001007
chatbot : ChatBot
1001-
The ChatBot component to generate content for, containing configuration such as title, model,
1002-
API endpoint, headers, and caption.
1008+
The ChatBot component to generate content for, containing configuration such
1009+
as title, model, API endpoint, headers, and caption.
10031010
10041011
Returns
10051012
-------
@@ -1074,7 +1081,8 @@ def parse_api_response(response):
10741081
return {{"role": "assistant", "content": output}}
10751082
output += body.get("message", {{}}).get("content", "")
10761083
except Exception as e:
1077-
return {{"role": "assistant", "content": f"Error while processing API response: {{str(e)}}"}}
1084+
return {{"role": "assistant", "content":
1085+
f"Error while processing API response: {{str(e)}}"}}
10781086
10791087
# Simulated typing effect for responses
10801088
def response_generator(msg_content):
@@ -1088,12 +1096,13 @@ def response_generator(msg_content):
10881096
{handle_prompt_block}
10891097
10901098
# Retrieve question and generate answer
1091-
combined = "\\n".join(msg["content"] for msg in st.session_state.messages if msg["role"] == "user")
1099+
combined = "\\n".join(msg["content"] for msg in st.session_state.messages
1100+
if msg["role"] == "user")
10921101
messages = [{{"role": "user", "content": combined}}]
1093-
with st.spinner('Generating answer...'):
1102+
with st.spinner('Generating answer...'):
10941103
response = generate_query(messages)
10951104
parsed_response = parse_api_response(response)
1096-
1105+
10971106
# Add the assistant's response to the session state and display it
10981107
st.session_state.messages.append(parsed_response)
10991108
with st.chat_message("assistant"):
@@ -1168,7 +1177,8 @@ def _generate_component_imports(self, component: r.Component) -> List[str]:
11681177
Parameters
11691178
----------
11701179
component : r.Component
1171-
The component for which to generate the required imports. The component can be of type:
1180+
The component for which to generate the required imports.
1181+
The component can be of type:
11721182
- PLOT
11731183
- DATAFRAME
11741184

0 commit comments

Comments
 (0)