at least this kind of works
This commit is contained in:
36
archive/tool_test.py
Normal file
36
archive/tool_test.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# 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
|
||||
Reference in New Issue
Block a user