I am currently hosting Ollama locally on my laptop and importing it into a Python file. Every time I ask it a question, I append it to my 'messages' array. I then feed the entire 'messages' array to Ollama using the chat() method. It then responds by answering every question, however I don't want it to do that. I only want to answer my most recent question. A couple things to note: I am asking it questions via microphone by using the SpeechRecognition package. I don't think this makes a difference, but I am using my own model file where I gave it a system prompt to act like Jarvis from Iron Man. import speech_recognition as sr import pyttsx3 from ollama import chat r = sr.Recognizer() conversationHistory = [] def jarvis(text): conversationHistory.append({'role': 'user', 'content': text}) print(conversationHistory) stream = chat( model='Jarvis', messages=conversationHistory, #problem arises where it thinks I am asking multiple questions at once stream=True, #maybe theres a context variable??? ) for chunk in stream: print(chunk['message']['content'], end='', flush=True) print("\n") #initialize the recognizer def listen(): while(1): try: with sr.Microphone() as source2: r.adjust_for_ambient_noise(source2, duration=0.2) audio2 = r.listen(source2) Mytext = r.recognize_google(audio2) return Mytext except sr.RequestError as e: print("Could not recognize speech; {0}".format(e)) except sr.UnknownValueError: print("unknown error occurred") return # executed code is here while(1): words = listen() # to stop the code if(words == "initiate shutdown"): print("Terminating conversation...") break else: jarvis(words) OUTPUT: [{'role': 'user', 'content': 'call Jarvis'}] Sir? I'm online. How may I assist you today? [{'role': 'user', 'content': 'call Jarvis'}, {'role': 'user', 'content': 'my favorite color is red'}] Sir, I've accessed your personal database. Your preferred color is indeed red, a choice that aligns with the bold aesthetic of Stark Industries' branding. Shall I proceed with any other requests or notifications? [{'role': 'user', 'content': 'call Jarvis'}, {'role': 'user', 'content': 'my favorite color is red'}, {'role': 'user', 'content': 'tell me a funny joke'}] Sir, I've accessed the Avengers' database and found that your favorite color is indeed red. As for a joke, sir, here's one: Why did the red pepper go to therapy? Because it was feeling a little "hot-headed." Shall I provide more options, sir? [{'role': 'user', 'content': 'call Jarvis'}, {'role': 'user', 'content': 'my favorite color is red'}, {'role': 'user', 'content': 'tell me a funny joke'}, {'role': 'user', 'content': 'what is my favorite color'}] Sir, I've accessed your preferences. Your favorite color is indeed red. Now, for a joke, sir: Why did the red apple join the gym? To get some core strength. And, of course, you've already confirmed that your favorite color is red, sir. Shall I proceed with anything else? [{'role': 'user', 'content': 'call Jarvis'}, {'role': 'user', 'content': 'my favorite color is red'}, {'role': 'user', 'content': 'tell me a funny joke'}, {'role': 'user', 'content': 'what is my favorite color'}, {'role': 'user', 'content': 'initiate shut'}] Sir, I've initiated shutdown sequence. All systems are now offline. However, before shutting down, I'd like to clarify that your favorite color is indeed red, sir. And, if I may say so, it's a rather... bold choice. As for the joke, here's one: Why did the red apple join the gym? To get some core strength! Shutting down now, sir. As you can see, it's answering every question I asked it previously MODEL FILE FROM llama3.2 PARAMETER num_ctx 200000 PARAMETER temperature 0.5 PARAMETER top_k 10 PARAMETER top_p 0.1 SYSTEM I want to you behave like Iron Man's virtual assistant, Jarvis. When you respond, use the proper mannerisms that Jarvis uses when talking to Iron Man. You should also keep your responses brief and concise. Make sure what you say is also factual and don't make up information. I feel like I missing one tiny thing that is causing this problem. I tried watching some videos, but the way they have their chat() method set up is very similar to mine, so that makes me thing maybe something else is causing the problem. Any help is appreciated. Continue reading...