ElGraph.Test.ScriptedLLM (ElGraph v0.3.0)

Copy Markdown View Source

테스트용 스크립트 LLM (테스트 키트, SPEC §7).

응답 목록을 순서대로 반환하고 받은 호출(messages/opts)을 기록한다.

{:ok, pid} = ScriptedLLM.start_link([LLM.assistant("hi")])
graph = ElGraph.Presets.react({ScriptedLLM, pid}, tools)
# ... 이후 ScriptedLLM.calls(pid)로 LLM이 받은 입력을 검증

스크립트 원소: assistant 메시지 맵(자동으로 {:ok, response} 포장) 또는 {:ok, response} / {:error, reason} 원형. 소진되면 {:error, :script_exhausted}.

Summary

Functions

지금까지 받은 호출 목록(%{messages:, opts:})을 순서대로 반환한다.

chat/3의 스트리밍 변형. 스크립트 원소가 {:deltas, parts, message}면 각 part를 on_delta로 차례로 방출하고, 일반 assistant 메시지면 content 전체를 토큰 1개로 방출한다.

Functions

calls(pid)

@spec calls(pid()) :: [%{messages: [map()], opts: keyword()}]

지금까지 받은 호출 목록(%{messages:, opts:})을 순서대로 반환한다.

start_link(script)

@spec start_link([term()]) :: Agent.on_start()

stream_chat(pid, messages, opts)

chat/3의 스트리밍 변형. 스크립트 원소가 {:deltas, parts, message}면 각 part를 on_delta로 차례로 방출하고, 일반 assistant 메시지면 content 전체를 토큰 1개로 방출한다.