import os
from parallel import Parallel
from parallel.types import TaskSpecParam, TextSchemaParam
client = Parallel(api_key=os.environ["PARALLEL_API_KEY"])
# Turn 1: Initial question
run1 = client.task_run.create(
input="Which country won the most Winter Olympics gold medals in 2026?",
processor="lite",
task_spec=TaskSpecParam(output_schema=TextSchemaParam()),
)
result1 = client.task_run.result(run1.run_id, api_timeout=3600)
print(f"Turn 1: {result1.output.content}")
# Turn 2: Follow-up — "they" refers to the country from Turn 1
run2 = client.task_run.create(
input="How many medals did they win?",
processor="lite",
previous_interaction_id=run1.interaction_id,
task_spec=TaskSpecParam(output_schema=TextSchemaParam()),
)
result2 = client.task_run.result(run2.run_id, api_timeout=3600)
print(f"Turn 2: {result2.output.content}")
# Turn 3: Drill deeper — context from both prior turns is available
run3 = client.task_run.create(
input="How does that compare to the second place country?",
processor="lite",
previous_interaction_id=run2.interaction_id,
task_spec=TaskSpecParam(output_schema=TextSchemaParam()),
)
result3 = client.task_run.result(run3.run_id, api_timeout=3600)
print(f"Turn 3: {result3.output.content}")