8000 Add voice feedback support for streaming tool calls by uezo · Pull Request #107 · uezo/aiavatarkit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add voice feedback support for streaming tool calls #107

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

Merged
merged 1 commit into from
Jun 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions aiavatar/sts/llm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@


class ToolCallResult:
def __init__(self, data: dict = None, is_final: bool = True):
def __init__(self, data: dict = None, is_final: bool = True, text: str = None):
self.data = data or {}
self.is_final = is_final
self.text = text


class ToolCall:
Expand Down Expand Up @@ -239,10 +240,14 @@ async def execute_tool(self, name: str, arguments: dict, metadata: dict) -> Asyn
async for r in tool_result:
if isinstance(r, Tuple):
yield ToolCallResult(data=r[0], is_final=r[1])
elif isinstance(r, dict):
yield ToolCallResult(data=r, is_final=False)
elif isinstance(r, str):
yield ToolCallResult(text=r, is_final=False)
else:
yield r
elif isinstance(tool_result, ToolCallResult):
yield await tool_result
yield tool_result
else:
yield ToolCallResult(data=await tool_result)

Expand Down
11 changes: 7 additions & 4 deletions aiavatar/sts/llm/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,13 @@ async def get_llm_stream_response(self, context_id: str, user_id: str, messages:
else:
async for tr in self.execute_tool(tc.name, json.loads(tc.arguments), {"user_id": user_id}):
tc.result = tr
yield LLMResponse(context_id=context_id, tool_call=tc)
if tr.is_final:
tool_result = tr.data
break
if tr.text:
yield LLMResponse(context_id=context_id, text=tr.text)
else:
yield LLMResponse(context_id=context_id, tool_call=tc)
if tr.is_final:
tool_result = tr.data
break

if self.debug:
logger.info(f"ToolCall result: {tool_result}")
Expand Down
11 changes: 7 additions & 4 deletions aiavatar/sts/llm/claude.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,13 @@ async def get_llm_stream_response(self, context_id: str, user_id: str, messages:
else:
async for tr in self.execute_tool(tc.name, arguments_json, {"user_id": user_id}):
tc.result = tr
yield LLMResponse(context_id=context_id, tool_call=tc)
if tr.is_final:
tool_result = tr.data
break
if tr.text:
yield LLMResponse(context_id=context_id, text=tr.text)
else:
yield LLMResponse(context_id=context_id, tool_call=tc)
if tr.is_final:
tool_result = tr.data
break

if self.debug:
logger.info(f"ToolCall result: {tool_result}")
Expand Down
11 changes: 7 additions & 4 deletions aiavatar/sts/llm/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,13 @@ async def get_llm_stream_response(self, context_id: str, user_id: str, messages:

async for tr in self.execute_tool(tc.name, tc.arguments, {"user_id": user_id}):
tc.result = tr
yield LLMResponse(context_id=context_id, tool_call=tc)
if tr.is_final:
tool_result = tr.data
break
if tr.text:
yield LLMResponse(context_id=context_id, text=tr.text)
else:
yield LLMResponse(context_id=context_id, tool_call=tc)
if tr.is_final:
tool_result = tr.data
break

if self.debug:
logger.info(f"ToolCall result: {tool_result}")
Expand Down
11 changes: 7 additions & 4 deletions aiavatar/sts/llm/litellm.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,13 @@ async def get_llm_stream_response(self, context_id: str, user_id: str, messages:
else:
async for tr in self.execute_tool(tc.name, json.loads(tc.arguments), {"user_id": user_id}):
tc.result = tr
yield LLMResponse(context_id=context_id, tool_call=tc)
if tr.is_final:
tool_result = tr.data
break
if tr.text:
yield LLMResponse(context_id=context_id, text=tr.text)
else:
yield LLMResponse(context_id=context_id, tool_call=tc)
if tr.is_final:
tool_result = tr.data
break

if self.debug:
logger.info(f"ToolCall result: {tool_result}")
Expand Down
0