Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,14 +37,12 @@ def process_chat(message, history, session_id):
|
|
37 |
thread_id = client.beta.threads.create().id
|
38 |
session_threads[session_id] = thread_id
|
39 |
|
40 |
-
# Store user message
|
41 |
client.beta.threads.messages.create(
|
42 |
thread_id=thread_id,
|
43 |
role="user",
|
44 |
content=message
|
45 |
)
|
46 |
|
47 |
-
# Run assistant
|
48 |
run = client.beta.threads.runs.create(
|
49 |
thread_id=thread_id,
|
50 |
assistant_id=ASSISTANT_ID
|
@@ -59,7 +57,6 @@ def process_chat(message, history, session_id):
|
|
59 |
break
|
60 |
time.sleep(1)
|
61 |
|
62 |
-
# Retrieve assistant message
|
63 |
messages = client.beta.threads.messages.list(thread_id=thread_id)
|
64 |
for msg in reversed(messages.data):
|
65 |
if msg.role == "assistant":
|
@@ -68,7 +65,7 @@ def process_chat(message, history, session_id):
|
|
68 |
else:
|
69 |
assistant_response = "⚠️ Assistant did not respond."
|
70 |
|
71 |
-
# Detect image
|
72 |
image_url = None
|
73 |
match = re.search(r'https://raw\.githubusercontent\.com/AndrewLORTech/surgical-pathology-manual/main/[\w\-/]*\.png', assistant_response)
|
74 |
if match:
|
@@ -115,10 +112,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
115 |
),
|
116 |
additional_inputs=[session_id],
|
117 |
examples=["What does clause 3.2 mean?", "Summarize the timeline from the image."],
|
118 |
-
title="💬 Document Assistant"
|
119 |
-
retry_btn="🔁 Retry",
|
120 |
-
undo_btn="↩️ Undo",
|
121 |
-
clear_btn="🗑️ Clear",
|
122 |
)
|
123 |
|
124 |
# Link image preview if extracted
|
|
|
37 |
thread_id = client.beta.threads.create().id
|
38 |
session_threads[session_id] = thread_id
|
39 |
|
|
|
40 |
client.beta.threads.messages.create(
|
41 |
thread_id=thread_id,
|
42 |
role="user",
|
43 |
content=message
|
44 |
)
|
45 |
|
|
|
46 |
run = client.beta.threads.runs.create(
|
47 |
thread_id=thread_id,
|
48 |
assistant_id=ASSISTANT_ID
|
|
|
57 |
break
|
58 |
time.sleep(1)
|
59 |
|
|
|
60 |
messages = client.beta.threads.messages.list(thread_id=thread_id)
|
61 |
for msg in reversed(messages.data):
|
62 |
if msg.role == "assistant":
|
|
|
65 |
else:
|
66 |
assistant_response = "⚠️ Assistant did not respond."
|
67 |
|
68 |
+
# Detect image from GitHub
|
69 |
image_url = None
|
70 |
match = re.search(r'https://raw\.githubusercontent\.com/AndrewLORTech/surgical-pathology-manual/main/[\w\-/]*\.png', assistant_response)
|
71 |
if match:
|
|
|
112 |
),
|
113 |
additional_inputs=[session_id],
|
114 |
examples=["What does clause 3.2 mean?", "Summarize the timeline from the image."],
|
115 |
+
title="💬 Document Assistant"
|
|
|
|
|
|
|
116 |
)
|
117 |
|
118 |
# Link image preview if extracted
|