agent-starter-pack 0.3.3__py3-none-any.whl → 0.21.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_starter_pack/agents/README.md +7 -0
- agents/langgraph_base_react/template/.templateconfig.yaml → agent_starter_pack/agents/adk_a2a_base/.template/templateconfig.yaml +5 -10
- agent_starter_pack/agents/adk_a2a_base/README.md +37 -0
- src/deployment_targets/cloud_run/Dockerfile → agent_starter_pack/agents/adk_a2a_base/app/__init__.py +2 -14
- agent_starter_pack/agents/adk_a2a_base/app/agent.py +70 -0
- agent_starter_pack/agents/adk_a2a_base/notebooks/adk_a2a_app_testing.ipynb +583 -0
- agents/crewai_coding_crew/notebooks/evaluating_crewai_agent.ipynb → agent_starter_pack/agents/adk_a2a_base/notebooks/evaluating_adk_agent.ipynb +163 -199
- {agents/adk_base → agent_starter_pack/agents/adk_a2a_base}/tests/integration/test_agent.py +2 -2
- agents/adk_base/template/.templateconfig.yaml → agent_starter_pack/agents/adk_base/.template/templateconfig.yaml +4 -1
- {agents → agent_starter_pack/agents}/adk_base/README.md +1 -1
- agent_starter_pack/agents/adk_base/app/__init__.py +17 -0
- {agents → agent_starter_pack/agents}/adk_base/app/agent.py +5 -2
- {agents → agent_starter_pack/agents}/adk_base/notebooks/adk_app_testing.ipynb +128 -82
- agents/langgraph_base_react/notebooks/evaluating_langgraph_agent.ipynb → agent_starter_pack/agents/adk_base/notebooks/evaluating_adk_agent.ipynb +181 -207
- agent_starter_pack/agents/adk_base/tests/integration/test_agent.py +58 -0
- agents/crewai_coding_crew/template/.templateconfig.yaml → agent_starter_pack/agents/adk_live/.template/templateconfig.yaml +5 -9
- agent_starter_pack/agents/adk_live/README.md +32 -0
- agent_starter_pack/agents/adk_live/app/__init__.py +17 -0
- agent_starter_pack/agents/adk_live/app/agent.py +51 -0
- agent_starter_pack/agents/adk_live/tests/unit/test_dummy.py +38 -0
- agents/agentic_rag/template/.templateconfig.yaml → agent_starter_pack/agents/agentic_rag/.template/templateconfig.yaml +7 -3
- {agents → agent_starter_pack/agents}/agentic_rag/README.md +1 -1
- agent_starter_pack/agents/agentic_rag/app/__init__.py +17 -0
- {agents → agent_starter_pack/agents}/agentic_rag/app/agent.py +8 -4
- {agents → agent_starter_pack/agents}/agentic_rag/notebooks/adk_app_testing.ipynb +128 -82
- agent_starter_pack/agents/agentic_rag/notebooks/evaluating_adk_agent.ipynb +1535 -0
- {agents → agent_starter_pack/agents}/agentic_rag/tests/integration/test_agent.py +3 -3
- agent_starter_pack/agents/langgraph_base/.template/templateconfig.yaml +31 -0
- agent_starter_pack/agents/langgraph_base/README.md +30 -0
- agent_starter_pack/agents/langgraph_base/app/__init__.py +17 -0
- agent_starter_pack/agents/langgraph_base/app/agent.py +34 -0
- {agents/crewai_coding_crew → agent_starter_pack/agents/langgraph_base}/notebooks/evaluating_langgraph_agent.ipynb +30 -17
- {agents/langgraph_base_react → agent_starter_pack/agents/langgraph_base}/tests/integration/test_agent.py +2 -2
- {src → agent_starter_pack}/base_template/.gitignore +5 -3
- agent_starter_pack/base_template/GEMINI.md +5 -0
- agent_starter_pack/base_template/Makefile +339 -0
- agent_starter_pack/base_template/README.md +267 -0
- agent_starter_pack/base_template/deployment/README.md +11 -0
- {src → agent_starter_pack}/base_template/deployment/terraform/apis.tf +2 -2
- {src → agent_starter_pack}/base_template/deployment/terraform/dev/apis.tf +6 -1
- {src → agent_starter_pack}/base_template/deployment/terraform/dev/iam.tf +12 -11
- {src → agent_starter_pack}/base_template/deployment/terraform/dev/providers.tf +5 -1
- {src → agent_starter_pack}/base_template/deployment/terraform/dev/storage.tf +1 -1
- {src → agent_starter_pack}/base_template/deployment/terraform/dev/variables.tf +10 -10
- agent_starter_pack/base_template/deployment/terraform/dev/{% if cookiecutter.is_adk %}telemetry.tf{% else %}unused_telemetry.tf{% endif %} +193 -0
- agent_starter_pack/base_template/deployment/terraform/github.tf +337 -0
- {src → agent_starter_pack}/base_template/deployment/terraform/iam.tf +20 -41
- {src → agent_starter_pack}/base_template/deployment/terraform/locals.tf +10 -3
- {src/resources/setup_cicd → agent_starter_pack/base_template/deployment/terraform}/providers.tf +8 -1
- {src → agent_starter_pack}/base_template/deployment/terraform/service_accounts.tf +7 -8
- agent_starter_pack/base_template/deployment/terraform/sql/completions.sql +138 -0
- {src → agent_starter_pack}/base_template/deployment/terraform/storage.tf +7 -16
- {src → agent_starter_pack}/base_template/deployment/terraform/variables.tf +61 -28
- {src → agent_starter_pack}/base_template/deployment/terraform/vars/env.tfvars +6 -1
- agent_starter_pack/base_template/deployment/terraform/{% if cookiecutter.cicd_runner == 'github_actions' %}wif.tf{% else %}unused_wif.tf{% endif %} +43 -0
- src/base_template/deployment/terraform/build_triggers.tf → agent_starter_pack/base_template/deployment/terraform/{% if cookiecutter.cicd_runner == 'google_cloud_build' %}build_triggers.tf{% else %}unused_build_triggers.tf{% endif %} +55 -38
- agent_starter_pack/base_template/deployment/terraform/{% if cookiecutter.is_adk %}telemetry.tf{% else %}unused_telemetry.tf{% endif %} +206 -0
- {src → agent_starter_pack}/base_template/pyproject.toml +24 -37
- agent_starter_pack/base_template/{% if cookiecutter.cicd_runner == 'github_actions' %}.github{% else %}unused_github{% endif %}/workflows/deploy-to-prod.yaml +132 -0
- agent_starter_pack/base_template/{% if cookiecutter.cicd_runner == 'github_actions' %}.github{% else %}unused_github{% endif %}/workflows/pr_checks.yaml +65 -0
- agent_starter_pack/base_template/{% if cookiecutter.cicd_runner == 'github_actions' %}.github{% else %}unused_github{% endif %}/workflows/staging.yaml +259 -0
- src/base_template/deployment/cd/deploy-to-prod.yaml → agent_starter_pack/base_template/{% if cookiecutter.cicd_runner == 'google_cloud_build' %}.cloudbuild{% else %}unused_.cloudbuild{% endif %}/deploy-to-prod.yaml +38 -30
- src/base_template/deployment/ci/pr_checks.yaml → agent_starter_pack/base_template/{% if cookiecutter.cicd_runner == 'google_cloud_build' %}.cloudbuild{% else %}unused_.cloudbuild{% endif %}/pr_checks.yaml +5 -5
- agent_starter_pack/base_template/{% if cookiecutter.cicd_runner == 'google_cloud_build' %}.cloudbuild{% else %}unused_.cloudbuild{% endif %}/staging.yaml +322 -0
- agent_starter_pack/base_template/{{cookiecutter.agent_directory}}/app_utils/telemetry.py +96 -0
- {src/base_template/app/utils → agent_starter_pack/base_template/{{cookiecutter.agent_directory}}/app_utils}/typing.py +7 -9
- agent_starter_pack/base_template/{{cookiecutter.agent_directory}}/app_utils/{% if cookiecutter.is_a2a and cookiecutter.agent_name == 'langgraph_base' %}converters{% else %}unused_converters{% endif %}/__init__.py +25 -0
- agent_starter_pack/base_template/{{cookiecutter.agent_directory}}/app_utils/{% if cookiecutter.is_a2a and cookiecutter.agent_name == 'langgraph_base' %}converters{% else %}unused_converters{% endif %}/part_converter.py +138 -0
- agent_starter_pack/base_template/{{cookiecutter.agent_directory}}/app_utils/{% if cookiecutter.is_a2a and cookiecutter.agent_name == 'langgraph_base' %}executor{% else %}unused_executor{% endif %}/__init__.py +13 -0
- agent_starter_pack/base_template/{{cookiecutter.agent_directory}}/app_utils/{% if cookiecutter.is_a2a and cookiecutter.agent_name == 'langgraph_base' %}executor{% else %}unused_executor{% endif %}/a2a_agent_executor.py +265 -0
- agent_starter_pack/base_template/{{cookiecutter.agent_directory}}/app_utils/{% if cookiecutter.is_a2a and cookiecutter.agent_name == 'langgraph_base' %}executor{% else %}unused_executor{% endif %}/task_result_aggregator.py +152 -0
- agent_starter_pack/cli/commands/create.py +1256 -0
- agent_starter_pack/cli/commands/enhance.py +611 -0
- agent_starter_pack/cli/commands/list.py +203 -0
- agent_starter_pack/cli/commands/register_gemini_enterprise.py +1070 -0
- agent_starter_pack/cli/commands/setup_cicd.py +862 -0
- {src → agent_starter_pack}/cli/main.py +10 -2
- {src → agent_starter_pack}/cli/utils/cicd.py +139 -48
- agent_starter_pack/cli/utils/gcp.py +263 -0
- agent_starter_pack/cli/utils/logging.py +103 -0
- agent_starter_pack/cli/utils/remote_template.py +677 -0
- agent_starter_pack/cli/utils/template.py +1466 -0
- {src → agent_starter_pack}/data_ingestion/data_ingestion_pipeline/components/process_data.py +1 -1
- {src → agent_starter_pack}/data_ingestion/data_ingestion_pipeline/submit_pipeline.py +20 -6
- {src → agent_starter_pack}/data_ingestion/pyproject.toml +1 -0
- {src → agent_starter_pack}/data_ingestion/uv.lock +602 -494
- agent_starter_pack/deployment_targets/agent_engine/tests/integration/test_agent_engine_app.py +484 -0
- agent_starter_pack/deployment_targets/agent_engine/tests/load_test/README.md +84 -0
- agent_starter_pack/deployment_targets/agent_engine/tests/load_test/load_test.py +424 -0
- agent_starter_pack/deployment_targets/agent_engine/tests/{% if cookiecutter.is_a2a %}helpers.py{% else %}unused_helpers.py{% endif %} +138 -0
- agent_starter_pack/deployment_targets/agent_engine/{{cookiecutter.agent_directory}}/agent_engine_app.py +263 -0
- agent_starter_pack/deployment_targets/agent_engine/{{cookiecutter.agent_directory}}/app_utils/deploy.py +414 -0
- agent_starter_pack/deployment_targets/agent_engine/{{cookiecutter.agent_directory}}/app_utils/{% if cookiecutter.is_adk_live %}expose_app.py{% else %}unused_expose_app.py{% endif %} +519 -0
- agent_starter_pack/deployment_targets/cloud_run/Dockerfile +51 -0
- agent_starter_pack/deployment_targets/cloud_run/deployment/terraform/dev/service.tf +243 -0
- agent_starter_pack/deployment_targets/cloud_run/deployment/terraform/service.tf +417 -0
- agent_starter_pack/deployment_targets/cloud_run/tests/integration/test_server_e2e.py +705 -0
- agent_starter_pack/deployment_targets/cloud_run/tests/load_test/.results/.placeholder +321 -0
- agent_starter_pack/deployment_targets/cloud_run/tests/load_test/README.md +165 -0
- agent_starter_pack/deployment_targets/cloud_run/tests/load_test/load_test.py +329 -0
- agent_starter_pack/deployment_targets/cloud_run/{{cookiecutter.agent_directory}}/fast_api_app.py +556 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/package-lock.json +79 -1044
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/package.json +1 -9
- agent_starter_pack/frontends/adk_live_react/frontend/src/App.tsx +65 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/components/logger/Logger.tsx +8 -3
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/components/logger/logger.scss +26 -0
- agent_starter_pack/frontends/adk_live_react/frontend/src/components/side-panel/SidePanel.tsx +516 -0
- agent_starter_pack/frontends/adk_live_react/frontend/src/components/side-panel/side-panel.scss +563 -0
- agent_starter_pack/frontends/adk_live_react/frontend/src/components/transcription-preview/TranscriptionPreview.tsx +106 -0
- agent_starter_pack/frontends/adk_live_react/frontend/src/components/transcription-preview/transcription-preview.scss +150 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/hooks/use-live-api.ts +8 -2
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/multimodal-live-types.ts +40 -2
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/utils/audio-recorder.ts +1 -1
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/utils/audio-streamer.ts +1 -1
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/utils/multimodal-live-client.ts +210 -24
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/utils/utils.ts +27 -5
- agent_starter_pack/resources/docs/adk-cheatsheet.md +1628 -0
- agent_starter_pack/resources/locks/uv-adk_a2a_base-agent_engine.lock +4966 -0
- agent_starter_pack/resources/locks/uv-adk_a2a_base-cloud_run.lock +5011 -0
- agent_starter_pack/resources/locks/uv-adk_base-agent_engine.lock +4946 -0
- agent_starter_pack/resources/locks/uv-adk_base-cloud_run.lock +4991 -0
- agent_starter_pack/resources/locks/uv-adk_live-agent_engine.lock +4963 -0
- agent_starter_pack/resources/locks/uv-adk_live-cloud_run.lock +5006 -0
- agent_starter_pack/resources/locks/uv-agentic_rag-agent_engine.lock +5487 -0
- agent_starter_pack/resources/locks/uv-agentic_rag-cloud_run.lock +5532 -0
- agent_starter_pack/resources/locks/uv-langgraph_base-agent_engine.lock +5788 -0
- agent_starter_pack/resources/locks/uv-langgraph_base-cloud_run.lock +5811 -0
- {src → agent_starter_pack}/utils/generate_locks.py +15 -12
- {src → agent_starter_pack}/utils/lock_utils.py +4 -7
- {src → agent_starter_pack}/utils/watch_and_rebuild.py +2 -2
- agent_starter_pack-0.21.0.dist-info/METADATA +182 -0
- agent_starter_pack-0.21.0.dist-info/RECORD +171 -0
- agent_starter_pack-0.21.0.dist-info/entry_points.txt +2 -0
- llm.txt +362 -0
- agent_starter_pack-0.3.3.dist-info/METADATA +0 -164
- agent_starter_pack-0.3.3.dist-info/RECORD +0 -176
- agent_starter_pack-0.3.3.dist-info/entry_points.txt +0 -2
- agents/crewai_coding_crew/README.md +0 -34
- agents/crewai_coding_crew/app/agent.py +0 -86
- agents/crewai_coding_crew/app/crew/config/agents.yaml +0 -39
- agents/crewai_coding_crew/app/crew/config/tasks.yaml +0 -37
- agents/crewai_coding_crew/app/crew/crew.py +0 -71
- agents/crewai_coding_crew/tests/integration/test_agent.py +0 -47
- agents/langgraph_base_react/README.md +0 -9
- agents/langgraph_base_react/app/agent.py +0 -73
- agents/live_api/README.md +0 -37
- agents/live_api/app/agent.py +0 -78
- agents/live_api/app/server.py +0 -196
- agents/live_api/app/templates.py +0 -51
- agents/live_api/app/vector_store.py +0 -55
- agents/live_api/template/.templateconfig.yaml +0 -29
- agents/live_api/tests/integration/test_server_e2e.py +0 -254
- agents/live_api/tests/load_test/load_test.py +0 -40
- agents/live_api/tests/unit/test_server.py +0 -143
- src/base_template/Makefile +0 -72
- src/base_template/README.md +0 -208
- src/base_template/app/__init__.py +0 -3
- src/base_template/app/utils/tracing.py +0 -155
- src/base_template/deployment/README.md +0 -126
- src/base_template/deployment/cd/staging.yaml +0 -216
- src/base_template/deployment/terraform/dev/log_sinks.tf +0 -63
- src/base_template/deployment/terraform/log_sinks.tf +0 -70
- src/base_template/deployment/terraform/providers.tf +0 -37
- src/cli/commands/create.py +0 -664
- src/cli/commands/setup_cicd.py +0 -829
- src/cli/utils/gcp.py +0 -117
- src/cli/utils/logging.py +0 -51
- src/cli/utils/template.py +0 -737
- src/deployment_targets/agent_engine/app/agent_engine_app.py +0 -336
- src/deployment_targets/agent_engine/notebooks/intro_agent_engine.ipynb +0 -1025
- src/deployment_targets/agent_engine/tests/integration/test_agent_engine_app.py +0 -183
- src/deployment_targets/agent_engine/tests/load_test/README.md +0 -42
- src/deployment_targets/agent_engine/tests/load_test/load_test.py +0 -107
- src/deployment_targets/cloud_run/app/server.py +0 -154
- src/deployment_targets/cloud_run/tests/integration/test_server_e2e.py +0 -249
- src/deployment_targets/cloud_run/tests/load_test/.results/.placeholder +0 -0
- src/deployment_targets/cloud_run/tests/load_test/README.md +0 -83
- src/deployment_targets/cloud_run/tests/load_test/load_test.py +0 -118
- src/deployment_targets/cloud_run/uv.lock +0 -6952
- src/frontends/live_api_react/frontend/src/App.tsx +0 -205
- src/frontends/live_api_react/frontend/src/components/control-tray/ControlTray.tsx +0 -217
- src/frontends/live_api_react/frontend/src/components/control-tray/control-tray.scss +0 -201
- src/frontends/live_api_react/frontend/src/components/side-panel/SidePanel.tsx +0 -161
- src/frontends/live_api_react/frontend/src/components/side-panel/side-panel.scss +0 -285
- src/frontends/streamlit/frontend/side_bar.py +0 -214
- src/frontends/streamlit/frontend/streamlit_app.py +0 -265
- src/frontends/streamlit/frontend/style/app_markdown.py +0 -37
- src/frontends/streamlit/frontend/utils/chat_utils.py +0 -67
- src/frontends/streamlit/frontend/utils/local_chat_history.py +0 -125
- src/frontends/streamlit/frontend/utils/message_editing.py +0 -59
- src/frontends/streamlit/frontend/utils/multimodal_utils.py +0 -217
- src/frontends/streamlit/frontend/utils/stream_handler.py +0 -301
- src/frontends/streamlit/frontend/utils/title_summary.py +0 -94
- src/frontends/streamlit_adk/frontend/side_bar.py +0 -214
- src/frontends/streamlit_adk/frontend/streamlit_app.py +0 -314
- src/frontends/streamlit_adk/frontend/style/app_markdown.py +0 -37
- src/frontends/streamlit_adk/frontend/utils/chat_utils.py +0 -84
- src/frontends/streamlit_adk/frontend/utils/local_chat_history.py +0 -110
- src/frontends/streamlit_adk/frontend/utils/message_editing.py +0 -61
- src/frontends/streamlit_adk/frontend/utils/multimodal_utils.py +0 -223
- src/frontends/streamlit_adk/frontend/utils/stream_handler.py +0 -311
- src/frontends/streamlit_adk/frontend/utils/title_summary.py +0 -129
- src/resources/containers/data_processing/Dockerfile +0 -27
- src/resources/containers/e2e-tests/Dockerfile +0 -19
- src/resources/idx/.idx/dev.nix +0 -57
- src/resources/idx/idx-template.json +0 -21
- src/resources/idx/idx-template.nix +0 -26
- src/resources/locks/uv-adk_base-agent_engine.lock +0 -5338
- src/resources/locks/uv-adk_base-cloud_run.lock +0 -5930
- src/resources/locks/uv-agentic_rag-agent_engine.lock +0 -5528
- src/resources/locks/uv-agentic_rag-cloud_run.lock +0 -6120
- src/resources/locks/uv-crewai_coding_crew-agent_engine.lock +0 -6231
- src/resources/locks/uv-crewai_coding_crew-cloud_run.lock +0 -6839
- src/resources/locks/uv-langgraph_base_react-agent_engine.lock +0 -5233
- src/resources/locks/uv-langgraph_base_react-cloud_run.lock +0 -5862
- src/resources/locks/uv-live_api-cloud_run.lock +0 -5832
- src/resources/setup_cicd/cicd_variables.tf +0 -41
- src/resources/setup_cicd/github.tf +0 -87
- {agents → agent_starter_pack/agents}/agentic_rag/app/retrievers.py +0 -0
- {agents → agent_starter_pack/agents}/agentic_rag/app/templates.py +0 -0
- {src → agent_starter_pack}/base_template/deployment/terraform/dev/vars/env.tfvars +0 -0
- {src → agent_starter_pack}/base_template/tests/unit/test_dummy.py +0 -0
- {src/deployment_targets/agent_engine/app/utils → agent_starter_pack/base_template/{{cookiecutter.agent_directory}}/app_utils}/gcs.py +0 -0
- {src → agent_starter_pack}/cli/utils/__init__.py +0 -0
- {src → agent_starter_pack}/cli/utils/datastores.py +0 -0
- {src → agent_starter_pack}/cli/utils/version.py +0 -0
- {src → agent_starter_pack}/data_ingestion/README.md +0 -0
- {src → agent_starter_pack}/data_ingestion/data_ingestion_pipeline/components/ingest_data.py +0 -0
- {src → agent_starter_pack}/data_ingestion/data_ingestion_pipeline/pipeline.py +0 -0
- {src → agent_starter_pack}/deployment_targets/agent_engine/deployment_metadata.json +0 -0
- {src → agent_starter_pack}/deployment_targets/agent_engine/tests/load_test/.results/.placeholder +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/public/favicon.ico +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/public/index.html +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/public/robots.txt +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/App.scss +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/App.test.tsx +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/components/audio-pulse/AudioPulse.tsx +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/components/audio-pulse/audio-pulse.scss +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/components/logger/mock-logs.ts +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/contexts/LiveAPIContext.tsx +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/hooks/use-media-stream-mux.ts +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/hooks/use-screen-capture.ts +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/hooks/use-webcam.ts +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/index.css +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/index.tsx +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/react-app-env.d.ts +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/reportWebVitals.ts +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/setupTests.ts +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/utils/audioworklet-registry.ts +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/utils/store-logger.ts +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/utils/worklets/audio-processing.ts +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/src/utils/worklets/vol-meter.ts +0 -0
- {src/frontends/live_api_react → agent_starter_pack/frontends/adk_live_react}/frontend/tsconfig.json +0 -0
- {agent_starter_pack-0.3.3.dist-info → agent_starter_pack-0.21.0.dist-info}/WHEEL +0 -0
- {agent_starter_pack-0.3.3.dist-info → agent_starter_pack-0.21.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
# Copyright 2025 Google LLC
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
# mypy: disable-error-code="arg-type"
|
|
16
|
-
import json
|
|
17
|
-
import uuid
|
|
18
|
-
from collections.abc import Sequence
|
|
19
|
-
from functools import partial
|
|
20
|
-
from typing import Any
|
|
21
|
-
|
|
22
|
-
import streamlit as st
|
|
23
|
-
from langchain_core.messages import HumanMessage
|
|
24
|
-
from streamlit_feedback import streamlit_feedback
|
|
25
|
-
|
|
26
|
-
from frontend.side_bar import SideBar
|
|
27
|
-
from frontend.style.app_markdown import MARKDOWN_STR
|
|
28
|
-
from frontend.utils.local_chat_history import LocalChatMessageHistory
|
|
29
|
-
from frontend.utils.message_editing import MessageEditing
|
|
30
|
-
from frontend.utils.multimodal_utils import format_content, get_parts_from_files
|
|
31
|
-
from frontend.utils.stream_handler import Client, StreamHandler, get_chain_response
|
|
32
|
-
|
|
33
|
-
USER = "my_user"
|
|
34
|
-
EMPTY_CHAT_NAME = "Empty chat"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def setup_page() -> None:
|
|
38
|
-
"""Configure the Streamlit page settings."""
|
|
39
|
-
st.set_page_config(
|
|
40
|
-
page_title="Playground",
|
|
41
|
-
layout="wide",
|
|
42
|
-
initial_sidebar_state="auto",
|
|
43
|
-
menu_items=None,
|
|
44
|
-
)
|
|
45
|
-
st.title("Playground")
|
|
46
|
-
st.markdown(MARKDOWN_STR, unsafe_allow_html=True)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def initialize_session_state() -> None:
|
|
50
|
-
"""Initialize the session state with default values."""
|
|
51
|
-
if "user_chats" not in st.session_state:
|
|
52
|
-
st.session_state["session_id"] = str(uuid.uuid4())
|
|
53
|
-
st.session_state.uploader_key = 0
|
|
54
|
-
st.session_state.run_id = None
|
|
55
|
-
st.session_state.user_id = USER
|
|
56
|
-
st.session_state["gcs_uris_to_be_sent"] = ""
|
|
57
|
-
st.session_state.modified_prompt = None
|
|
58
|
-
st.session_state.session_db = LocalChatMessageHistory(
|
|
59
|
-
session_id=st.session_state["session_id"],
|
|
60
|
-
user_id=st.session_state["user_id"],
|
|
61
|
-
)
|
|
62
|
-
st.session_state.user_chats = (
|
|
63
|
-
st.session_state.session_db.get_all_conversations()
|
|
64
|
-
)
|
|
65
|
-
st.session_state.user_chats[st.session_state["session_id"]] = {
|
|
66
|
-
"title": EMPTY_CHAT_NAME,
|
|
67
|
-
"messages": [],
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def display_messages() -> None:
|
|
72
|
-
"""Display all messages in the current chat session."""
|
|
73
|
-
messages = st.session_state.user_chats[st.session_state["session_id"]]["messages"]
|
|
74
|
-
tool_calls_map = {} # Map tool_call_id to tool call input
|
|
75
|
-
|
|
76
|
-
for i, message in enumerate(messages):
|
|
77
|
-
if message["type"] in ["ai", "human"] and message["content"]:
|
|
78
|
-
display_chat_message(message, i)
|
|
79
|
-
elif message.get("tool_calls"):
|
|
80
|
-
# Store each tool call input mapped by its ID
|
|
81
|
-
for tool_call in message["tool_calls"]:
|
|
82
|
-
tool_calls_map[tool_call["id"]] = tool_call
|
|
83
|
-
elif message["type"] == "tool":
|
|
84
|
-
# Look up the corresponding tool call input by ID
|
|
85
|
-
tool_call_id = message["tool_call_id"]
|
|
86
|
-
if tool_call_id in tool_calls_map:
|
|
87
|
-
display_tool_output(tool_calls_map[tool_call_id], message)
|
|
88
|
-
else:
|
|
89
|
-
st.error(f"Could not find tool call input for ID: {tool_call_id}")
|
|
90
|
-
else:
|
|
91
|
-
st.error(f"Unexpected message type: {message['type']}")
|
|
92
|
-
st.write("Full messages list:", messages)
|
|
93
|
-
raise ValueError(f"Unexpected message type: {message['type']}")
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
def display_chat_message(message: dict[str, Any], index: int) -> None:
|
|
97
|
-
"""Display a single chat message with edit, refresh, and delete options."""
|
|
98
|
-
chat_message = st.chat_message(message["type"])
|
|
99
|
-
with chat_message:
|
|
100
|
-
st.markdown(format_content(message["content"]), unsafe_allow_html=True)
|
|
101
|
-
col1, col2, col3 = st.columns([2, 2, 94])
|
|
102
|
-
display_message_buttons(message, index, col1, col2, col3)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def display_message_buttons(
|
|
106
|
-
message: dict[str, Any], index: int, col1: Any, col2: Any, col3: Any
|
|
107
|
-
) -> None:
|
|
108
|
-
"""Display edit, refresh, and delete buttons for a chat message."""
|
|
109
|
-
edit_button = f"{index}_edit"
|
|
110
|
-
refresh_button = f"{index}_refresh"
|
|
111
|
-
delete_button = f"{index}_delete"
|
|
112
|
-
content = (
|
|
113
|
-
message["content"]
|
|
114
|
-
if isinstance(message["content"], str)
|
|
115
|
-
else message["content"][-1]["text"]
|
|
116
|
-
)
|
|
117
|
-
|
|
118
|
-
with col1:
|
|
119
|
-
st.button(label="✎", key=edit_button, type="primary")
|
|
120
|
-
if message["type"] == "human":
|
|
121
|
-
with col2:
|
|
122
|
-
st.button(
|
|
123
|
-
label="⟳",
|
|
124
|
-
key=refresh_button,
|
|
125
|
-
type="primary",
|
|
126
|
-
on_click=partial(MessageEditing.refresh_message, st, index, content),
|
|
127
|
-
)
|
|
128
|
-
with col3:
|
|
129
|
-
st.button(
|
|
130
|
-
label="X",
|
|
131
|
-
key=delete_button,
|
|
132
|
-
type="primary",
|
|
133
|
-
on_click=partial(MessageEditing.delete_message, st, index),
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
if st.session_state[edit_button]:
|
|
137
|
-
st.text_area(
|
|
138
|
-
"Edit your message:",
|
|
139
|
-
value=content,
|
|
140
|
-
key=f"edit_box_{index}",
|
|
141
|
-
on_change=partial(MessageEditing.edit_message, st, index, message["type"]),
|
|
142
|
-
)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
def display_tool_output(
|
|
146
|
-
tool_call_input: dict[str, Any], tool_call_output: dict[str, Any]
|
|
147
|
-
) -> None:
|
|
148
|
-
"""Display the input and output of a tool call in an expander."""
|
|
149
|
-
tool_expander = st.expander(label="Tool Calls:", expanded=False)
|
|
150
|
-
with tool_expander:
|
|
151
|
-
msg = (
|
|
152
|
-
f"\n\nEnding tool: `{tool_call_input}` with\n **args:**\n"
|
|
153
|
-
f"```\n{json.dumps(tool_call_input, indent=2)}\n```\n"
|
|
154
|
-
f"\n\n**output:**\n "
|
|
155
|
-
f"```\n{json.dumps(tool_call_output, indent=2)}\n```"
|
|
156
|
-
)
|
|
157
|
-
st.markdown(msg, unsafe_allow_html=True)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
def handle_user_input(side_bar: SideBar) -> None:
|
|
161
|
-
"""Process user input, generate AI response, and update chat history."""
|
|
162
|
-
prompt = st.chat_input() or st.session_state.modified_prompt
|
|
163
|
-
if prompt:
|
|
164
|
-
st.session_state.modified_prompt = None
|
|
165
|
-
parts = get_parts_from_files(
|
|
166
|
-
upload_gcs_checkbox=st.session_state.checkbox_state,
|
|
167
|
-
uploaded_files=side_bar.uploaded_files,
|
|
168
|
-
gcs_uris=side_bar.gcs_uris,
|
|
169
|
-
)
|
|
170
|
-
st.session_state["gcs_uris_to_be_sent"] = ""
|
|
171
|
-
parts.append({"type": "text", "text": prompt})
|
|
172
|
-
st.session_state.user_chats[st.session_state["session_id"]]["messages"].append(
|
|
173
|
-
HumanMessage(content=parts).model_dump()
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
display_user_input(parts)
|
|
177
|
-
generate_ai_response(
|
|
178
|
-
remote_agent_engine_id=side_bar.remote_agent_engine_id,
|
|
179
|
-
agent_callable_path=side_bar.agent_callable_path,
|
|
180
|
-
url=side_bar.url_input_field,
|
|
181
|
-
authenticate_request=side_bar.should_authenticate_request,
|
|
182
|
-
)
|
|
183
|
-
update_chat_title()
|
|
184
|
-
if len(parts) > 1:
|
|
185
|
-
st.session_state.uploader_key += 1
|
|
186
|
-
st.rerun()
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
def display_user_input(parts: Sequence[dict[str, Any]]) -> None:
|
|
190
|
-
"""Display the user's input in the chat interface."""
|
|
191
|
-
human_message = st.chat_message("human")
|
|
192
|
-
with human_message:
|
|
193
|
-
existing_user_input = format_content(parts)
|
|
194
|
-
st.markdown(existing_user_input, unsafe_allow_html=True)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
def generate_ai_response(
|
|
198
|
-
remote_agent_engine_id: str | None = None,
|
|
199
|
-
agent_callable_path: str | None = None,
|
|
200
|
-
url: str | None = None,
|
|
201
|
-
authenticate_request: bool = False,
|
|
202
|
-
) -> None:
|
|
203
|
-
"""Generate and display the AI's response to the user's input."""
|
|
204
|
-
ai_message = st.chat_message("ai")
|
|
205
|
-
with ai_message:
|
|
206
|
-
status = st.status("Generating answer🤖")
|
|
207
|
-
stream_handler = StreamHandler(st=st)
|
|
208
|
-
client = Client(
|
|
209
|
-
remote_agent_engine_id=remote_agent_engine_id,
|
|
210
|
-
agent_callable_path=agent_callable_path,
|
|
211
|
-
url=url,
|
|
212
|
-
authenticate_request=authenticate_request,
|
|
213
|
-
)
|
|
214
|
-
get_chain_response(st=st, client=client, stream_handler=stream_handler)
|
|
215
|
-
status.update(label="Finished!", state="complete", expanded=False)
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
def update_chat_title() -> None:
|
|
219
|
-
"""Update the chat title if it's currently empty."""
|
|
220
|
-
if (
|
|
221
|
-
st.session_state.user_chats[st.session_state["session_id"]]["title"]
|
|
222
|
-
== EMPTY_CHAT_NAME
|
|
223
|
-
):
|
|
224
|
-
st.session_state.session_db.set_title(
|
|
225
|
-
st.session_state.user_chats[st.session_state["session_id"]]
|
|
226
|
-
)
|
|
227
|
-
st.session_state.session_db.upsert_session(
|
|
228
|
-
st.session_state.user_chats[st.session_state["session_id"]]
|
|
229
|
-
)
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
def display_feedback(side_bar: SideBar) -> None:
|
|
233
|
-
"""Display a feedback component and log the feedback if provided."""
|
|
234
|
-
if st.session_state.run_id is not None:
|
|
235
|
-
feedback = streamlit_feedback(
|
|
236
|
-
feedback_type="faces",
|
|
237
|
-
optional_text_label="[Optional] Please provide an explanation",
|
|
238
|
-
key=f"feedback-{st.session_state.run_id}",
|
|
239
|
-
)
|
|
240
|
-
if feedback is not None:
|
|
241
|
-
client = Client(
|
|
242
|
-
remote_agent_engine_id=side_bar.remote_agent_engine_id,
|
|
243
|
-
agent_callable_path=side_bar.agent_callable_path,
|
|
244
|
-
url=side_bar.url_input_field,
|
|
245
|
-
authenticate_request=side_bar.should_authenticate_request,
|
|
246
|
-
)
|
|
247
|
-
client.log_feedback(
|
|
248
|
-
feedback_dict=feedback,
|
|
249
|
-
run_id=st.session_state.run_id,
|
|
250
|
-
)
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
def main() -> None:
|
|
254
|
-
"""Main function to set up and run the Streamlit app."""
|
|
255
|
-
setup_page()
|
|
256
|
-
initialize_session_state()
|
|
257
|
-
side_bar = SideBar(st=st)
|
|
258
|
-
side_bar.init_side_bar()
|
|
259
|
-
display_messages()
|
|
260
|
-
handle_user_input(side_bar=side_bar)
|
|
261
|
-
display_feedback(side_bar=side_bar)
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
if __name__ == "__main__":
|
|
265
|
-
main()
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# Copyright 2025 Google LLC
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
MARKDOWN_STR = """
|
|
16
|
-
<style>
|
|
17
|
-
button[kind="primary"] {
|
|
18
|
-
background: none!important;
|
|
19
|
-
border: 0;
|
|
20
|
-
padding: 20!important;
|
|
21
|
-
color: grey !important;
|
|
22
|
-
text-decoration: none;
|
|
23
|
-
cursor: pointer;
|
|
24
|
-
border: none !important;
|
|
25
|
-
# float: right;
|
|
26
|
-
}
|
|
27
|
-
button[kind="primary"]:hover {
|
|
28
|
-
text-decoration: none;
|
|
29
|
-
color: white !important;
|
|
30
|
-
}
|
|
31
|
-
button[kind="primary"]:focus {
|
|
32
|
-
outline: none !important;
|
|
33
|
-
box-shadow: none !important;
|
|
34
|
-
color: !important;
|
|
35
|
-
}
|
|
36
|
-
</style>
|
|
37
|
-
"""
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# Copyright 2025 Google LLC
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
import os
|
|
16
|
-
from pathlib import Path
|
|
17
|
-
from typing import Any
|
|
18
|
-
|
|
19
|
-
import yaml
|
|
20
|
-
|
|
21
|
-
SAVED_CHAT_PATH = str(os.getcwd()) + "/.saved_chats"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def clean_text(text: str) -> str:
|
|
25
|
-
"""Preprocess the input text by removing leading and trailing newlines."""
|
|
26
|
-
if not text:
|
|
27
|
-
return text
|
|
28
|
-
|
|
29
|
-
if text.startswith("\n"):
|
|
30
|
-
text = text[1:]
|
|
31
|
-
if text.endswith("\n"):
|
|
32
|
-
text = text[:-1]
|
|
33
|
-
return text
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def sanitize_messages(
|
|
37
|
-
messages: list[dict[str, str | list[dict[str, str]]]],
|
|
38
|
-
) -> list[dict[str, str | list[dict[str, str]]]]:
|
|
39
|
-
"""Preprocess and fix the content of messages."""
|
|
40
|
-
for message in messages:
|
|
41
|
-
if isinstance(message["content"], list):
|
|
42
|
-
for part in message["content"]:
|
|
43
|
-
if part["type"] == "text":
|
|
44
|
-
part["text"] = clean_text(part["text"])
|
|
45
|
-
else:
|
|
46
|
-
message["content"] = clean_text(message["content"])
|
|
47
|
-
return messages
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def save_chat(st: Any) -> None:
|
|
51
|
-
"""Save the current chat session to a YAML file."""
|
|
52
|
-
Path(SAVED_CHAT_PATH).mkdir(parents=True, exist_ok=True)
|
|
53
|
-
session_id = st.session_state["session_id"]
|
|
54
|
-
session = st.session_state.user_chats[session_id]
|
|
55
|
-
messages = session.get("messages", [])
|
|
56
|
-
if len(messages) > 0:
|
|
57
|
-
session["messages"] = sanitize_messages(session["messages"])
|
|
58
|
-
filename = f"{session_id}.yaml"
|
|
59
|
-
with open(Path(SAVED_CHAT_PATH) / filename, "w") as file:
|
|
60
|
-
yaml.dump(
|
|
61
|
-
[session],
|
|
62
|
-
file,
|
|
63
|
-
allow_unicode=True,
|
|
64
|
-
default_flow_style=False,
|
|
65
|
-
encoding="utf-8",
|
|
66
|
-
)
|
|
67
|
-
st.toast(f"Chat saved to path: ↓ {Path(SAVED_CHAT_PATH) / filename}")
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# Copyright 2025 Google LLC
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
import os
|
|
16
|
-
from datetime import datetime
|
|
17
|
-
|
|
18
|
-
import yaml
|
|
19
|
-
from langchain_core.chat_history import BaseChatMessageHistory
|
|
20
|
-
|
|
21
|
-
from frontend.utils.title_summary import chain_title
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class LocalChatMessageHistory(BaseChatMessageHistory):
|
|
25
|
-
"""Manages local storage and retrieval of chat message history."""
|
|
26
|
-
|
|
27
|
-
def __init__(
|
|
28
|
-
self,
|
|
29
|
-
user_id: str,
|
|
30
|
-
session_id: str = "default",
|
|
31
|
-
base_dir: str = ".streamlit_chats",
|
|
32
|
-
) -> None:
|
|
33
|
-
self.user_id = user_id
|
|
34
|
-
self.session_id = session_id
|
|
35
|
-
self.base_dir = base_dir
|
|
36
|
-
self.user_dir = os.path.join(self.base_dir, self.user_id)
|
|
37
|
-
self.session_file = os.path.join(self.user_dir, f"{session_id}.yaml")
|
|
38
|
-
|
|
39
|
-
os.makedirs(self.user_dir, exist_ok=True)
|
|
40
|
-
|
|
41
|
-
def get_session(self, session_id: str) -> None:
|
|
42
|
-
"""Updates the session ID and file path for the current session."""
|
|
43
|
-
self.session_id = session_id
|
|
44
|
-
self.session_file = os.path.join(self.user_dir, f"{session_id}.yaml")
|
|
45
|
-
|
|
46
|
-
def get_all_conversations(self) -> dict[str, dict]:
|
|
47
|
-
"""Retrieves all conversations for the current user."""
|
|
48
|
-
conversations = {}
|
|
49
|
-
for filename in os.listdir(self.user_dir):
|
|
50
|
-
if filename.endswith(".yaml"):
|
|
51
|
-
file_path = os.path.join(self.user_dir, filename)
|
|
52
|
-
with open(file_path) as f:
|
|
53
|
-
conversation = yaml.safe_load(f)
|
|
54
|
-
if not isinstance(conversation, list) or len(conversation) > 1:
|
|
55
|
-
raise ValueError(
|
|
56
|
-
f"""Invalid format in {file_path}.
|
|
57
|
-
YAML file can only contain one conversation with the following
|
|
58
|
-
structure.
|
|
59
|
-
- messages:
|
|
60
|
-
- content: [message text]
|
|
61
|
-
- type: (human or ai)"""
|
|
62
|
-
)
|
|
63
|
-
conversation = conversation[0]
|
|
64
|
-
if "title" not in conversation:
|
|
65
|
-
conversation["title"] = filename
|
|
66
|
-
conversations[filename[:-5]] = conversation
|
|
67
|
-
return dict(
|
|
68
|
-
sorted(conversations.items(), key=lambda x: x[1].get("update_time", ""))
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
def upsert_session(self, session: dict) -> None:
|
|
72
|
-
"""Updates or inserts a session into the local storage."""
|
|
73
|
-
session["update_time"] = datetime.now().isoformat()
|
|
74
|
-
with open(self.session_file, "w") as f:
|
|
75
|
-
yaml.dump(
|
|
76
|
-
[session],
|
|
77
|
-
f,
|
|
78
|
-
allow_unicode=True,
|
|
79
|
-
default_flow_style=False,
|
|
80
|
-
encoding="utf-8",
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
def set_title(self, session: dict) -> None:
|
|
84
|
-
"""
|
|
85
|
-
Set the title for the given session.
|
|
86
|
-
|
|
87
|
-
This method generates a title for the session based on its messages.
|
|
88
|
-
If the session has messages, it appends a special message to prompt
|
|
89
|
-
for title creation, generates the title using a title chain, and
|
|
90
|
-
updates the session with the new title.
|
|
91
|
-
|
|
92
|
-
Args:
|
|
93
|
-
session (dict): A dictionary containing session information,
|
|
94
|
-
including messages.
|
|
95
|
-
|
|
96
|
-
Returns:
|
|
97
|
-
None
|
|
98
|
-
"""
|
|
99
|
-
if session["messages"]:
|
|
100
|
-
messages = session["messages"] + [
|
|
101
|
-
{
|
|
102
|
-
"type": "human",
|
|
103
|
-
"content": "End of conversation - Create one single title",
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
# Remove the tool calls from conversation
|
|
107
|
-
messages = [
|
|
108
|
-
msg
|
|
109
|
-
for msg in messages
|
|
110
|
-
if msg["type"] in ("ai", "human") and isinstance(msg["content"], str)
|
|
111
|
-
]
|
|
112
|
-
|
|
113
|
-
response = chain_title.invoke(messages)
|
|
114
|
-
title = (
|
|
115
|
-
response.content.strip()
|
|
116
|
-
if isinstance(response.content, str)
|
|
117
|
-
else str(response.content)
|
|
118
|
-
)
|
|
119
|
-
session["title"] = title
|
|
120
|
-
self.upsert_session(session)
|
|
121
|
-
|
|
122
|
-
def clear(self) -> None:
|
|
123
|
-
"""Removes the current session file if it exists."""
|
|
124
|
-
if os.path.exists(self.session_file):
|
|
125
|
-
os.remove(self.session_file)
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# Copyright 2025 Google LLC
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
|
|
15
|
-
# fmt: off
|
|
16
|
-
|
|
17
|
-
from typing import Any
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class MessageEditing:
|
|
21
|
-
"""Provides methods for editing, refreshing, and deleting chat messages."""
|
|
22
|
-
|
|
23
|
-
@staticmethod
|
|
24
|
-
def edit_message(st: Any, button_idx: int, message_type: str) -> None:
|
|
25
|
-
"""Edit a message in the chat history."""
|
|
26
|
-
button_id = f"edit_box_{button_idx}"
|
|
27
|
-
if message_type == "human":
|
|
28
|
-
messages = st.session_state.user_chats[st.session_state["session_id"]][
|
|
29
|
-
"messages"
|
|
30
|
-
]
|
|
31
|
-
st.session_state.user_chats[st.session_state["session_id"]][
|
|
32
|
-
"messages"
|
|
33
|
-
] = messages[:button_idx]
|
|
34
|
-
st.session_state.modified_prompt = st.session_state[button_id]
|
|
35
|
-
else:
|
|
36
|
-
st.session_state.user_chats[st.session_state["session_id"]]["messages"][
|
|
37
|
-
button_idx
|
|
38
|
-
]["content"] = st.session_state[button_id]
|
|
39
|
-
|
|
40
|
-
@staticmethod
|
|
41
|
-
def refresh_message(st: Any, button_idx: int, content: str) -> None:
|
|
42
|
-
"""Refresh a message in the chat history."""
|
|
43
|
-
messages = st.session_state.user_chats[st.session_state["session_id"]][
|
|
44
|
-
"messages"
|
|
45
|
-
]
|
|
46
|
-
st.session_state.user_chats[st.session_state["session_id"]][
|
|
47
|
-
"messages"
|
|
48
|
-
] = messages[:button_idx]
|
|
49
|
-
st.session_state.modified_prompt = content
|
|
50
|
-
|
|
51
|
-
@staticmethod
|
|
52
|
-
def delete_message(st: Any, button_idx: int) -> None:
|
|
53
|
-
"""Delete a message from the chat history."""
|
|
54
|
-
messages = st.session_state.user_chats[st.session_state["session_id"]][
|
|
55
|
-
"messages"
|
|
56
|
-
]
|
|
57
|
-
st.session_state.user_chats[st.session_state["session_id"]][
|
|
58
|
-
"messages"
|
|
59
|
-
] = messages[:button_idx]
|