Files
ISAIP-1/tool_test_func.py
2026-04-22 09:50:49 -04:00

47 lines
1.3 KiB
Python

# TOOL USE TEST
import ollama
def llm_converse(system_prompt, context_prompt, user_input):
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
return full_response
def get_file_content(filename):
with open(filename, "r") as files:
bruh = files.read()
return bruh
system_prompts = """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_prompts = None # if context exists
user_inputs = "Check the list and tell me what is in there"
prompt1 = llm_converse(system_prompts, context_prompts, user_inputs)
if "$DATABASE$" in prompt1:
# DATABASE LOGIC TODO
pass
print() # newline after streaming
print(full_response) # your complete output