Spaces:
Running
Running
view debug info
Browse files- .gitignore +181 -0
- app.py +143 -53
- utils/__pycache__/llm_parser.cpython-310.pyc +0 -0
- utils/__pycache__/llm_prompts.cpython-310.pyc +0 -0
- utils/llm_parser.py +1 -1
.gitignore
ADDED
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
share/python-wheels/
|
24 |
+
*.egg-info/
|
25 |
+
.installed.cfg
|
26 |
+
*.egg
|
27 |
+
MANIFEST
|
28 |
+
|
29 |
+
# PyInstaller
|
30 |
+
# Usually these files are written by a python script from a template
|
31 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
32 |
+
*.manifest
|
33 |
+
*.spec
|
34 |
+
|
35 |
+
# Installer logs
|
36 |
+
pip-log.txt
|
37 |
+
pip-delete-this-directory.txt
|
38 |
+
|
39 |
+
# Unit test / coverage reports
|
40 |
+
htmlcov/
|
41 |
+
.tox/
|
42 |
+
.nox/
|
43 |
+
.coverage
|
44 |
+
.coverage.*
|
45 |
+
.cache
|
46 |
+
nosetests.xml
|
47 |
+
coverage.xml
|
48 |
+
*.cover
|
49 |
+
*.py,cover
|
50 |
+
.hypothesis/
|
51 |
+
.pytest_cache/
|
52 |
+
cover/
|
53 |
+
|
54 |
+
# Translations
|
55 |
+
*.mo
|
56 |
+
*.pot
|
57 |
+
|
58 |
+
# Django stuff:
|
59 |
+
*.log
|
60 |
+
local_settings.py
|
61 |
+
db.sqlite3
|
62 |
+
db.sqlite3-journal
|
63 |
+
|
64 |
+
# Flask stuff:
|
65 |
+
instance/
|
66 |
+
.webassets-cache
|
67 |
+
|
68 |
+
# Scrapy stuff:
|
69 |
+
.scrapy
|
70 |
+
|
71 |
+
# Sphinx documentation
|
72 |
+
docs/_build/
|
73 |
+
|
74 |
+
# PyBuilder
|
75 |
+
.pybuilder/
|
76 |
+
target/
|
77 |
+
|
78 |
+
# Jupyter Notebook
|
79 |
+
.ipynb_checkpoints
|
80 |
+
|
81 |
+
# IPython
|
82 |
+
profile_default/
|
83 |
+
ipython_config.py
|
84 |
+
|
85 |
+
# pyenv
|
86 |
+
# For a library or package, you might want to ignore these files since the code is
|
87 |
+
# intended to run in multiple environments; otherwise, check them in:
|
88 |
+
# .python-version
|
89 |
+
|
90 |
+
# pipenv
|
91 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
92 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
93 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
94 |
+
# install all needed dependencies.
|
95 |
+
#Pipfile.lock
|
96 |
+
|
97 |
+
# UV
|
98 |
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
99 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
100 |
+
# commonly ignored for libraries.
|
101 |
+
#uv.lock
|
102 |
+
|
103 |
+
# poetry
|
104 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
105 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
106 |
+
# commonly ignored for libraries.
|
107 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
108 |
+
#poetry.lock
|
109 |
+
|
110 |
+
# pdm
|
111 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
112 |
+
#pdm.lock
|
113 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
114 |
+
# in version control.
|
115 |
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
116 |
+
.pdm.toml
|
117 |
+
.pdm-python
|
118 |
+
.pdm-build/
|
119 |
+
|
120 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
121 |
+
__pypackages__/
|
122 |
+
|
123 |
+
# Celery stuff
|
124 |
+
celerybeat-schedule
|
125 |
+
celerybeat.pid
|
126 |
+
|
127 |
+
# SageMath parsed files
|
128 |
+
*.sage.py
|
129 |
+
|
130 |
+
# Environments
|
131 |
+
.env
|
132 |
+
.venv
|
133 |
+
env/
|
134 |
+
venv/
|
135 |
+
ENV/
|
136 |
+
env.bak/
|
137 |
+
venv.bak/
|
138 |
+
|
139 |
+
# Spyder project settings
|
140 |
+
.spyderproject
|
141 |
+
.spyproject
|
142 |
+
|
143 |
+
# Rope project settings
|
144 |
+
.ropeproject
|
145 |
+
|
146 |
+
# mkdocs documentation
|
147 |
+
/site
|
148 |
+
|
149 |
+
# mypy
|
150 |
+
.mypy_cache/
|
151 |
+
.dmypy.json
|
152 |
+
dmypy.json
|
153 |
+
|
154 |
+
# Pyre type checker
|
155 |
+
.pyre/
|
156 |
+
|
157 |
+
# pytype static type analyzer
|
158 |
+
.pytype/
|
159 |
+
|
160 |
+
# Cython debug symbols
|
161 |
+
cython_debug/
|
162 |
+
|
163 |
+
# PyCharm
|
164 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
165 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
166 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
167 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
168 |
+
#.idea/
|
169 |
+
|
170 |
+
# Ruff stuff:
|
171 |
+
.ruff_cache/
|
172 |
+
|
173 |
+
# PyPI configuration file
|
174 |
+
.pypirc
|
175 |
+
|
176 |
+
# Cursor
|
177 |
+
# Cursor is an AI-powered code editor.`.cursorignore` specifies files/directories to
|
178 |
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
179 |
+
# refer to https://docs.cursor.com/context/ignore-files
|
180 |
+
.cursorignore
|
181 |
+
.cursorindexingignore
|
app.py
CHANGED
@@ -51,7 +51,7 @@ def extract_wikipedia_content(wiki_url, api_key, model_id, base_url, target_lang
|
|
51 |
)
|
52 |
|
53 |
def translate_content(content, article_title, artice_summary, content_format,
|
54 |
-
target_lang, api_key, model_id, base_url):
|
55 |
|
56 |
llm_client = init_llm_client(api_key, base_url=base_url)
|
57 |
|
@@ -76,17 +76,37 @@ def translate_content(content, article_title, artice_summary, content_format,
|
|
76 |
)
|
77 |
|
78 |
decoded_object = json_repair.loads(response.choices[0].message.content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
if 'output_content' in decoded_object:
|
80 |
return decoded_object['output_content']
|
81 |
|
82 |
return "Error: Translation output not found in the response."
|
83 |
|
84 |
-
def translate_section(section_content, article_title, article_summary, content_format,
|
|
|
85 |
"""
|
86 |
Translates a single section of the Wikipedia article
|
87 |
"""
|
88 |
if not section_content or not api_key:
|
89 |
-
return "Please provide content and API key for translation."
|
90 |
|
91 |
# Use custom language if selected
|
92 |
if target_lang == "custom" and custom_lang:
|
@@ -94,7 +114,7 @@ def translate_section(section_content, article_title, article_summary, content_f
|
|
94 |
else:
|
95 |
actual_lang = target_lang
|
96 |
|
97 |
-
|
98 |
content=section_content,
|
99 |
article_title=article_title,
|
100 |
artice_summary=article_summary,
|
@@ -102,58 +122,77 @@ def translate_section(section_content, article_title, article_summary, content_f
|
|
102 |
target_lang=actual_lang,
|
103 |
api_key=api_key,
|
104 |
model_id=model_id,
|
105 |
-
base_url=base_url
|
|
|
106 |
)
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
-
def
|
109 |
-
"""
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
"""
|
112 |
-
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
empty_updates = []
|
117 |
-
for _ in range(100): # Assuming max 100 sections
|
118 |
-
empty_updates.extend([
|
119 |
-
gr.update(visible=False), # section textbox
|
120 |
-
gr.update(visible=False), # translate button
|
121 |
-
gr.update(visible=False) # translation output
|
122 |
-
])
|
123 |
-
return empty_updates
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
value=section_content,
|
130 |
-
label=f"Section: {section_name}",
|
131 |
-
visible=True
|
132 |
-
))
|
133 |
-
|
134 |
-
# Update for translate button
|
135 |
-
components.append(gr.update(
|
136 |
-
visible=True,
|
137 |
-
value=f"Translate {section_name}"
|
138 |
-
))
|
139 |
-
|
140 |
-
# Update for translation output
|
141 |
-
components.append(gr.update(
|
142 |
-
visible=True,
|
143 |
-
value="",
|
144 |
-
label=f"Translation: {section_name}"
|
145 |
-
))
|
146 |
|
147 |
-
#
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
-
return
|
157 |
|
158 |
# Create Gradio app
|
159 |
with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
@@ -232,6 +271,13 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
232 |
label="Content Format",
|
233 |
info="Choose how to display article content"
|
234 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
|
236 |
gr.Markdown("### About")
|
237 |
gr.Markdown("""
|
@@ -286,6 +332,12 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
286 |
visible=False # Hidden by default as it's usually large
|
287 |
)
|
288 |
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
# Pre-define section textboxes and related components
|
290 |
gr.Markdown("### Article Sections")
|
291 |
with gr.Column() as sections_container:
|
@@ -295,10 +347,11 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
295 |
section_textbox = gr.Textbox(visible=False, lines=4)
|
296 |
translate_btn = gr.Button("Translate", visible=False)
|
297 |
translation_output = gr.Textbox(visible=False, lines=4)
|
298 |
-
|
|
|
299 |
|
300 |
# Connect the translate button to the translation function
|
301 |
-
translate_btn.click(
|
302 |
fn=translate_section,
|
303 |
inputs=[
|
304 |
section_textbox,
|
@@ -309,9 +362,27 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
309 |
custom_language,
|
310 |
api_key,
|
311 |
model_id,
|
312 |
-
base_url
|
|
|
313 |
],
|
314 |
-
outputs=translation_output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
)
|
316 |
|
317 |
# Connect the extract button to the function
|
@@ -345,6 +416,25 @@ with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
345 |
outputs=[sidebar_expanded, sidebar, main_content, sidebar_show_btn]
|
346 |
)
|
347 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
348 |
# Launch the app
|
349 |
if __name__ == "__main__":
|
350 |
demo.launch()
|
|
|
51 |
)
|
52 |
|
53 |
def translate_content(content, article_title, artice_summary, content_format,
|
54 |
+
target_lang, api_key, model_id, base_url, debug_mode=False):
|
55 |
|
56 |
llm_client = init_llm_client(api_key, base_url=base_url)
|
57 |
|
|
|
76 |
)
|
77 |
|
78 |
decoded_object = json_repair.loads(response.choices[0].message.content)
|
79 |
+
|
80 |
+
# Return translation and debug info if debug mode is enabled
|
81 |
+
if debug_mode:
|
82 |
+
debug_info = {
|
83 |
+
"prompt": translation_prompt,
|
84 |
+
"response": response.choices[0].message.content,
|
85 |
+
"usage": {
|
86 |
+
"prompt_tokens": response.usage.prompt_tokens,
|
87 |
+
"completion_tokens": response.usage.completion_tokens,
|
88 |
+
"total_tokens": response.usage.total_tokens
|
89 |
+
},
|
90 |
+
"model": model_id
|
91 |
+
}
|
92 |
+
|
93 |
+
if 'output_content' in decoded_object:
|
94 |
+
return decoded_object['output_content'], debug_info
|
95 |
+
return "Error: Translation output not found in the response.", debug_info
|
96 |
+
|
97 |
+
# Regular return when debug mode is disabled
|
98 |
if 'output_content' in decoded_object:
|
99 |
return decoded_object['output_content']
|
100 |
|
101 |
return "Error: Translation output not found in the response."
|
102 |
|
103 |
+
def translate_section(section_content, article_title, article_summary, content_format,
|
104 |
+
target_lang, custom_lang, api_key, model_id, base_url, debug_mode=False):
|
105 |
"""
|
106 |
Translates a single section of the Wikipedia article
|
107 |
"""
|
108 |
if not section_content or not api_key:
|
109 |
+
return "Please provide content and API key for translation.", None if debug_mode else None
|
110 |
|
111 |
# Use custom language if selected
|
112 |
if target_lang == "custom" and custom_lang:
|
|
|
114 |
else:
|
115 |
actual_lang = target_lang
|
116 |
|
117 |
+
result = translate_content(
|
118 |
content=section_content,
|
119 |
article_title=article_title,
|
120 |
artice_summary=article_summary,
|
|
|
122 |
target_lang=actual_lang,
|
123 |
api_key=api_key,
|
124 |
model_id=model_id,
|
125 |
+
base_url=base_url,
|
126 |
+
debug_mode=debug_mode
|
127 |
)
|
128 |
+
|
129 |
+
if debug_mode:
|
130 |
+
translation, debug_info = result
|
131 |
+
return translation, debug_info
|
132 |
+
return result, None
|
133 |
|
134 |
+
def format_debug_info(debug_info):
|
135 |
+
"""Format debug information as markdown for display in modal"""
|
136 |
+
if not debug_info:
|
137 |
+
return "No debug information available."
|
138 |
+
|
139 |
+
# Format the debug information as markdown
|
140 |
+
markdown = "## LLM Debug Information\n\n"
|
141 |
+
|
142 |
+
# Add model and usage info
|
143 |
+
markdown += f"### Model: {debug_info['model']}\n\n"
|
144 |
+
markdown += "### Usage\n"
|
145 |
+
markdown += f"- Prompt tokens: {debug_info['usage']['prompt_tokens']}\n"
|
146 |
+
markdown += f"- Completion tokens: {debug_info['usage']['completion_tokens']}\n"
|
147 |
+
markdown += f"- Total tokens: {debug_info['usage']['total_tokens']}\n\n"
|
148 |
+
|
149 |
+
# Add prompt
|
150 |
+
markdown += "### Prompt\n"
|
151 |
+
markdown += f"```\n{debug_info['prompt'].replace('```','')}\n```\n\n"
|
152 |
+
|
153 |
+
# Add raw response
|
154 |
+
markdown += "### Raw Response\n"
|
155 |
+
markdown += f"```json\n{debug_info['response']}\n```\n"
|
156 |
+
|
157 |
+
return markdown
|
158 |
+
|
159 |
+
# Add this function to update UI with sections from Wikipedia content
|
160 |
+
def update_ui_with_sections(sections):
|
161 |
"""
|
162 |
+
Updates the UI to display sections from the Wikipedia article
|
163 |
|
164 |
+
Args:
|
165 |
+
sections: Dictionary of section titles and content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
+
Returns:
|
168 |
+
List of updates for all section components
|
169 |
+
"""
|
170 |
+
results = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
+
# Prepare updates for up to 100 sections (400 components - 4 per section)
|
173 |
+
for i in range(100):
|
174 |
+
if i < len(sections):
|
175 |
+
# Get section title and content
|
176 |
+
section_title = list(sections.keys())[i]
|
177 |
+
section_content = sections[section_title]
|
178 |
+
|
179 |
+
# Make section textbox visible with content and label
|
180 |
+
results.extend([
|
181 |
+
gr.update(visible=True, value=section_content, label=f"Section: {section_title}"),
|
182 |
+
gr.update(visible=True), # Translate button
|
183 |
+
gr.update(visible=True, value="", label=f"Translation: {section_title}"), # Translation output
|
184 |
+
gr.update(visible=False) # Debug button (hidden by default)
|
185 |
+
])
|
186 |
+
else:
|
187 |
+
# Hide unused components
|
188 |
+
results.extend([
|
189 |
+
gr.update(visible=False),
|
190 |
+
gr.update(visible=False),
|
191 |
+
gr.update(visible=False),
|
192 |
+
gr.update(visible=False)
|
193 |
+
])
|
194 |
|
195 |
+
return results
|
196 |
|
197 |
# Create Gradio app
|
198 |
with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
|
|
271 |
label="Content Format",
|
272 |
info="Choose how to display article content"
|
273 |
)
|
274 |
+
|
275 |
+
# Debug mode toggle
|
276 |
+
debug_mode = gr.Checkbox(
|
277 |
+
label="Debug Mode",
|
278 |
+
value=False,
|
279 |
+
info="Show detailed information about LLM calls"
|
280 |
+
)
|
281 |
|
282 |
gr.Markdown("### About")
|
283 |
gr.Markdown("""
|
|
|
332 |
visible=False # Hidden by default as it's usually large
|
333 |
)
|
334 |
|
335 |
+
# Debug info state and modal components
|
336 |
+
debug_info_state = gr.State(None)
|
337 |
+
|
338 |
+
with gr.Blocks() as debug_modal:
|
339 |
+
debug_markdown = gr.Markdown("Debug information will appear here.")
|
340 |
+
|
341 |
# Pre-define section textboxes and related components
|
342 |
gr.Markdown("### Article Sections")
|
343 |
with gr.Column() as sections_container:
|
|
|
347 |
section_textbox = gr.Textbox(visible=False, lines=4)
|
348 |
translate_btn = gr.Button("Translate", visible=False)
|
349 |
translation_output = gr.Textbox(visible=False, lines=4)
|
350 |
+
debug_btn = gr.Button("View Debug Info", visible=False)
|
351 |
+
section_components.extend([section_textbox, translate_btn, translation_output, debug_btn])
|
352 |
|
353 |
# Connect the translate button to the translation function
|
354 |
+
result = translate_btn.click(
|
355 |
fn=translate_section,
|
356 |
inputs=[
|
357 |
section_textbox,
|
|
|
362 |
custom_language,
|
363 |
api_key,
|
364 |
model_id,
|
365 |
+
base_url,
|
366 |
+
debug_mode
|
367 |
],
|
368 |
+
outputs=[translation_output, debug_info_state]
|
369 |
+
)
|
370 |
+
|
371 |
+
# Show debug button only when debug mode is on and after translation
|
372 |
+
result.then(
|
373 |
+
fn=lambda debug_info, debug_mode: gr.update(visible=debug_mode and debug_info is not None),
|
374 |
+
inputs=[debug_info_state, debug_mode],
|
375 |
+
outputs=[debug_btn]
|
376 |
+
)
|
377 |
+
|
378 |
+
# Connect debug button to show modal with debug info
|
379 |
+
debug_btn.click(
|
380 |
+
fn=format_debug_info,
|
381 |
+
inputs=[debug_info_state],
|
382 |
+
outputs=[debug_markdown]
|
383 |
+
).then(
|
384 |
+
fn=lambda: True,
|
385 |
+
outputs=[debug_modal]
|
386 |
)
|
387 |
|
388 |
# Connect the extract button to the function
|
|
|
416 |
outputs=[sidebar_expanded, sidebar, main_content, sidebar_show_btn]
|
417 |
)
|
418 |
|
419 |
+
# Add debug info display to the bottom of the sidebar
|
420 |
+
with sidebar:
|
421 |
+
debug_header = gr.Markdown("### Debug Information", visible=False)
|
422 |
+
debug_display = gr.Markdown(visible=False)
|
423 |
+
|
424 |
+
# Update the debug button click handler to show debug info in the sidebar
|
425 |
+
for i in range(0, len(section_components), 4):
|
426 |
+
debug_btn = section_components[i+3] # The debug button is the 4th component
|
427 |
+
|
428 |
+
# Re-connect debug button with proper click handling
|
429 |
+
debug_btn.click(
|
430 |
+
fn=format_debug_info,
|
431 |
+
inputs=[debug_info_state],
|
432 |
+
outputs=[debug_display]
|
433 |
+
).then(
|
434 |
+
fn=lambda: (gr.update(visible=True), gr.update(visible=True)),
|
435 |
+
outputs=[debug_header, debug_display]
|
436 |
+
)
|
437 |
+
|
438 |
# Launch the app
|
439 |
if __name__ == "__main__":
|
440 |
demo.launch()
|
utils/__pycache__/llm_parser.cpython-310.pyc
CHANGED
Binary files a/utils/__pycache__/llm_parser.cpython-310.pyc and b/utils/__pycache__/llm_parser.cpython-310.pyc differ
|
|
utils/__pycache__/llm_prompts.cpython-310.pyc
CHANGED
Binary files a/utils/__pycache__/llm_prompts.cpython-310.pyc and b/utils/__pycache__/llm_prompts.cpython-310.pyc differ
|
|
utils/llm_parser.py
CHANGED
@@ -6,7 +6,7 @@ def init_llm_client(api_key, base_url=None):
|
|
6 |
"""
|
7 |
Initialize the OpenAI client with the provided API key and model ID.
|
8 |
"""
|
9 |
-
|
10 |
if base_url and len(base_url) > 0 and base_url.startswith("http"):
|
11 |
os.environ["OPENAI_API_BASE"] = base_url
|
12 |
else:
|
|
|
6 |
"""
|
7 |
Initialize the OpenAI client with the provided API key and model ID.
|
8 |
"""
|
9 |
+
|
10 |
if base_url and len(base_url) > 0 and base_url.startswith("http"):
|
11 |
os.environ["OPENAI_API_BASE"] = base_url
|
12 |
else:
|