Skip to content

Conversation

@smurching
Copy link
Contributor

@smurching smurching commented Apr 2, 2025

Description

Updates chatbot templates to support running the template against agents deployed with Mosaic AI agent framework (https://docs.databricks.com/aws/en/generative-ai/agent-framework/author-agent)

How is this tested?

Tested manually by deploying the following apps against an agent serving & standard GPT4-o external model endpoint

Dash chatbot

Agent serving endpoint:
image

External model serving endpoint:
image

Gradio chatbot

Agent serving endpoint:
image

External model serving endpoint:
image

Shiny chatbot

Agent serving endpoint:
image

External model serving endpoint:
image

Streamlit chatbot

Agent serving endpoint:
image

External model serving endpoint:
image

@smurching smurching requested review from jerrylian-db and theof-db and removed request for theof-db April 3, 2025 21:18
Signed-off-by: Sid Murching <[email protected]>
return res["messages"]
elif "choices" in res:
return [res["choices"][0]["message"]]
raise Exception("This app can only run against Databricks model serving endpoints that serve one of the conversational agent schemas documented in https://docs.databricks.com/aws/en/generative-ai/agent-framework/author-agent")
Copy link
Contributor

Choose a reason for hiding this comment

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

@smurching - Curious this would still continue to support foundational models?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, I need to update this message, thanks!

@smurching smurching requested a review from aakrati April 3, 2025 23:57
@@ -1 +1,2 @@
openai
mlflow
streamlit
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we try to pin the library versions in the requirements.txt files across the templates? That would help the templates be stable across time. I've actually seen some templates break when restarted because the libraries were not pinned.

Copy link
Contributor

Choose a reason for hiding this comment

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

You could inspect the app logs to see what library versions were used.


if __name__ == '__main__':
app.run_server(debug=True)
app.run(debug=True)
Copy link
Contributor

@jerrylian-db jerrylian-db Apr 4, 2025

Choose a reason for hiding this comment

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

Thanks for fixing this! The template is actually broke in production right now because dash 3+ does not support the run_server method anymore. 😅

return [res["choices"][0]["message"]]
raise Exception("This app can only run against:"
"1) Databricks foundation model or external model endpoints with the chat task type (described in https://docs.databricks.com/aws/en/machine-learning/model-serving/score-foundation-models#chat-completion-model-query)"
"2) Databricks agent serving endpoints that implmeent the conversational agent schema documented "
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: typo

"in https://docs.databricks.com/aws/en/generative-ai/agent-framework/author-agent")

def query_endpoint(endpoint_name, messages, max_tokens):
return _query_endpoint(endpoint_name, messages, max_tokens)[-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

would it be possible to document that we will only take the last msg of the list of chatagent messages?

"in https://docs.databricks.com/aws/en/generative-ai/agent-framework/author-agent")

def query_endpoint(endpoint_name, messages, max_tokens):
return _query_endpoint(endpoint_name, messages, max_tokens)[-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

def doesn't have to be done here, but should we add a test to ensure that this file is the same across the diff chatbot templates to reduce room for potential error? cc @jerrylian-db

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's a good idea - it seems we don't have CI set up yet in this repo, but we should, and probably should have some tests for these apps

Copy link
Contributor Author

@smurching smurching Apr 8, 2025

Choose a reason for hiding this comment

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

Basic tests are probably sufficient (we can just follow best practices for testing a dash, streamlit, gradio app etc) and hopefully not too confusing to give to end users (we could also leave the tests outside the template, I'm fine with that too, but IMO they seem actually useful)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can send a follow-up with that change after this one, will discuss offline with @aakrati @jerrylian-db on what makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(filed #22 on top of the current PR, can iterate/follow up on this one after this initial PR lands)

Signed-off-by: Sid Murching <[email protected]>
@smurching smurching requested review from bbqiu and jerrylian-db April 8, 2025 06:30
Copy link
Contributor

@bbqiu bbqiu left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

@jerrylian-db jerrylian-db left a comment

Choose a reason for hiding this comment

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

Thanks so much for this!

@smurching smurching merged commit 27c104b into databricks:main Apr 8, 2025
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.

4 participants