Spaces:
Running
Running
Upload 8 files
Browse files- index.html +4 -6
- phase0102_chunker_aggregator_2.py +21 -2
index.html
CHANGED
|
@@ -41,6 +41,9 @@
|
|
| 41 |
|
| 42 |
<button onclick="uploadFile()" style="margin-top:10px; width:100%;">Process Jungian Tree</button>
|
| 43 |
<div id="status" style="font-size: 0.8em; margin-top: 10px; color: var(--accent);">Status: Idle</div>
|
|
|
|
|
|
|
|
|
|
| 44 |
</div>
|
| 45 |
|
| 46 |
<script>
|
|
@@ -96,9 +99,4 @@ function listenToStream() {
|
|
| 96 |
|
| 97 |
|
| 98 |
</body>
|
| 99 |
-
</html>
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
|
|
|
| 41 |
|
| 42 |
<button onclick="uploadFile()" style="margin-top:10px; width:100%;">Process Jungian Tree</button>
|
| 43 |
<div id="status" style="font-size: 0.8em; margin-top: 10px; color: var(--accent);">Status: Idle</div>
|
| 44 |
+
|
| 45 |
+
<div id="tree-container"></div>
|
| 46 |
+
|
| 47 |
</div>
|
| 48 |
|
| 49 |
<script>
|
|
|
|
| 99 |
|
| 100 |
|
| 101 |
</body>
|
| 102 |
+
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
phase0102_chunker_aggregator_2.py
CHANGED
|
@@ -68,8 +68,26 @@ WHOLE = False # Set to True to process the whole book; False to process a page r
|
|
| 68 |
START_PAGE = 5
|
| 69 |
END_PAGE = 15
|
| 70 |
|
| 71 |
-
def call_groq_json(system_prompt, user_content):
|
| 72 |
strict_system_prompt = system_prompt + "\nIMPORTANT: Ensure all internal quotes are escaped. Respond ONLY in valid JSON."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
completion = client.chat.completions.create(
|
| 74 |
model=MODEL,
|
| 75 |
messages=[
|
|
@@ -80,7 +98,8 @@ def call_groq_json(system_prompt, user_content):
|
|
| 80 |
temperature=0.2
|
| 81 |
)
|
| 82 |
return json.loads(completion.choices[0].message.content)
|
| 83 |
-
|
|
|
|
| 84 |
#async def run_chunking_process(pdf_path, queue=None, whole=False, start_p=20, end_p=30):
|
| 85 |
async def run_chunking_process(pdf_path, queue=None, whole=WHOLE, start_p=START_PAGE, end_p=END_PAGE):
|
| 86 |
"""
|
|
|
|
| 68 |
START_PAGE = 5
|
| 69 |
END_PAGE = 15
|
| 70 |
|
| 71 |
+
async def call_groq_json(system_prompt, user_content):
|
| 72 |
strict_system_prompt = system_prompt + "\nIMPORTANT: Ensure all internal quotes are escaped. Respond ONLY in valid JSON."
|
| 73 |
+
|
| 74 |
+
# Use loop.run_in_executor to keep the Groq call from blocking the UI
|
| 75 |
+
loop = asyncio.get_event_loop()
|
| 76 |
+
completion = await loop.run_in_executor(
|
| 77 |
+
None,
|
| 78 |
+
lambda: client.chat.completions.create(
|
| 79 |
+
model=MODEL,
|
| 80 |
+
messages=[
|
| 81 |
+
{"role": "system", "content": strict_system_prompt},
|
| 82 |
+
{"role": "user", "content": user_content}
|
| 83 |
+
],
|
| 84 |
+
response_format={"type": "json_object"},
|
| 85 |
+
temperature=0.2
|
| 86 |
+
)
|
| 87 |
+
)
|
| 88 |
+
return json.loads(completion.choices[0].message.content)
|
| 89 |
+
|
| 90 |
+
"""
|
| 91 |
completion = client.chat.completions.create(
|
| 92 |
model=MODEL,
|
| 93 |
messages=[
|
|
|
|
| 98 |
temperature=0.2
|
| 99 |
)
|
| 100 |
return json.loads(completion.choices[0].message.content)
|
| 101 |
+
"""
|
| 102 |
+
|
| 103 |
#async def run_chunking_process(pdf_path, queue=None, whole=False, start_p=20, end_p=30):
|
| 104 |
async def run_chunking_process(pdf_path, queue=None, whole=WHOLE, start_p=START_PAGE, end_p=END_PAGE):
|
| 105 |
"""
|