Skip to content

Conversation

felixarntz
Copy link
Member

@felixarntz felixarntz commented Jul 10, 2025

This PR simply updates the branch for #2 with class diagrams that encompass the fluent API (since I had separately explored them in its own branch prior to today's discussion).

A quick review shall be sufficient here, as all of this will still have to undergo a more comprehensive review as part of #2.

After merging this into #2, a good next step would be to update the code examples, ideally with a side-by-side comparison of both consumer / implementor facing APIs (fluent API and traditional method call API).

…anize overview diagrams for easier understanding.
@felixarntz felixarntz requested a review from JasonTheAdams July 10, 2025 20:18
@felixarntz felixarntz added the [Type] Developer Documentation Documentation for developers label Jul 10, 2025
+withImageFile(File $file) self
+withAudioFile(File $file) self
+withVideoFile(File $file) self
+withFunctionResponse(FunctionResponse $functionResponse) self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It adds a function response as a message part, typically this needs to be used in a user message, in response to the LLM returning a function call message part.

Technically similar to the other methods here that add message parts.

+generateEmbeddings() Embedding[]
}

class MessageBuilder {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a message as opposed to a prompt?

Copy link
Member Author

@felixarntz felixarntz Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Message is the main data transfer object to communicate between the user and the LLM. There are three types of Messages: user, model, and system messages.

A "prompt" in this SDK is not really an actual thing. It's a higher-level overarching term for what could be a single user message, or many user and model messages (in case of history), or a user message with a bunch of configuration arguments.

I used the name PromptBuilder to relate to that overarching term, but we could go with a different name. Maybe something like AiRequestBuilder could be used instead.

The reason there's a MessageBuilder in addition to the (what is called now) PromptBuilder is to easily be able to create Message objects, which is mostly relevant when using PromptBuilder::withHistory().

+message(?string $text) MessageBuilder$
}

class PromptBuilder {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will also have a bunch of getter methods so the object consumer can do it's thing, unless you're planning on having a separate DTO that goes the model?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the model will receive this in a different way, see the detailed class diagram. For the most part, it's 1 or more Message objects, and an AiModelConfig object.

@JasonTheAdams
Copy link
Member

Excited to see this! Left a few thoughts and questions, @felixarntz!

@felixarntz felixarntz requested a review from JasonTheAdams July 11, 2025 00:20
…nterfaces to use `TextToSpeechConversion`.
Copy link
Member

@JasonTheAdams JasonTheAdams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! Great work! 🎉

@felixarntz felixarntz merged commit fe53935 into add/architecture-definition Jul 11, 2025
@felixarntz felixarntz deleted the architecture-revision/fluent-api branch August 14, 2025 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants