# TOOL USE TEST import ollama system_prompt = """You have access to a list. If you want to retrieve the content in the list, output EXACTLY: $DATABASE$ Do not output anything else. The result will be returned in a string starting with [DATABASE]. """ context_prompt = None # if context exists user_input = "Check the list and tell me what is in there" combined_system = f"{system_prompt}\n\nContext: {context_prompt}" stream = ollama.chat( model='llama3.2', messages=[ {'role': 'system', 'content': combined_system}, {'role': 'user', 'content': user_input}, ], stream=True, ) # Accumulate chunks into a variable full_response = "" for chunk in stream: content = chunk['message']['content'] print(content, end='', flush=True) full_response += content if "$DATABASE$" in full_response: # DATABASE LOGIC TODO pass print() # newline after streaming print(full_response) # your complete output