Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize agents and chains #56

Merged
merged 5 commits into from
May 12, 2023
Merged

Reorganize agents and chains #56

merged 5 commits into from
May 12, 2023

Conversation

serras
Copy link
Contributor

@serras serras commented May 12, 2023

This PR moves into the direction of a simpler interface, but with the nice composition abilities from the DSL. In particular there are no more chains/agents/..., everything is an Agent, which should provide a function of the form.

suspend fun Raise<AIError>.call(input: Input): Output

I've re-implemented the prompt functionality from AIScope into two new Agents, namely LLMAgent and DeserializerLLMAgent (which just wraps the former with deserialization capabilities). As a result, the AIScope is much more contained: it only calls other agents, but doesn't perform the calls to OpenAI itself. Note that barely any change was required in the examples, but we've gained the ability to use LLMAgent as an agent in context.

A side effect is that the entire chains package is gone: instead of creating a SequenceChain, the idea is that developers will manipulate the passing of information between agents themselves.

@raulraja @nomisRev @realdavidvega any feedback is welcome :)

@serras serras requested a review from raulraja May 12, 2023 12:22
@serras serras self-assigned this May 12, 2023
Copy link
Contributor

@franciscodr franciscodr left a comment

Choose a reason for hiding this comment

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

Oustanding job, @serras. I have only left one comment

Comment on lines 17 to 33
"LLMAgent should return a prediction with just the output" {
val template = "Tell me {foo}."
either {
val promptTemplate = PromptTemplate(template, listOf("foo"))
val chain = LLMAgent(testLLM, promptTemplate, model)
with (chain) { call(mapOf("foo" to "a joke")) }
} shouldBeRight listOf("I'm not good at jokes")
}

"LLMAgent should return a prediction with both output and inputs" {
val template = "Tell me {foo}."
either {
val prompt = PromptTemplate(template, listOf("foo"))
val chain = LLMAgent(testLLM, prompt, model)
with (chain) { call(mapOf("foo" to "a joke")) }
} shouldBeRight listOf("I'm not good at jokes")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Those tests check the same thing, aren't they?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I've removed one

@serras serras merged commit 8fe9e47 into main May 12, 2023
1 check passed
@serras serras deleted the as-reorganize-agent branch May 12, 2023 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants