Skip to content
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

Move create_ai_function_info to function_context.py #1260

Merged
merged 4 commits into from
Dec 20, 2024
Merged

Conversation

jayeshp19
Copy link
Collaborator

@jayeshp19 jayeshp19 commented Dec 19, 2024

  • Moved create_ai_function_info to function_context.py for better reusability and reduce repetation
  • Fixes UnboundLocalError in test_stt.py::test_stream[24000-assemblyai] by ensuring ws is initialized before access.

Copy link

changeset-bot bot commented Dec 19, 2024

🦋 Changeset detected

Latest commit: d6da32b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
livekit-plugins-anthropic Patch
livekit-plugins-openai Patch
livekit-agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jayeshp19 jayeshp19 marked this pull request as ready for review December 19, 2024 13:14
@jayeshp19 jayeshp19 requested a review from theomonnom December 19, 2024 13:14
@jayeshp19 jayeshp19 changed the title Moved create_ai_function_info to function_context.py Move create_ai_function_info to function_context.py Dec 19, 2024
Comment on lines 309 to 315
def create_ai_function_info(
fnc_ctx: FunctionContext,
tool_call_id: str,
fnc_name: str,
raw_arguments: str, # JSON string
) -> FunctionCallInfo:
if fnc_name not in fnc_ctx.ai_functions:
Copy link
Member

Choose a reason for hiding this comment

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

This function was initially for OpenAI but if they all support the same kind of arguments (same json format).
Then it makes sense to move it.

Tho I'm not sure about what the implementation will looks like when we add support for structured output

Copy link
Member

Choose a reason for hiding this comment

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

I would keep this function prefixed with _ tho. It's not really relevant to users

@@ -289,6 +289,8 @@ async def recv_task(ws: aiohttp.ClientWebSocketResponse):
except Exception:
logger.exception("failed to process AssemblyAI message")

ws: aiohttp.ClientWebSocketResponse | None = None
Copy link
Member

Choose a reason for hiding this comment

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

We didn't add assemblyai to the CI?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jayeshp19 jayeshp19 merged commit c57b4cc into main Dec 20, 2024
13 of 14 checks passed
@jayeshp19 jayeshp19 deleted the create-ai-func branch December 20, 2024 08:12
@github-actions github-actions bot mentioned this pull request Dec 19, 2024
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.

2 participants