Anybody building controlFlow agents to interact wi...
# ask-community
a
Anybody building controlFlow agents to interact with via http? Like to serve as backends for UI chatbots?
tldr i'd use
marvin
, its using
pydantic-ai
for llm support (better typing) or
pydantic-ai
directly
Copy code
@app.post("/chat")
def chat(...):
   asyncio.create_task(marvin.Agent(...).run(_render_payload(...)))
main difference is that you'd need to wrap that in a flow if you want that
for example @Marvin is something like this using pydantic-ai https://github.com/PrefectHQ/marvin/tree/main/examples/slackbot
m
thought for 45.0 seconds
Got it — are you asking if there’s an example like that Slackbot, but using PydanticAI instead of Marvin? If so, I can help you: - port the Marvin Slackbot example to PydanticAI + Slack Bolt - optionally wire it to trigger Prefect flows/deployments - package it into a container and run it as an ECS service (pushing the image to ECR) A couple of quick questions so I can tailor the example: 1) Which LLM provider are you planning to use (OpenAI, Anthropic, etc.)? 2) Do you want simple free-form replies in Slack, or structured outputs (where PydanticAI really shines)? 3) From Slack, do you want to kick off Prefect runs (via deployments) or just answer in-channel? 4) For deployment, should I target ECS on EC2 or Fargate, and do you already have an ECR repo you want to use? In the meantime, here are the core pieces we’d combine: - PydanticAI: https://github.com/pydantic/pydantic-ai - Slack Bolt (Python): https://slack.dev/bolt-python/ - Prefect 3 deployments and workers (if you want Slack to trigger flows): https://docs.prefect.io/latest/ (I’ll point you to the exact pages once I know your infra preference) If you confirm the details above, I’ll drop a minimal, working skeleton with: - Slack Bolt app that forwards messages to a PydanticAI Agent - Optional hook to trigger a Prefect deployment when a command is used - Dockerfile and ECS task/service notes tailored for ECR + ECS on your chosen capacity (EC2 or Fargate)
n
Slack Bolt (Python): https://slack.dev/bolt-python/
i think it got confused by my lack of question, i would not use this lol
a
What can Marvin do that ControlFlow can't. They both look alike.
n
that's why i linked the first discussion, to disambiguate
the main difference is that controlflow is inherently instrumented with prefect, which people found annoying, which i explain in that discussion
👍 1
a
Can you interact with Marvin through HTTP/restAPI. I don't really want to use CLI with it. I'm trying to use it as a backend to a frontend chatbot.
n
what did you think about the suggestions to either • write a small api with a
/chat
endpoint • deploy a flow that does the same thing to a process work pool ?
a
I don't know, I just need the right endpoint to send my chat msgs. I already have a working controlFlow workflow
n
i would consider controlflow as archived and use marvin instead. the migration would not be challenging unless you depend on the prefect instrumentation. either of the 2 options i mentioned above give you a web endpoint to send requests to your agentic while loop
controlflow is now explicitly archived to make this more clear