MCPcopy
hub / github.com/XPixelGroup/DiffBIR / add_text

Function add_text

llava/serve/gradio_web_server.py:128–151  ·  view source on GitHub ↗
(state, text, image, image_process_mode, request: gr.Request)

Source from the content-addressed store, hash-verified

126
127
128def add_text(state, text, image, image_process_mode, request: gr.Request):
129 logger.info(f"add_text. ip: {request.client.host}. len: {len(text)}")
130 if len(text) <= 0 and image is None:
131 state.skip_next = True
132 return (state, state.to_gradio_chatbot(), "", None) + (no_change_btn,) * 5
133 if args.moderate:
134 flagged = violates_moderation(text)
135 if flagged:
136 state.skip_next = True
137 return (state, state.to_gradio_chatbot(), moderation_msg, None) + (
138 no_change_btn,) * 5
139
140 text = text[:1536] # Hard cut-off
141 if image is not None:
142 text = text[:1200] # Hard cut-off for images
143 if '<image>' not in text:
144 # text = '<Image><image></Image>' + text
145 text = text + '\n<image>'
146 text = (text, image, image_process_mode)
147 state = default_conversation.copy()
148 state.append_message(state.roles[0], text)
149 state.append_message(state.roles[1], None)
150 state.skip_next = False
151 return (state, state.to_gradio_chatbot(), "", None) + (disable_btn,) * 5
152
153
154def http_bot(state, model_selector, temperature, top_p, max_new_tokens, request: gr.Request):

Callers

nothing calls this directly

Calls 4

violates_moderationFunction · 0.90
to_gradio_chatbotMethod · 0.80
copyMethod · 0.80
append_messageMethod · 0.80

Tested by

no test coverage detected