def data_input():
# It gets the data that the llm need and the user wants to ask question related to this data
def chat_with_data(data):
messages = [
{
"role": "system",
"content": "You are given some data and you have to analyze the data correctly if the user asks for any output then give the output as per the data and user's question otherwise don't give answer."
},
{
"role": "user",
"content": data
}
]
try:
while True:
user_input = input("Enter your message: ")
if user_input.lower() == 'exit':
print("Exiting the chat")
break
messages.append({"role": "user", "content": user_input})
assistant_message = ''
ollama_response = ollama.chat(model='llama3.2', messages=messages, stream=True)
for chunk in ollama_response:
assistant_message += chunk['message']['content']
print(assistant_message, flush=True)
messages.append({"role": "assistant", "content": assistant_message})
except Exception as e:
ic(e)
data = data_input()
chat_with_data(data)
Die LLM folgt der Anweisung und enthält eine lange Zusammenfassung der Daten und das Programm endet, aber das Programm sollte in einer Schleife ausgeführt werden, bis der Benutzer Beenden .>
[code]def data_input(): # It gets the data that the llm need and the user wants to ask question related to this data
def chat_with_data(data):
messages = [ { "role": "system", "content": "You are given some data and you have to analyze the data correctly if the user asks for any output then give the output as per the data and user's question otherwise don't give answer." }, { "role": "user", "content": data } ]
try: while True: user_input = input("Enter your message: ") if user_input.lower() == 'exit': print("Exiting the chat") break
except Exception as e: ic(e) data = data_input() chat_with_data(data) [/code] Die LLM folgt der Anweisung und enthält eine lange Zusammenfassung der Daten und das Programm endet, aber das Programm sollte in einer Schleife ausgeführt werden, bis der Benutzer Beenden .>
Mein Programm stottert nach der 2. Schleife bei den Nutzereingaben der Grade. Es würde eine leere Zeile für einen Wert hinterlassen, den Wert akzeptieren und dies für den Rest der Schleife weiter...
Ich versuche, GetAsync mehrmals in einer nicht blockierenden asynchronen Funktion aufzurufen. Zu meiner Überraschung wird nur der erste Anruf ausgeführt. Da alle Anfragen an dieselbe Domäne gerichtet...