You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from ollama import chat
import sys
# Check if a question is passed as an argument
if len(sys.argv) < 2:
print("Please provide a question as an argument.")
sys.exit(1)
# Get the question from command-line arguments
question=sys.argv[1]
# Set up the chat with the provided question
stream=chat(
model='crewai-deepseek-r1:7b',
messages=[{'role': 'user', 'content': question}],
stream=True,
)
reasoning_content=""
content=""
# Process the stream and handle the content
for chunk in stream:
if chunk and 'message' in chunk and chunk['message'].content:
# Get the content from the chunk
chunk_content=chunk['message'].content
# Print the content immediately, without newline
sys.stdout.write(chunk_content)
sys.stdout.flush()
# Store in appropriate buffer
if chunk_content.startswith('<think>'):
in_thinking=True
elif chunk_content.startswith('</think>'):
in_thinking=False
else:
if 'in_thinking' in locals() and in_thinking:
reasoning_content += chunk_content
else:
content += chunk_content
# Output the reasoning and final answer
print("\n\nReasoning:", reasoning_content)
print("\nFinal Answer:", content)
The text was updated successfully, but these errors were encountered:
I updated it
The text was updated successfully, but these errors were encountered: