Skip to content

feat(livekit-plugins-google): structured responses for Live API tool calls#1

Open
vsomayaji wants to merge 2 commits intomainfrom
structured-tool-response
Open

feat(livekit-plugins-google): structured responses for Live API tool calls#1
vsomayaji wants to merge 2 commits intomainfrom
structured-tool-response

Conversation

@vsomayaji
Copy link

LiveKit automatically converts the result of a tool call to a string (reference), and this string was being returned in the Live API FunctionResponse.response as output. So, for example:

@function_tool()
async def lookup_weather(self, context: RunContext, location: str) -> dict[str, Any]:
    return {"weather": "sunny", "temperature_f": 70}

Would get returned to the Live API as:

{
  "output": "{'weather': 'sunny', 'temperature_f': 70}"
}

However, our Live API integration requires returning the actual result, not the string representation.

With this change, we:

  1. Do not return a FunctionResponse if the tool call did not return anything.
  2. Set FunctionResponse.response to the actual result by calling ast.literal_eval on the string representation.
  3. Set FunctionResponse.scheduling to SILENT to let the model decide when to use the result (reference).

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.

1 participant