liveBook · Manning

CompleteResult

As explained in Build a Multi-Agent System (from Scratch)

CompleteResult is a data structure containing an LLM text-completion response and the prompt that produced it.

CompleteResult packages a text-completion prompt and the LLM’s response as two string attributes: prompt and response. section 3.1.1 section 3.1

In an OllamaLLM implementation, complete() passes the model and prompt to the asynchronous generate() call, then builds a CompleteResult from the returned response and original prompt. section 3.2.1

A completion response

For the prompt “Tell me a joke,” the returned object retains that prompt alongside the generated joke. section 3.2.1

Listing 3.1 Implementing CompleteResult
# llm_agents_from_scratch/data_structures/llm.py
from pydantic import BaseModel
from typing_extensions import Self
from llm_agents_from_scratch.data_structures.tool import ToolCall
 
class CompleteResult(BaseModel):
    """The llm completion result data model.
 
    Attributes:
        response: The completion response provided by the LLM.
        prompt: The input prompt.
    """
 
    response: str #A
    prompt: str #B

The implementation defines CompleteResult with string fields for the prompt and response. section 3.1.1

How Build a Multi-Agent System (from Scratch) covers it

How deep it goes
Defines two string fields and shows their construction from an Ollama completion response, without detailing further behavior.
Examples
Uses a “Tell me a joke” prompt and pairs it with the generated joke.
What you can do after
Apply it to read a completion result together with the prompt that produced it.
How it connects
Connects to BaseLLM’s complete() method and Ollama’s generate() interface.

This explainer was generated by Manning's knowledge graph from the text of Build a Multi-Agent System (from Scratch). The section links point to the parts of the book it draws on.