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

New version requires input= keyword for arg. #399

Merged
merged 3 commits into from
Jan 9, 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
6 changes: 3 additions & 3 deletions gemini-2/live_api_starter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
"async with client.aio.live.connect(model=MODEL, config=config) as session:\n",
" message = \"Hello? Gemini are you there?\"\n",
" print(\"> \", message, \"\\n\")\n",
" await session.send(message, end_of_turn=True)\n",
" await session.send(input=message, end_of_turn=True)\n",
"\n",
" # For text responses, When the model's turn is complete it breaks out of the loop.\n",
" turn = session.receive()\n",
Expand Down Expand Up @@ -361,7 +361,7 @@
" with wave_file(file_name) as wav:\n",
" message = \"Hello? Gemini are you there?\"\n",
" print(\"> \", message, \"\\n\")\n",
" await session.send(message, end_of_turn=True)\n",
" await session.send(input=message, end_of_turn=True)\n",
"\n",
" turn = session.receive()\n",
" async for n,response in async_enumerate(turn):\n",
Expand Down Expand Up @@ -480,7 +480,7 @@
" logger.debug('send')\n",
"\n",
" # Send the message to the model.\n",
" await self.session.send(text, end_of_turn=True)\n",
" await self.session.send(input=text, end_of_turn=True)\n",
" logger.debug('sent')\n",
" yield text\n",
"\n",
Expand Down
9 changes: 4 additions & 5 deletions gemini-2/live_api_starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,10 @@
class AudioLoop:
def __init__(self, video_mode=DEFAULT_MODE):
self.video_mode = video_mode

self.audio_in_queue = None
self.out_queue = None


self.session = None

self.send_text_task = None
Expand All @@ -106,7 +105,7 @@ async def send_text(self):
)
if text.lower() == "q":
break
await self.session.send(text or ".", end_of_turn=True)
await self.session.send(input=text or ".", end_of_turn=True)

def _get_frame(self, cap):
# Read the frameq
Expand Down Expand Up @@ -179,7 +178,7 @@ async def get_screen(self):
async def send_realtime(self):
while True:
msg = await self.out_queue.get()
await self.session.send(msg)
await self.session.send(input=msg)

async def listen_audio(self):
mic_info = pya.get_default_input_device_info()
Expand Down Expand Up @@ -248,7 +247,7 @@ async def run(self):
tg.create_task(self.get_frames())
elif self.video_mode == "screen":
tg.create_task(self.get_screen())

tg.create_task(self.receive_audio())
tg.create_task(self.play_audio())

Expand Down
Loading