MCPcopy Create free account
hub / github.com/VitoHowe/glm-coding / find_prompt_item

Function find_prompt_item

app/services/tenvision_adapter.py:206–232  ·  view source on GitHub ↗
(items, image_h, image_w)

Source from the content-addressed store, hash-verified

204 if y > int(image_h * 0.22):
205 continue
206 chars = parse_prompt_chars(text)
207 if PROMPT_PREFIX in text or ('点击' in text and len(chars) >= 2):
208 prompt_candidates.append((len(chars), w, -y, item))
209
210 if prompt_candidates:
211 prompt_candidates.sort(reverse=True)
212 return prompt_candidates[0][3]
213
214 wide_top_items = [
215 item
216 for item in items
217 if (
218 item['bbox'][1] <= int(image_h * 0.18)
219 and item['bbox'][2] >= int(image_w * 0.25)
220 and is_prompt_like_text(item['text'])
221 )
222 ]
223 if wide_top_items:
224 return sorted(wide_top_items, key=lambda it: (it['bbox'][1], -it['bbox'][2]))[0]
225 return None
226
227
228def build_prompt_chars(items, image, engine):
229 prompt_item = find_prompt_item(items, image.shape[0], image.shape[1])
230 if prompt_item is not None:
231 chars = parse_prompt_chars(prompt_item['text'])
232 if len(chars) >= 2:
233 return prompt_item, chars
234
235 top_roi = image[: int(image.shape[0] * 0.14), :]

Callers 1

build_prompt_charsFunction · 0.85

Calls 2

parse_prompt_charsFunction · 0.85
is_prompt_like_textFunction · 0.85

Tested by

no test coverage detected