Skip to content

Commit

Permalink
New version requires input= keyword for arg. (#399)
Browse files Browse the repository at this point in the history
* New version requires `input=` keyword for arg.
  • Loading branch information
MarkDaoust authored Jan 9, 2025
1 parent 79f0837 commit b6e259a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
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

0 comments on commit b6e259a

Please sign in to comment.