Skip to content

armgit / burr

Public Imported from GitHub
0

Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.

Adds FastAPI example -- not fully fleshed out, but good enough for now

elijahbenizzyffb1cf52b1a2
diff --git a/burr/tracking/server/examples/chatbot.py b/burr/tracking/server/examples/chatbot.py
index c6a6b5aa..0718f7f3 100644
--- a/burr/tracking/server/examples/chatbot.py
+++ b/burr/tracking/server/examples/chatbot.py
@@ -11,15 +11,15 @@ from burr.core import Application
We manage an application, write to it with post endpoints, and read with
get/ endpoints.
-This demonstrates how
+This demonstrates how you can build interactive web applications with Burr!
"""
-# We're doing dynamic import cause this lives within examples/
+# We're doing dynamic import cause this lives within examples/ (and that module has dashes)
# navigate to the examples directory to read more about this!
chat_application = importlib.import_module(
"burr.examples.multi-modal-chatbot.application"
) # noqa: F401
-# the app is commented out as we dynamically register it
+# the app is commented out as we include the router.
# app = FastAPI()
router = APIRouter()
@@ -82,13 +82,5 @@ async def create_new_application(project_id: str, app_id: str) -> str:
return app_id # just return it for now
-# def register(app: FastAPI, api_prefix: str):
-# app.post(
-# f"{api_prefix}/{{project_id}}/{{app_id}}/response",
-# response_model=List[ChatItem])(chat_response)
-# app.get(f"{api_prefix}/{{project_id}}/{{app_id}}/history", response_model=List[ChatItem])(
-# chat_history
-# )
-# app.post(f"{api_prefix}/{{project_id}}/{{app_id}}/create", response_model=str)(
-# create_new_application
-# )
+# comment this back in fro a standalone chatbot API
+# app.include_router(router, prefix="/api/v0/chatbot")
diff --git a/examples/README.md b/examples/README.md
index f865cef8..f8b23298 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -30,3 +30,4 @@ Note we have a few more in [other-examples](other-examples/), but those do not y
- [multi-modal-chatbot](multi-modal-chatbot/) - This example shows how to use Burr to create a multi-modal chatbot. This demonstrates how to use a model to delegate to other models conditionally.
- [streaming-overview](streaming-overview/) - This example shows how we can use the streaming API to respond to return quicker results to the user and build a seamless experience
- [tracing-and-spans](tracing-and-spans/) - This example shows how to use Burr to create a simple chatbot with additional visibility. This is a good starting point for understanding how to use Burr's tracing functionality.
+- [web-server](web-server/) - This example shows how to use Burr in a web server. This is a good starting point for understanding how to use Burr for interaction.
diff --git a/examples/validate_examples.py b/examples/validate_examples.py
index f515dcd0..179ad4ca 100644
--- a/examples/validate_examples.py
+++ b/examples/validate_examples.py
@@ -12,7 +12,14 @@ REQUIRED_FILES = [
"__init__.py", # included as we want them all to be importable
]
-FILTERLIST = ["other-examples", "ml-training", "simulation", "multi-agent-collaboration"]
+FILTERLIST = [
+ "other-examples",
+ # todo -- remove the following once we've fleshed them out
+ "ml-training",
+ "simulation",
+ "multi-agent-collaboration",
+ "web-server",
+]
def should_validate(directory: str) -> bool: