Skip to content

Commit 3d7f1b4

Browse files
committed
add preserve reasoning tokens test
1 parent 1db529f commit 3d7f1b4

File tree

4 files changed

+279
-236
lines changed

4 files changed

+279
-236
lines changed

pydantic_ai_slim/pydantic_ai/models/openrouter.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,9 @@ async def _map_messages(self, messages: list[ModelMessage]) -> list[ChatCompleti
460460

461461
for message, openai_message in zip(messages, openai_messages):
462462
if isinstance(message, ModelResponse):
463-
openai_message['reasoning_details'] = [
463+
if reasoning_details := [
464464
part.into_reasoning_detail() for part in message.parts if isinstance(part, OpenRouterThinkingPart)
465-
]
465+
]:
466+
openai_message['reasoning_details'] = reasoning_details
466467

467468
return openai_messages
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
interactions:
2+
- request:
3+
headers:
4+
accept:
5+
- application/json
6+
accept-encoding:
7+
- gzip, deflate
8+
connection:
9+
- keep-alive
10+
content-length:
11+
- '171'
12+
content-type:
13+
- application/json
14+
host:
15+
- openrouter.ai
16+
method: POST
17+
parsed_body:
18+
messages:
19+
- content: What was the impact of Voltaire's writings on modern french culture? Think about your answer.
20+
role: user
21+
model: openai/o3
22+
stream: false
23+
uri: https://openrouter.ai/api/v1/chat/completions
24+
response:
25+
headers:
26+
access-control-allow-origin:
27+
- '*'
28+
connection:
29+
- keep-alive
30+
content-length:
31+
- '11648'
32+
content-type:
33+
- application/json
34+
permissions-policy:
35+
- payment=(self "https://checkout.stripe.com" "https://connect-js.stripe.com" "https://js.stripe.com" "https://*.js.stripe.com"
36+
"https://hooks.stripe.com")
37+
referrer-policy:
38+
- no-referrer, strict-origin-when-cross-origin
39+
transfer-encoding:
40+
- chunked
41+
vary:
42+
- Accept-Encoding
43+
parsed_body:
44+
choices:
45+
- finish_reason: stop
46+
index: 0
47+
logprobs: null
48+
message:
49+
content: "Impact of Voltaire’s Writings on Modern French Culture\n\n1. A civic vocabulary of liberty and tolerance\n
50+
“Écrasez l’infâme” (Crush the infamous thing) and “Il faut cultiver notre jardin” (We must cultivate our garden)
51+
are still quoted by politicians, journalists and schoolchildren. \n• His defense of minor-religion victims (Calas,
52+
Sirven, La Barre) supplied iconic cases that taught the French the meaning of liberté de conscience. \n• Concepts
53+
central to the Revolution (droits de l’homme, liberté d’expression, égalité civile) were first popularized not
54+
by legal texts but by Voltaire’s pamphlets, letters and contes philosophiques. When the Déclaration des droits
55+
de l’homme et du citoyen (1789) was drafted, deputies openly cited him.\n\n2. Laïcité as a cultural reflex\n
56+
Voltaire’s relentless criticism of clerical power helped dissociate “being French” from “being Catholic.” \n
57+
The 1905 law separating Church and State and the contemporary consensus that religion is a private matter (laïcité)
58+
both rest on an attitude—skepticism toward organized religion—that Voltaire normalized. \n• His nickname l’Athée
59+
de la Sorbonne is still invoked in current debates about headscarves, bio-ethics or blasphemy; op-ed writers speak
60+
of a “Voltaire moment” whenever satire confronts religion (Charlie Hebdo, exhibitions, plays, etc.).\n\n3. Freedom
61+
of speech as a near-sacred principle\n• Voltaire’s legendary—if apocryphal—phrase “I disapprove of what you say,
62+
but I will defend to the death your right to say it,” regularly appears in parliamentary debates, media codes
63+
of ethics and lycée textbooks. \n• Modern defamation and press-liberty laws (1881 and after) were drafted in
64+
a climate steeped in Voltairian skepticism toward censorship.\n\n4. The French taste for “esprit” and satire\n
65+
Candide, Lettres philosophiques, and Dictionnaire philosophique established the short, witty, corrosive form as
66+
a French ideal of prose. \n• Newspapers like Le Canard enchaîné, TV programs such as “Les Guignols,” and graphic
67+
novels by Luz or Jul draw directly on the Voltairian strategy: humor plus moral indignation. \n• Even serious
68+
political commentary in France prizes the mot d’esprit and the reductive punch line—an unwritten stylistic legacy
69+
of Voltaire.\n\n5. Educational canon and cultural literacy\n• Voltaire is compulsory reading in collège and lycée;
70+
exam questions on Candide are perennial. \n• His letters model the “dissertation française” structure (thèse,
71+
antithèse, synthèse) taught nationwide. \n• The annual “Prix Voltaire” (CLEMI) rewards high-school press clubs
72+
that fight censorship, rooting his ideals in adolescent civic training.\n\n6. Influence on French legal and political
73+
institutions\n• The Council of State and the Constitutional Council frequently cite “liberté de penser” (Voltaire,
74+
Traité sur la tolérance) when striking down laws that restrict expression. \n• The secular “Journée de la laïcité,”
75+
celebrated each 9 December, uses excerpts from Traité sur la tolérance in official posters distributed to town
76+
halls.\n\n7. Literary forms and genres\n• The conte philosophique (Candide, Zadig, Micromégas) paved the way for
77+
the modern nouvelle, the hybrid “essay-novel” of Sartre, Camus, Yourcenar, and for the philosophical BD (Sfar’s
78+
Le chat du rabbin). \n• Voltaire’s mixing of reportage, satire, philosophy and fiction prefigured the essayistic
79+
style of today’s “livres de société” by writers such as Houellebecq or Mona Chollet.\n\n8. Language: a living
80+
imprint\n• “Voltairien/Voltairienne” denotes caustic wit; “voltairisme” means sharp, secular critique. \n• His
81+
aphorisms—“Le mieux est l’ennemi du bien,” “Les hommes naissent égaux” —crop up in talk-shows and business seminars
82+
alike.\n\n9. National memory\n• Burial in the Panthéon (1791) created the template for the République’s secular
83+
sanctuaries. \n• Libraries, streets, Lycée Voltaire (Paris, Orléans, Wingles) and the high-speed train “TGV 220
84+
Voltaire” embed him in daily geography. \n• Bicentenary celebrations in 1978 and the 2014 republication of Traité
85+
sur la tolérance (after the Charlie Hebdo attacks) both caused nationwide spikes in sales, proving enduring resonance.\n\n10.
86+
A benchmark for intellectual engagement\n• When French public intellectuals sign manifestos (from Zola’s “J’accuse”
87+
to the recent petitions on climate or pensions), the very act echoes Voltaire’s pamphlet warfare: use the pen
88+
to influence power. \n• The Académie française and PEN International invoke him as the patron saint of the “écrivain
89+
engagé,” a figure central to modern French self-understanding.\n\nIn short, Voltaire’s writings did more than
90+
enrich French literature; they installed reflexes—skepticism, satire, secularism, and the primacy of individual
91+
rights—that continue to structure French laws, education, media tone, and collective identity. Modern France’s
92+
attachment to laïcité, its bawdy political humor, its fierce defense of free expression, and even the way essays
93+
are written in lycée classrooms all carry a Voltairian fingerprint."
94+
reasoning: |-
95+
**Exploring Voltaire's impact**
96+
97+
The user seeks a thoughtful answer about Voltaire's influence on modern French culture. I should summarize his significance by discussing Enlightenment values like liberté and human rights, his role in shaping French Revolution ideas, and his distinctive use of satire. It’s also important to address his anti-clerical stance that encouraged secularism, the promotion of freedom of speech, his legacy in literature, and presence in institutions. Finally, I want to touch on his enduring impact on contemporary discussions around laïcité and cultural narrative.**Structuring the response**
98+
99+
I’m thinking about how to organize the response. I want to start with an introduction that highlights Voltaire as a central figure of the Enlightenment, noting how his writings shaped essential French values like rationality, secularism, and tolerance. After that, I should break the discussion into categories such as political thought, secularism, literature, education, and popular culture. I aim to develop this into a thoughtful answer of around 800 to 1000 words, which will cover all these important aspects.
100+
reasoning_details:
101+
- format: openai-responses-v1
102+
index: 0
103+
summary: |-
104+
**Exploring Voltaire's impact**
105+
106+
The user seeks a thoughtful answer about Voltaire's influence on modern French culture. I should summarize his significance by discussing Enlightenment values like liberté and human rights, his role in shaping French Revolution ideas, and his distinctive use of satire. It’s also important to address his anti-clerical stance that encouraged secularism, the promotion of freedom of speech, his legacy in literature, and presence in institutions. Finally, I want to touch on his enduring impact on contemporary discussions around laïcité and cultural narrative.**Structuring the response**
107+
108+
I’m thinking about how to organize the response. I want to start with an introduction that highlights Voltaire as a central figure of the Enlightenment, noting how his writings shaped essential French values like rationality, secularism, and tolerance. After that, I should break the discussion into categories such as political thought, secularism, literature, education, and popular culture. I aim to develop this into a thoughtful answer of around 800 to 1000 words, which will cover all these important aspects.
109+
type: reasoning.summary
110+
- data: gAAAAABpALH0SrlqG_JSYqQT07H5yKQO7GcmENK5_dmCbkx_o6J5Qg7kZHHNvKynIDieAzknNQwmLf4SB96VU59uasmIK5oOyInBjdpczoYyFEoN8zKWVOolEaCLXSMJfybQb6U_CKEYmPrh_B4CsGDuLzKq7ak6ERC0qFb0vh6ctchIyzWN7MztgnrNt85TReEN3yPmox0suv_kjEc4K5nB6L8C5NOK8ZG4Y3X88feoIvteZq0u2AapGP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KOyH-YSW-J1lu2MJcrk9Z-Sc4d875cZ6B3HxUuJFYQWqMoJ6EkZjNRLpp3XBkFEu5ip4md7yu_FYK7SInsuVI0igMVRx5i9vURIiGnVf60yBfWpqJac0Jp_7V3ftXsdXk3pSE4_GF9QgKM4l9chXH-frUEExxXS13BRQJP1b29-0B7ciG-48c18uSktRItBmXv2_baSiyo7_nvnPWVUgpig9qOuiFFmVPPvFRGTQS6jh8dPZR8PCFnpxuMhVrrJDJUNu8wmVGdVDMZP6kO2PYhNpz35RrX25SSgzjbl6V4uFDb7KQdWQAv-78QkLibUeB7w47I_2G47TGxbUsmnTt_sss1LW0peGrmCMKncgSQKro8rSBQ==
111+
format: openai-responses-v1
112+
id: rs_06569cab051e4c78016900b1eb409c81909668d636e3a424f9
113+
index: 0
114+
type: reasoning.encrypted
115+
refusal: null
116+
role: assistant
117+
native_finish_reason: completed
118+
created: 1761653226
119+
id: gen-1761653226-LJcHbeILDwsw5Tlqupp9
120+
model: openai/o3
121+
object: chat.completion
122+
provider: OpenAI
123+
usage:
124+
completion_tokens: 1431
125+
completion_tokens_details:
126+
reasoning_tokens: 256
127+
prompt_tokens: 25
128+
total_tokens: 1456
129+
status:
130+
code: 200
131+
message: OK
132+
version: 1

0 commit comments

Comments
 (0)