Liking cljdoc? Tell your friends :D

im.ttalk.agent.provider.wire.openai

中立消息 ↔ OpenAI wire 格式 转换

neutral->wire: 中立消息列表 → OpenAI chat messages response->neutral: OpenAI 响应 → 中立 assistant 消息

OpenAI wire 形态:

  • system/user: {:role "system"/"user" :content "..."}
  • assistant: {:role "assistant" :content "..."}
  • assistant+tools: {:role "assistant" :content nil :tool_calls [{:id .. :type "function" :function {:name .. :arguments "{json}"}}]}
  • tool result: {:role "tool" :tool_call_id .. :content "..."}

多模态:user 消息的 :content 为中立部件向量(见 model/content)时, 按 media type 顶层类别翻译——image/* → image_url(内联走 data URI)、 audio/* → input_audio(仅 wav/mp3,OpenAI 不收 URL 音频)、 application/pdf → file.file_data。其余类型不静默丢,抛 :validation-error。 :type 为字符串的元素视为 OpenAI 原生块,原样透传。

中立消息 ↔ OpenAI wire 格式 转换

neutral->wire: 中立消息列表 → OpenAI chat messages
response->neutral: OpenAI 响应 → 中立 assistant 消息

OpenAI wire 形态:
- system/user:  {:role "system"/"user" :content "..."}
- assistant:    {:role "assistant" :content "..."}
- assistant+tools: {:role "assistant" :content nil
                    :tool_calls [{:id .. :type "function"
                                  :function {:name .. :arguments "{json}"}}]}
- tool result:  {:role "tool" :tool_call_id .. :content "..."}

**多模态**:user 消息的 :content 为中立部件向量(见 model/content)时,
按 media type 顶层类别翻译——image/* → image_url(内联走 data URI)、
audio/* → input_audio(仅 wav/mp3,OpenAI 不收 URL 音频)、
application/pdf → file.file_data。其余类型不静默丢,抛 :validation-error。
:type 为**字符串**的元素视为 OpenAI 原生块,原样透传。
raw docstring

neutral->wireclj

(neutral->wire neutral-msgs)

把中立消息列表转成 OpenAI chat messages 列表。

返回:{:messages [wire-msg ...]} (system 作为普通消息内联,故无独立 :system 字段)

把中立消息列表转成 OpenAI chat messages 列表。

返回:{:messages [wire-msg ...]}
(system 作为普通消息内联,故无独立 :system 字段)
sourceraw docstring

response->neutralclj

(response->neutral response)

OpenAI 响应 → 中立 assistant 消息。 含 tool_calls 则返回 assistant-tool-calls,否则纯文本 assistant。

OpenAI 响应 → 中立 assistant 消息。
含 tool_calls 则返回 assistant-tool-calls,否则纯文本 assistant。
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close