|
319 | 319 | " display(Markdown(f\"**Response >** {''.join(response)}\"))"
|
320 | 320 | ]
|
321 | 321 | },
|
322 |
| - { |
323 |
| - "cell_type": "code", |
324 |
| - "execution_count": null, |
325 |
| - "metadata": { |
326 |
| - "id": "a715adea5343" |
327 |
| - }, |
328 |
| - "outputs": [], |
329 |
| - "source": [ |
330 |
| - "get_current_weather = FunctionDeclaration(\n", |
331 |
| - " name=\"get_current_weather\",\n", |
332 |
| - " description=\"Get current weather in the given location\",\n", |
333 |
| - " parameters={\n", |
334 |
| - " \"type\": \"OBJECT\",\n", |
335 |
| - " \"properties\": {\n", |
336 |
| - " \"location\": {\n", |
337 |
| - " \"type\": \"STRING\",\n", |
338 |
| - " },\n", |
339 |
| - " },\n", |
340 |
| - " },\n", |
341 |
| - ")\n", |
342 |
| - "\n", |
343 |
| - "config = LiveConnectConfig(\n", |
344 |
| - " response_modalities=[\"TEXT\"],\n", |
345 |
| - " tools=[get_current_weather],\n", |
346 |
| - ")\n", |
347 |
| - "\n", |
348 |
| - "async with client.aio.live.connect(\n", |
349 |
| - " model=MODEL_ID,\n", |
350 |
| - " config=config,\n", |
351 |
| - ") as session:\n", |
352 |
| - " text_input = \"Get the current weather in Santa Clara, San Jose and Mountain View\"\n", |
353 |
| - " display(Markdown(f\"**Input:** {text_input}\"))\n", |
354 |
| - "\n", |
355 |
| - " await session.send(input=text_input, end_of_turn=True)\n", |
356 |
| - "\n", |
357 |
| - " response = []\n", |
358 |
| - "\n", |
359 |
| - " async for message in session.receive():\n", |
360 |
| - " print(message)\n", |
361 |
| - " if message.text:\n", |
362 |
| - " response.append(message.text)\n", |
363 |
| - " if message.tool_call:\n", |
364 |
| - " print(message.function_response)\n", |
365 |
| - "\n", |
366 |
| - " display(Markdown(f\"**Response >** {''.join(response)}\"))" |
367 |
| - ] |
368 |
| - }, |
369 | 322 | {
|
370 | 323 | "cell_type": "markdown",
|
371 | 324 | "metadata": {
|
|
0 commit comments