So, i recently started using the Assistant API, and i really dont know much as of yet. I wanted to try using it as a normal GPT, but when i get the response, it seems t add a sort of summary of the request before the actual response:
user > Text(annotations=[], value='Hello')Hello Jane Doe! I'm just a computer program, so I don't have feelings, but I'm here and ready to help you. How can I assist you today?
why does it add that, and how do i remove it?
this is the code:
from openai import OpenAI, AssistantEventHandler
# Initialize the OpenAI client
client = OpenAI(api_key="")
# Define the event handler class
class EventHandler(AssistantEventHandler):
def on_text_created(self, text) -> None:
print(f"\nuser > {text}", end="", flush=True)
def on_text_delta(self, delta, snapshot):
print(delta.value, end="", flush=True)
def on_tool_call_created(self, tool_call):
print(f"\nassistant > {tool_call.type}\n", flush=True)
def on_tool_call_delta(self, delta, snapshot):
if delta.type == 'code_interpreter':
if delta.code_interpreter.input:
print(delta.code_interpreter.input, end="", flush=True)
if delta.code_interpreter.outputs:
print(f"\n\noutput >", flush=True)
for output in delta.code_interpreter.outputs:
if output.type == "logs":
print(f"\n{output.logs}", flush=True)
# Create the Assistant
assistant = client.beta.assistants.create(
name="Virtual Assistant",
instructions="You are a lifelike virtual assistant.",
model="gpt-4-turbo",
)
# Create the Thread
thread = client.beta.threads.create()
# Loop to accept user input and send messages
while True:
user_input = input("You > ")
# Add user message to the Thread
message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content=user_input
)
# Create and stream a Run
with client.beta.threads.runs.stream(
thread_id=thread.id,
assistant_id=assistant.id,
instructions="Please address the user as Jane Doe. The user has a premium account.",
event_handler=EventHandler(),
) as stream:
stream.until_done()