Skip to content

100+ AI Agents, Agent Skills and RAG Apps - Free and Open Source.

Remove avatar placeholder images and serving code

ciaf0b723a0db8
diff --git a/voice_ai_agents/insurance_claim_live_agent_team/README.md b/voice_ai_agents/insurance_claim_live_agent_team/README.md
index 88b774d1..55f0b95c 100644
--- a/voice_ai_agents/insurance_claim_live_agent_team/README.md
+++ b/voice_ai_agents/insurance_claim_live_agent_team/README.md
@@ -86,7 +86,7 @@ FNOL_AVATAR_VOICE=Kore
* Supply a PNG under 5 MB, at least 704 × 1280 pixels.
* Paths can be absolute or relative to the app directory.
-* The image overrides `FNOL_AVATAR_NAME` and also serves as the waiting portrait.
+* The image overrides `FNOL_AVATAR_NAME` as the API's avatar reference.
* Stock-avatar clothing cannot be changed through a prompt.
## Configuration
diff --git a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar-assets/ben.jpg b/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar-assets/ben.jpg
deleted file mode 100644
index 026a52f3..00000000
Binary files a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar-assets/ben.jpg and /dev/null differ
diff --git a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar-assets/ingrid.jpg b/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar-assets/ingrid.jpg
deleted file mode 100644
index 9b7eb69f..00000000
Binary files a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar-assets/ingrid.jpg and /dev/null differ
diff --git a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar-assets/kira.jpg b/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar-assets/kira.jpg
deleted file mode 100644
index 9ee94106..00000000
Binary files a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar-assets/kira.jpg and /dev/null differ
diff --git a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar.js b/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar.js
index 752183b1..b0c3aada 100644
--- a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar.js
+++ b/voice_ai_agents/insurance_claim_live_agent_team/live_demo/avatar.js
@@ -5,7 +5,6 @@
const status = document.querySelector('#avatarStatus');
const resume = document.querySelector('#resumeAvatar');
const name = document.querySelector('#avatarName');
- const poster = document.querySelector('#avatarPoster');
const MediaSourceClass = window.MediaSource || window.ManagedMediaSource;
const defaultCodec = 'video/mp4; codecs="avc1.42c020, mp4a.40.2"';
const MAX_BYTES = 16 * 1024 * 1024;
@@ -155,9 +154,6 @@
enabled = Boolean(settings?.enabled && supported);
stage.hidden = !enabled;
name.textContent = enabled ? `${settings.name} · Claim assistant` : 'Claim assistant';
- poster.hidden = !enabled || !settings?.poster;
- if (settings?.poster) poster.src = settings.poster;
- poster.alt = enabled ? `${settings.name}, AI claim assistant` : '';
label(enabled ? 'Start a conversation when you’re ready' : 'Voice assistant · ready when you are');
},
connecting() { label(enabled ? 'Connecting your avatar…' : 'Connecting…', 'connecting'); },
diff --git a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/index.html b/voice_ai_agents/insurance_claim_live_agent_team/live_demo/index.html
index 7cabeb65..8b531d73 100644
--- a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/index.html
+++ b/voice_ai_agents/insurance_claim_live_agent_team/live_demo/index.html
@@ -10,7 +10,7 @@
href="https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600&family=Patrick+Hand&family=Inter:wght@400;500;600&display=swap"
rel="stylesheet"
/>
- <link rel="stylesheet" href="./styles.css?v=three-column-3" />
+ <link rel="stylesheet" href="./styles.css?v=three-column-4" />
</head>
<body>
<div class="desk">
@@ -34,7 +34,6 @@
</div>
<div id="avatarStage" class="avatar-stage" data-state="idle" hidden>
- <img id="avatarPoster" class="avatar-poster" alt="" hidden />
<video id="avatarVideo" playsinline aria-label="Live AI claim assistant" hidden></video>
<span class="avatar-disclosure">AI avatar</span>
<div class="avatar-identity">
@@ -126,7 +125,7 @@
</dialog>
<canvas id="frameCanvas" hidden></canvas>
- <script src="./avatar.js?v=3"></script>
+ <script src="./avatar.js?v=4"></script>
<script src="./app.js?v=voice-turns-2"></script>
</body>
</html>
diff --git a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/server.py b/voice_ai_agents/insurance_claim_live_agent_team/live_demo/server.py
index 71e41209..a07180f1 100644
--- a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/server.py
+++ b/voice_ai_agents/insurance_claim_live_agent_team/live_demo/server.py
@@ -30,7 +30,6 @@ from typing import Any
from fastapi import FastAPI, HTTPException, WebSocket, WebSocketDisconnect, Request, Response
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import FileResponse, StreamingResponse
-from fastapi.staticfiles import StaticFiles
from pydantic import BaseModel, Field
APP_DIR = Path(__file__).resolve().parents[1]
@@ -87,11 +86,6 @@ from live_tools import ( # noqa: E402
GENAI_CLIENT = None
AVATAR_CLIENT = None
-AVATAR_POSTERS = {
- "Ben": "/avatar-assets/ben.jpg",
- "Ingrid": "/avatar-assets/ingrid.jpg",
- "Kira": "/avatar-assets/kira.jpg",
-}
logger = logging.getLogger(__name__)
FRAME_MAX_AGE_SECONDS = 12.0
@@ -113,11 +107,10 @@ def avatar_description(enabled: bool | None = None) -> dict[str, Any]:
return {
"enabled": configured if enabled is None else enabled,
"name": "Claim advisor" if settings["image"] else settings["name"],
- "poster": "/avatar-reference" if settings["image"] else AVATAR_POSTERS.get(settings["name"], ""),
}
-def avatar_reference() -> tuple[Path, bytes]:
+def avatar_reference() -> bytes:
path = (APP_DIR / avatar_settings()["image"]).resolve()
data = path.read_bytes()
if len(data) >= 5 * 1024 * 1024 or not data.startswith(b"\x89PNG\r\n\x1a\n"):
@@ -125,7 +118,7 @@ def avatar_reference() -> tuple[Path, bytes]:
width, height = int.from_bytes(data[16:20], "big"), int.from_bytes(data[20:24], "big")
if width < 704 or height < 1280:
raise ValueError("Custom avatar must be at least 704 x 1280")
- return path, data
+ return data
def live_media_message(blob):
@@ -977,7 +970,7 @@ async def live_voice(websocket: WebSocket) -> None:
settings = avatar_settings()
avatar_enabled = avatar_description()["enabled"] and websocket.query_params.get("avatar") != "off"
avatar_name = settings["name"] if avatar_enabled else ""
- avatar_image = avatar_reference()[1] if avatar_enabled and settings["image"] else None
+ avatar_image = avatar_reference() if avatar_enabled and settings["image"] else None
history = [
types.Content(
role="user" if turn["speaker"] == "Claimant" else "model",
@@ -1172,17 +1165,3 @@ def styles():
@app.get("/avatar.js")
def avatar_javascript():
return FileResponse(DEMO_DIR / "avatar.js", media_type="text/javascript")
-
-
-app.mount("/avatar-assets", StaticFiles(directory=DEMO_DIR / "avatar-assets"), name="avatar-assets")
-
-
[email protected]("/avatar-reference")
-def avatar_reference_image():
- if not avatar_settings()["image"]:
- raise HTTPException(status_code=404)
- try:
- path, _ = avatar_reference()
- except (OSError, ValueError):
- raise HTTPException(status_code=404) from None
- return FileResponse(path, media_type="image/png")
diff --git a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/styles.css b/voice_ai_agents/insurance_claim_live_agent_team/live_demo/styles.css
index 4d6cf0ec..ad4889fe 100644
--- a/voice_ai_agents/insurance_claim_live_agent_team/live_demo/styles.css
+++ b/voice_ai_agents/insurance_claim_live_agent_team/live_demo/styles.css
@@ -898,7 +898,6 @@ h1 {
border-radius: 12px;
background: var(--desk-edge);
}
-.avatar-poster,
#avatarVideo {
position: absolute;
inset: 0;
diff --git a/voice_ai_agents/insurance_claim_live_agent_team/tests/avatar-player.cjs b/voice_ai_agents/insurance_claim_live_agent_team/tests/avatar-player.cjs
index 1bfacbac..6e881eec 100644
--- a/voice_ai_agents/insurance_claim_live_agent_team/tests/avatar-player.cjs
+++ b/voice_ai_agents/insurance_claim_live_agent_team/tests/avatar-player.cjs
@@ -23,7 +23,7 @@ function env(supported = true) {
const context = vm.createContext({window:{MediaSource:Media}, document:{querySelector(id){if(!elements.has(id))elements.set(id,element());return elements.get(id);}}, URL:{createObjectURL:()=>`blob:${sources.length}`,revokeObjectURL:url=>revoked.push(url)}, atob:s=>global.Buffer.from(s,'base64').toString('binary'), console});
vm.runInContext(source, context);
const player = context.window.claimAvatar;
- player.configure({enabled:true,name:'Ben',poster:'/avatar-assets/ben.jpg'});
+ player.configure({enabled:true,name:'Kira'});
return {player,elements,sources,revoked};
}
function box(type, payload = []) { const b = global.Buffer.alloc(8 + payload.length); b.writeUInt32BE(b.length); b.write(type,4); global.Buffer.from(payload).copy(b,8); return b; }
@@ -72,7 +72,7 @@ test('unsupported browsers select voice mode without a decoder', () => {
test('voice-only configuration hides the unused avatar frame', () => {
const e=env();
assert.equal(e.elements.get('#avatarStage').hidden,false);
- e.player.configure({enabled:false,name:'',poster:''});
+ e.player.configure({enabled:false,name:''});
assert.equal(e.elements.get('#avatarStage').hidden,true);
});
for(const [name,fn]of tests){fn();console.log('PASS '+name);}
diff --git a/voice_ai_agents/insurance_claim_live_agent_team/tests/test_avatar.py b/voice_ai_agents/insurance_claim_live_agent_team/tests/test_avatar.py
index da2cecb2..9375ad4f 100644
--- a/voice_ai_agents/insurance_claim_live_agent_team/tests/test_avatar.py
+++ b/voice_ai_agents/insurance_claim_live_agent_team/tests/test_avatar.py
@@ -66,8 +66,7 @@ class AvatarConfigTests(unittest.TestCase):
reference = Path(directory) / 'reference.png'
reference.write_bytes(png)
with patch.dict(os.environ, {'FNOL_AVATAR_IMAGE': str(reference)}):
- path, data = server.avatar_reference()
- self.assertEqual(path, reference.resolve())
+ data = server.avatar_reference()
self.assertEqual(data, png)