Elffuss BraidHub

kikocis/llama-stack public

63314e75ef83 · 29.6 KiBRawPermalink
1# Copyright (c) Meta Platforms, Inc. and affiliates.
2# All rights reserved.
3#
4# This source code is licensed under the terms described in the LICENSE file in
5# the root directory of this source tree.
6
7import asyncio
8import copy
9import os
10import secrets
11import shutil
12import string
13import tempfile
14import uuid
15from datetime import datetime
16from typing import AsyncGenerator, List, Tuple
17from urllib.parse import urlparse
18
19import httpx
20
21from termcolor import cprint
22
23from llama_toolchain.agentic_system.api import * # noqa: F403
24from llama_toolchain.inference.api import * # noqa: F403
25from llama_toolchain.memory.api import * # noqa: F403
26from llama_toolchain.safety.api import * # noqa: F403
27
28from llama_toolchain.tools.base import BaseTool
29from llama_toolchain.tools.builtin import (
30 interpret_content_as_attachment,
31 SingleMessageBuiltinTool,
32)
33
34from .rag.context_retriever import generate_rag_query
35from .safety import SafetyException, ShieldRunnerMixin
36
37
38def make_random_string(length: int = 8):
39 return "".join(
40 secrets.choice(string.ascii_letters + string.digits) for _ in range(length)
41 )
42
43
44class ChatAgent(ShieldRunnerMixin):
45 def __init__(
46 self,
47 agent_config: AgentConfig,
48 inference_api: Inference,
49 memory_api: Memory,
50 safety_api: Safety,
51 builtin_tools: List[SingleMessageBuiltinTool],
52 max_infer_iters: int = 10,
53 ):
54 self.agent_config = agent_config
55 self.inference_api = inference_api
56 self.memory_api = memory_api
57 self.safety_api = safety_api
58
59 self.max_infer_iters = max_infer_iters
60 self.tools_dict = {t.get_name(): t for t in builtin_tools}
61
62 self.tempdir = tempfile.mkdtemp()
63 self.sessions = {}
64
65 ShieldRunnerMixin.__init__(
66 self,
67 safety_api,
68 input_shields=agent_config.input_shields,
69 output_shields=agent_config.output_shields,
70 )
71
72 def __del__(self):
73 shutil.rmtree(self.tempdir)
74
75 def turn_to_messages(self, turn: Turn) -> List[Message]:
76 messages = []
77
78 # We do not want to keep adding RAG context to the input messages
79 # May be this should be a parameter of the agentic instance
80 # that can define its behavior in a custom way
81 for m in turn.input_messages:
82 msg = m.copy()
83 if isinstance(msg, UserMessage):
84 msg.context = None
85 messages.append(msg)
86
87 # messages.extend(turn.input_messages)
88 for step in turn.steps:
89 if step.step_type == StepType.inference.value:
90 messages.append(step.model_response)
91 elif step.step_type == StepType.tool_execution.value:
92 for response in step.tool_responses:
93 messages.append(
94 ToolResponseMessage(
95 call_id=response.call_id,
96 tool_name=response.tool_name,
97 content=response.content,
98 )
99 )
100 elif step.step_type == StepType.shield_call.value:
101 response = step.response
102 if response.is_violation:
103 # CompletionMessage itself in the ShieldResponse
104 messages.append(
105 CompletionMessage(
106 content=response.violation_return_message,
107 stop_reason=StopReason.end_of_turn,
108 )
109 )
110 # print_dialog(messages)
111 return messages
112
113 def create_session(self, name: str) -> Session:
114 session_id = str(uuid.uuid4())
115 session = Session(
116 session_id=session_id,
117 session_name=name,
118 turns=[],
119 started_at=datetime.now(),
120 )
121 self.sessions[session_id] = session
122 return session
123
124 async def create_and_execute_turn(
125 self, request: AgenticSystemTurnCreateRequest
126 ) -> AsyncGenerator:
127 assert (
128 request.session_id in self.sessions
129 ), f"Session {request.session_id} not found"
130
131 session = self.sessions[request.session_id]
132
133 messages = []
134 for i, turn in enumerate(session.turns):
135 messages.extend(self.turn_to_messages(turn))
136
137 messages.extend(request.messages)
138
139 # print("processed dialog ======== ")
140 # print_dialog(messages)
141
142 turn_id = str(uuid.uuid4())
143 start_time = datetime.now()
144 yield AgenticSystemTurnResponseStreamChunk(
145 event=AgenticSystemTurnResponseEvent(
146 payload=AgenticSystemTurnResponseTurnStartPayload(
147 turn_id=turn_id,
148 )
149 )
150 )
151
152 steps = []
153 output_message = None
154 async for chunk in self.run(
155 session=session,
156 turn_id=turn_id,
157 input_messages=messages,
158 attachments=request.attachments or [],
159 sampling_params=self.agent_config.sampling_params,
160 stream=request.stream,
161 ):
162 if isinstance(chunk, CompletionMessage):
163 cprint(
164 f"{chunk.role.capitalize()}: {chunk.content}",
165 "white",
166 attrs=["bold"],
167 )
168 output_message = chunk
169 continue
170
171 assert isinstance(
172 chunk, AgenticSystemTurnResponseStreamChunk
173 ), f"Unexpected type {type(chunk)}"
174 event = chunk.event
175 if (
176 event.payload.event_type
177 == AgenticSystemTurnResponseEventType.step_complete.value
178 ):
179 steps.append(event.payload.step_details)
180
181 yield chunk
182
183 assert output_message is not None
184
185 turn = Turn(
186 turn_id=turn_id,
187 session_id=request.session_id,
188 input_messages=request.messages,
189 output_message=output_message,
190 started_at=start_time,
191 completed_at=datetime.now(),
192 steps=steps,
193 )
194 session.turns.append(turn)
195
196 chunk = AgenticSystemTurnResponseStreamChunk(
197 event=AgenticSystemTurnResponseEvent(
198 payload=AgenticSystemTurnResponseTurnCompletePayload(
199 turn=turn,
200 )
201 )
202 )
203 yield chunk
204
205 async def run(
206 self,
207 session: Session,
208 turn_id: str,
209 input_messages: List[Message],
210 attachments: List[Attachment],
211 sampling_params: SamplingParams,
212 stream: bool = False,
213 ) -> AsyncGenerator:
214 # Doing async generators makes downstream code much simpler and everything amenable to
215 # streaming. However, it also makes things complicated here because AsyncGenerators cannot
216 # return a "final value" for the `yield from` statement. we simulate that by yielding a
217 # final boolean (to see whether an exception happened) and then explicitly testing for it.
218
219 async for res in self.run_shields_wrapper(
220 turn_id, input_messages, self.input_shields, "user-input"
221 ):
222 if isinstance(res, bool):
223 return
224 else:
225 yield res
226
227 async for res in self._run(
228 session, turn_id, input_messages, attachments, sampling_params, stream
229 ):
230 if isinstance(res, bool):
231 return
232 elif isinstance(res, CompletionMessage):
233 final_response = res
234 break
235 else:
236 yield res
237
238 assert final_response is not None
239 # for output shields run on the full input and output combination
240 messages = input_messages + [final_response]
241
242 async for res in self.run_shields_wrapper(
243 turn_id, messages, self.output_shields, "assistant-output"
244 ):
245 if isinstance(res, bool):
246 return
247 else:
248 yield res
249
250 yield final_response
251
252 async def run_shields_wrapper(
253 self,
254 turn_id: str,
255 messages: List[Message],
256 shields: List[ShieldDefinition],
257 touchpoint: str,
258 ) -> AsyncGenerator:
259 if len(shields) == 0:
260 return
261
262 step_id = str(uuid.uuid4())
263 try:
264 yield AgenticSystemTurnResponseStreamChunk(
265 event=AgenticSystemTurnResponseEvent(
266 payload=AgenticSystemTurnResponseStepStartPayload(
267 step_type=StepType.shield_call.value,
268 step_id=step_id,
269 metadata=dict(touchpoint=touchpoint),
270 )
271 )
272 )
273 await self.run_shields(messages, shields)
274
275 except SafetyException as e:
276 yield AgenticSystemTurnResponseStreamChunk(
277 event=AgenticSystemTurnResponseEvent(
278 payload=AgenticSystemTurnResponseStepCompletePayload(
279 step_type=StepType.shield_call.value,
280 step_details=ShieldCallStep(
281 step_id=step_id,
282 turn_id=turn_id,
283 response=e.response,
284 ),
285 )
286 )
287 )
288
289 yield CompletionMessage(
290 content=str(e),
291 stop_reason=StopReason.end_of_turn,
292 )
293 yield False
294
295 yield AgenticSystemTurnResponseStreamChunk(
296 event=AgenticSystemTurnResponseEvent(
297 payload=AgenticSystemTurnResponseStepCompletePayload(
298 step_type=StepType.shield_call.value,
299 step_details=ShieldCallStep(
300 step_id=step_id,
301 turn_id=turn_id,
302 response=ShieldResponse(
303 # TODO: fix this, give each shield a shield type method and
304 # fire one event for each shield run
305 shield_type=BuiltinShield.llama_guard,
306 is_violation=False,
307 ),
308 ),
309 )
310 )
311 )
312
313 async def _run(
314 self,
315 session: Session,
316 turn_id: str,
317 input_messages: List[Message],
318 attachments: List[Attachment],
319 sampling_params: SamplingParams,
320 stream: bool = False,
321 ) -> AsyncGenerator:
322 enabled_tools = set(t.type for t in self.agent_config.tools)
323 need_rag_context = await self._should_retrieve_context(
324 input_messages, attachments
325 )
326 if need_rag_context:
327 step_id = str(uuid.uuid4())
328 yield AgenticSystemTurnResponseStreamChunk(
329 event=AgenticSystemTurnResponseEvent(
330 payload=AgenticSystemTurnResponseStepStartPayload(
331 step_type=StepType.memory_retrieval.value,
332 step_id=step_id,
333 )
334 )
335 )
336
337 # TODO: find older context from the session and either replace it
338 # or append with a sliding window. this is really a very simplistic implementation
339 rag_context, bank_ids = await self._retrieve_context(
340 session, input_messages, attachments
341 )
342
343 step_id = str(uuid.uuid4())
344 yield AgenticSystemTurnResponseStreamChunk(
345 event=AgenticSystemTurnResponseEvent(
346 payload=AgenticSystemTurnResponseStepCompletePayload(
347 step_type=StepType.memory_retrieval.value,
348 step_id=step_id,
349 step_details=MemoryRetrievalStep(
350 turn_id=turn_id,
351 step_id=step_id,
352 memory_bank_ids=bank_ids,
353 inserted_context=rag_context or "",
354 ),
355 )
356 )
357 )
358
359 if rag_context:
360 last_message = input_messages[-1]
361 last_message.context = "\n".join(rag_context)
362
363 elif attachments and AgenticSystemTool.code_interpreter.value in enabled_tools:
364 urls = [a.content for a in attachments if isinstance(a.content, URL)]
365 msg = await attachment_message(self.tempdir, urls)
366 input_messages.append(msg)
367
368 output_attachments = []
369
370 n_iter = 0
371 while True:
372 msg = input_messages[-1]
373 if msg.role == Role.user.value:
374 color = "blue"
375 elif msg.role == Role.ipython.value:
376 color = "yellow"
377 else:
378 color = None
379 cprint(f"{str(msg)}", color=color)
380
381 step_id = str(uuid.uuid4())
382 yield AgenticSystemTurnResponseStreamChunk(
383 event=AgenticSystemTurnResponseEvent(
384 payload=AgenticSystemTurnResponseStepStartPayload(
385 step_type=StepType.inference.value,
386 step_id=step_id,
387 )
388 )
389 )
390
391 req = ChatCompletionRequest(
392 model=self.agent_config.model,
393 messages=input_messages,
394 tools=self._get_tools(),
395 tool_prompt_format=self.agent_config.tool_prompt_format,
396 stream=True,
397 sampling_params=sampling_params,
398 )
399
400 tool_calls = []
401 content = ""
402 stop_reason = None
403 async for chunk in self.inference_api.chat_completion(req):
404 event = chunk.event
405 if event.event_type == ChatCompletionResponseEventType.start:
406 continue
407 elif event.event_type == ChatCompletionResponseEventType.complete:
408 stop_reason = StopReason.end_of_turn
409 continue
410
411 delta = event.delta
412 if isinstance(delta, ToolCallDelta):
413 if delta.parse_status == ToolCallParseStatus.success:
414 tool_calls.append(delta.content)
415
416 if stream:
417 yield AgenticSystemTurnResponseStreamChunk(
418 event=AgenticSystemTurnResponseEvent(
419 payload=AgenticSystemTurnResponseStepProgressPayload(
420 step_type=StepType.inference.value,
421 step_id=step_id,
422 model_response_text_delta="",
423 tool_call_delta=delta,
424 )
425 )
426 )
427
428 elif isinstance(delta, str):
429 content += delta
430 if stream and event.stop_reason is None:
431 yield AgenticSystemTurnResponseStreamChunk(
432 event=AgenticSystemTurnResponseEvent(
433 payload=AgenticSystemTurnResponseStepProgressPayload(
434 step_type=StepType.inference.value,
435 step_id=step_id,
436 model_response_text_delta=event.delta,
437 )
438 )
439 )
440 else:
441 raise ValueError(f"Unexpected delta type {type(delta)}")
442
443 if event.stop_reason is not None:
444 stop_reason = event.stop_reason
445
446 stop_reason = stop_reason or StopReason.out_of_tokens
447 message = CompletionMessage(
448 content=content,
449 stop_reason=stop_reason,
450 tool_calls=tool_calls,
451 )
452
453 yield AgenticSystemTurnResponseStreamChunk(
454 event=AgenticSystemTurnResponseEvent(
455 payload=AgenticSystemTurnResponseStepCompletePayload(
456 step_type=StepType.inference.value,
457 step_id=step_id,
458 step_details=InferenceStep(
459 # somewhere deep, we are re-assigning message or closing over some
460 # variable which causes message to mutate later on. fix with a
461 # `deepcopy` for now, but this is symptomatic of a deeper issue.
462 step_id=step_id,
463 turn_id=turn_id,
464 model_response=copy.deepcopy(message),
465 ),
466 )
467 )
468 )
469
470 if n_iter >= self.max_infer_iters:
471 cprint("Done with MAX iterations, exiting.")
472 yield message
473 break
474
475 if stop_reason == StopReason.out_of_tokens:
476 cprint("Out of token budget, exiting.")
477 yield message
478 break
479
480 if len(message.tool_calls) == 0:
481 if stop_reason == StopReason.end_of_turn:
482 # TODO: UPDATE RETURN TYPE TO SEND A TUPLE OF (MESSAGE, ATTACHMENTS)
483 if len(output_attachments) > 0:
484 if isinstance(message.content, list):
485 message.content += attachments
486 else:
487 message.content = [message.content] + attachments
488 yield message
489 else:
490 cprint(f"Partial message: {str(message)}", color="green")
491 input_messages = input_messages + [message]
492 else:
493 cprint(f"{str(message)}", color="green")
494 try:
495 tool_call = message.tool_calls[0]
496
497 name = tool_call.tool_name
498 if not isinstance(name, BuiltinTool):
499 yield message
500 return
501
502 step_id = str(uuid.uuid4())
503 yield AgenticSystemTurnResponseStreamChunk(
504 event=AgenticSystemTurnResponseEvent(
505 payload=AgenticSystemTurnResponseStepStartPayload(
506 step_type=StepType.tool_execution.value,
507 step_id=step_id,
508 )
509 )
510 )
511 yield AgenticSystemTurnResponseStreamChunk(
512 event=AgenticSystemTurnResponseEvent(
513 payload=AgenticSystemTurnResponseStepProgressPayload(
514 step_type=StepType.tool_execution.value,
515 step_id=step_id,
516 tool_call=tool_call,
517 )
518 )
519 )
520
521 result_messages = await execute_tool_call_maybe(
522 self.tools_dict,
523 [message],
524 )
525 assert (
526 len(result_messages) == 1
527 ), "Currently not supporting multiple messages"
528 result_message = result_messages[0]
529
530 yield AgenticSystemTurnResponseStreamChunk(
531 event=AgenticSystemTurnResponseEvent(
532 payload=AgenticSystemTurnResponseStepCompletePayload(
533 step_type=StepType.tool_execution.value,
534 step_details=ToolExecutionStep(
535 step_id=step_id,
536 turn_id=turn_id,
537 tool_calls=[tool_call],
538 tool_responses=[
539 ToolResponse(
540 call_id=result_message.call_id,
541 tool_name=result_message.tool_name,
542 content=result_message.content,
543 )
544 ],
545 ),
546 )
547 )
548 )
549
550 # TODO: add tool-input touchpoint and a "start" event for this step also
551 # but that needs a lot more refactoring of Tool code potentially
552 yield AgenticSystemTurnResponseStreamChunk(
553 event=AgenticSystemTurnResponseEvent(
554 payload=AgenticSystemTurnResponseStepCompletePayload(
555 step_type=StepType.shield_call.value,
556 step_details=ShieldCallStep(
557 step_id=str(uuid.uuid4()),
558 turn_id=turn_id,
559 response=ShieldResponse(
560 # TODO: fix this, give each shield a shield type method and
561 # fire one event for each shield run
562 shield_type=BuiltinShield.llama_guard,
563 is_violation=False,
564 ),
565 ),
566 )
567 )
568 )
569
570 except SafetyException as e:
571 yield AgenticSystemTurnResponseStreamChunk(
572 event=AgenticSystemTurnResponseEvent(
573 payload=AgenticSystemTurnResponseStepCompletePayload(
574 step_type=StepType.shield_call.value,
575 step_details=ShieldCallStep(
576 step_id=str(uuid.uuid4()),
577 turn_id=turn_id,
578 response=e.response,
579 ),
580 )
581 )
582 )
583
584 yield CompletionMessage(
585 content=str(e),
586 stop_reason=StopReason.end_of_turn,
587 )
588 yield False
589 return
590
591 if out_attachment := interpret_content_as_attachment(
592 result_message.content
593 ):
594 # NOTE: when we push this message back to the model, the model may ignore the
595 # attached file path etc. since the model is trained to only provide a user message
596 # with the summary. We keep all generated attachments and then attach them to final message
597 output_attachments.append(out_attachment)
598
599 input_messages = input_messages + [message, result_message]
600
601 n_iter += 1
602
603 async def _ensure_memory_bank(self, session: Session) -> MemoryBank:
604 if session.memory_bank is None:
605 session.memory_bank = await self.memory_api.create_memory_bank(
606 name=f"memory_bank_{session.session_id}",
607 config=VectorMemoryBankConfig(
608 embedding_model="sentence-transformer/all-MiniLM-L6-v2",
609 chunk_size_in_tokens=512,
610 ),
611 )
612
613 return session.memory_bank
614
615 async def _should_retrieve_context(
616 self, messages: List[Message], attachments: List[Attachment]
617 ) -> bool:
618 enabled_tools = set(t.type for t in self.agent_config.tools)
619 if attachments:
620 if (
621 AgenticSystemTool.code_interpreter.value in enabled_tools
622 and self.agent_config.tool_choice == ToolChoice.required
623 ):
624 return False
625 else:
626 return True
627
628 return AgenticSystemTool.memory.value in enabled_tools
629
630 def _memory_tool_definition(self) -> Optional[MemoryToolDefinition]:
631 for t in self.agent_config.tools:
632 if t.type == AgenticSystemTool.memory.value:
633 return t
634
635 return None
636
637 async def _retrieve_context(
638 self, session: Session, messages: List[Message], attachments: List[Attachment]
639 ) -> Tuple[List[str], List[int]]: # (rag_context, bank_ids)
640 bank_ids = []
641
642 memory = self._memory_tool_definition()
643 assert memory is not None, "Memory tool not configured"
644 bank_ids.extend(c.bank_id for c in memory.memory_bank_configs)
645
646 if attachments:
647 bank = await self._ensure_memory_bank(session)
648 bank_ids.append(bank.bank_id)
649
650 documents = [
651 MemoryBankDocument(
652 document_id=str(uuid.uuid4()),
653 content=a.content,
654 mime_type=a.mime_type,
655 metadata={},
656 )
657 for a in attachments
658 ]
659 await self.memory_api.insert_documents(bank.bank_id, documents)
660 elif session.memory_bank:
661 bank_ids.append(session.memory_bank.bank_id)
662
663 if not bank_ids:
664 # this can happen if the per-session memory bank is not yet populated
665 # (i.e., no prior turns uploaded an Attachment)
666 return None, []
667
668 query = await generate_rag_query(
669 memory.query_generator_config, messages, inference_api=self.inference_api
670 )
671 tasks = [
672 self.memory_api.query_documents(
673 bank_id=bank_id,
674 query=query,
675 params={
676 "max_chunks": 5,
677 },
678 )
679 for bank_id in bank_ids
680 ]
681 results: List[QueryDocumentsResponse] = await asyncio.gather(*tasks)
682 chunks = [c for r in results for c in r.chunks]
683 scores = [s for r in results for s in r.scores]
684
685 # sort by score
686 chunks, scores = zip(
687 *sorted(zip(chunks, scores), key=lambda x: x[1], reverse=True)
688 )
689 if not chunks:
690 return None, bank_ids
691
692 tokens = 0
693 picked = []
694 for c in chunks[: memory.max_chunks]:
695 tokens += c.token_count
696 if tokens > memory.max_tokens_in_context:
697 cprint(
698 f"Using {len(picked)} chunks; reached max tokens in context: {tokens}",
699 "red",
700 )
701 break
702 picked.append(f"id:{c.document_id}; content:{c.content}")
703
704 return [
705 "Here are the retrieved documents for relevant context:\n=== START-RETRIEVED-CONTEXT ===\n",
706 *picked,
707 "\n=== END-RETRIEVED-CONTEXT ===\n",
708 ], bank_ids
709
710 def _get_tools(self) -> List[ToolDefinition]:
711 ret = []
712 for t in self.agent_config.tools:
713 if isinstance(t, SearchToolDefinition):
714 ret.append(ToolDefinition(tool_name=BuiltinTool.brave_search))
715 elif isinstance(t, WolframAlphaToolDefinition):
716 ret.append(ToolDefinition(tool_name=BuiltinTool.wolfram_alpha))
717 elif isinstance(t, PhotogenToolDefinition):
718 ret.append(ToolDefinition(tool_name=BuiltinTool.photogen))
719 elif isinstance(t, CodeInterpreterToolDefinition):
720 ret.append(ToolDefinition(tool_name=BuiltinTool.code_interpreter))
721 elif isinstance(t, FunctionCallToolDefinition):
722 ret.append(
723 ToolDefinition(
724 tool_name=t.function_name,
725 description=t.description,
726 parameters=t.parameters,
727 )
728 )
729 return ret
730
731
732async def attachment_message(tempdir: str, urls: List[URL]) -> ToolResponseMessage:
733 content = []
734
735 for url in urls:
736 uri = url.uri
737 if uri.startswith("file://"):
738 filepath = uri[len("file://") :]
739 elif uri.startswith("http"):
740 path = urlparse(uri).path
741 basename = os.path.basename(path)
742 filepath = f"{tempdir}/{make_random_string() + basename}"
743 print(f"Downloading {url} -> {filepath}")
744
745 async with httpx.AsyncClient() as client:
746 r = await client.get(uri)
747 resp = r.text
748 with open(filepath, "w") as fp:
749 fp.write(resp)
750 else:
751 raise ValueError(f"Unsupported URL {url}")
752
753 content.append(f'# There is a file accessible to you at "{filepath}"\n')
754
755 return ToolResponseMessage(
756 call_id="",
757 tool_name=BuiltinTool.code_interpreter,
758 content=content,
759 )
760
761
762async def execute_tool_call_maybe(
763 tools_dict: Dict[str, BaseTool], messages: List[CompletionMessage]
764) -> List[ToolResponseMessage]:
765 # While Tools.run interface takes a list of messages,
766 # All tools currently only run on a single message
767 # When this changes, we can drop this assert
768 # Whether to call tools on each message and aggregate
769 # or aggregate and call tool once, reamins to be seen.
770 assert len(messages) == 1, "Expected single message"
771 message = messages[0]
772
773 tool_call = message.tool_calls[0]
774 name = tool_call.tool_name
775 assert isinstance(name, BuiltinTool)
776
777 name = name.value
778
779 assert name in tools_dict, f"Tool {name} not found"
780 tool = tools_dict[name]
781 result_messages = await tool.run(messages)
782 return result_messages
783
784
785def print_dialog(messages: List[Message]):
786 for i, m in enumerate(messages):
787 if m.role == Role.user.value:
788 color = "red"
789 elif m.role == Role.assistant.value:
790 color = "white"
791 elif m.role == Role.ipython.value:
792 color = "yellow"
793 elif m.role == Role.system.value:
794 color = "green"
795 else:
796 color = "white"
797
798 s = str(m)
799 cprint(f"{i} ::: {s[:100]}...", color=color)