-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
741 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"livekit-plugins-google": minor | ||
"livekit-plugins-openai": patch | ||
"livekit-agents": patch | ||
--- | ||
|
||
make multimodal class generic and support gemini live api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from typing import Annotated | ||
|
||
import aiohttp | ||
from dotenv import load_dotenv | ||
from livekit.agents import ( | ||
AutoSubscribe, | ||
JobContext, | ||
WorkerOptions, | ||
WorkerType, | ||
cli, | ||
llm, | ||
multimodal, | ||
) | ||
from livekit.plugins import google | ||
|
||
load_dotenv() | ||
|
||
logger = logging.getLogger("my-worker") | ||
logger.setLevel(logging.INFO) | ||
|
||
|
||
async def entrypoint(ctx: JobContext): | ||
logger.info("starting entrypoint") | ||
|
||
fnc_ctx = llm.FunctionContext() | ||
|
||
@fnc_ctx.ai_callable() | ||
async def get_weather( | ||
location: Annotated[ | ||
str, llm.TypeInfo(description="The location to get the weather for") | ||
], | ||
): | ||
"""Called when the user asks about the weather. This function will return the weather for the given location.""" | ||
logger.info(f"getting weather for {location}") | ||
url = f"https://wttr.in/{location}?format=%C+%t" | ||
async with aiohttp.ClientSession() as session: | ||
async with session.get(url) as response: | ||
if response.status == 200: | ||
weather_data = await response.text() | ||
# # response from the function call is returned to the LLM | ||
return f"The weather in {location} is {weather_data}." | ||
else: | ||
raise Exception( | ||
f"Failed to get weather data, status code: {response.status}" | ||
) | ||
|
||
await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY) | ||
participant = await ctx.wait_for_participant() | ||
|
||
chat_ctx = llm.ChatContext() | ||
|
||
agent = multimodal.MultimodalAgent( | ||
model=google.beta.realtime.RealtimeModel( | ||
voice="Charon", | ||
temperature=0.8, | ||
instructions="You are a helpful assistant", | ||
), | ||
fnc_ctx=fnc_ctx, | ||
chat_ctx=chat_ctx, | ||
) | ||
agent.start(ctx.room, participant) | ||
|
||
|
||
if __name__ == "__main__": | ||
cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint, worker_type=WorkerType.ROOM)) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
"openai", | ||
"watchfiles", | ||
"anthropic", | ||
"websockets.client", | ||
] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
from .multimodal_agent import AgentTranscriptionOptions, MultimodalAgent | ||
from .multimodal_agent import ( | ||
AgentTranscriptionOptions, | ||
MultimodalAgent, | ||
_RealtimeAPI, | ||
_RealtimeAPISession, | ||
) | ||
|
||
__all__ = ["MultimodalAgent", "AgentTranscriptionOptions"] | ||
__all__ = [ | ||
"MultimodalAgent", | ||
"AgentTranscriptionOptions", | ||
"_RealtimeAPI", | ||
"_RealtimeAPISession", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from . import realtime | ||
|
||
__all__ = ["realtime"] |
15 changes: 15 additions & 0 deletions
15
livekit-plugins/livekit-plugins-google/livekit/plugins/google/beta/realtime/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from .api_proto import ( | ||
ClientEvents, | ||
LiveAPIModels, | ||
ResponseModality, | ||
Voice, | ||
) | ||
from .realtime_api import RealtimeModel | ||
|
||
__all__ = [ | ||
"RealtimeModel", | ||
"ClientEvents", | ||
"LiveAPIModels", | ||
"ResponseModality", | ||
"Voice", | ||
] |
Oops, something went wrong.