agent: |
cCPPCMvGtekkMjI0Ri6pGet idle CPU percentage
Get idle CPU percentage
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.
The top output above contains what percentage is idle CPU. Split the output and get the part that contains 'id'. Then extract the number.
inputs
outputs
lines = topoutput.split('\n')
line = [x for x in lines if 'Cpu' in x][0]
parts = line.split(',')
parts[0] = ' '.join(parts[0].split()[1:])
idle_part = [x for x in parts if 'id' in x]
idle_cpu = float(idle_part[0].split()[0])
print("Idle CPU: ", idle_cpu)
labels = [x.split()[1] for x in parts]
values = [x.split()[0] for x in parts]
context.plot.xlabel = ""
context.plot.ylabel = ""
context.plot.title = "CPU usage"
context.plot.add_trace(name="CPU usage", xpts=labels, ypts=values, tracetype="pie")
copied