Debug
Browse files
app.py
CHANGED
@@ -110,14 +110,23 @@ def chat_with_model(messages):
|
|
110 |
pad_id = current_tokenizer.pad_token_id or current_tokenizer.unk_token_id or 0
|
111 |
eos_id = current_tokenizer.eos_token_id
|
112 |
|
113 |
-
|
114 |
system_messages = [
|
115 |
{
|
116 |
"role": "system",
|
117 |
"content": (
|
118 |
"You are a radiologist's companion, here to answer questions about the patient and assist in the diagnosis if asked to do so. "
|
119 |
"You are able to call specialized tools. "
|
120 |
-
"At the moment, you have one tool available: an organ segmentation algorithm for abdominal CTs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
)
|
122 |
},
|
123 |
{
|
@@ -130,7 +139,7 @@ def chat_with_model(messages):
|
|
130 |
# filtered_messages = [msg for msg in messages if not (msg["role"] == "assistant" and "Welcome to the Radiologist's Companion" in msg["content"])]
|
131 |
|
132 |
# FULL conversation
|
133 |
-
full_messages = system_messages +
|
134 |
|
135 |
# --- Generate from full context
|
136 |
prompt = format_prompt(full_messages)
|
|
|
110 |
pad_id = current_tokenizer.pad_token_id or current_tokenizer.unk_token_id or 0
|
111 |
eos_id = current_tokenizer.eos_token_id
|
112 |
|
113 |
+
# Build system context
|
114 |
system_messages = [
|
115 |
{
|
116 |
"role": "system",
|
117 |
"content": (
|
118 |
"You are a radiologist's companion, here to answer questions about the patient and assist in the diagnosis if asked to do so. "
|
119 |
"You are able to call specialized tools. "
|
120 |
+
"At the moment, you have one tool available: an organ segmentation algorithm for abdominal CTs.\n\n"
|
121 |
+
"If the user requests an organ segmentation, output a JSON object in this structure:\n"
|
122 |
+
"{\n"
|
123 |
+
" \"function\": \"segment_organ\",\n"
|
124 |
+
" \"arguments\": {\n"
|
125 |
+
" \"scan_path\": \"<path_to_ct_scan>\",\n"
|
126 |
+
" \"organ\": \"<organ_name>\"\n"
|
127 |
+
" }\n"
|
128 |
+
"}\n\n"
|
129 |
+
"Once you call the function, the app will execute it and return the result."
|
130 |
)
|
131 |
},
|
132 |
{
|
|
|
139 |
# filtered_messages = [msg for msg in messages if not (msg["role"] == "assistant" and "Welcome to the Radiologist's Companion" in msg["content"])]
|
140 |
|
141 |
# FULL conversation
|
142 |
+
full_messages = system_messages + messages
|
143 |
|
144 |
# --- Generate from full context
|
145 |
prompt = format_prompt(full_messages)
|