google-adk 1.6.1__py3-none-any.whl → 1.8.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.
- google/adk/a2a/converters/event_converter.py +5 -85
- google/adk/a2a/converters/request_converter.py +1 -2
- google/adk/a2a/executor/a2a_agent_executor.py +45 -16
- google/adk/a2a/logs/log_utils.py +1 -2
- google/adk/a2a/utils/__init__.py +0 -0
- google/adk/a2a/utils/agent_card_builder.py +544 -0
- google/adk/a2a/utils/agent_to_a2a.py +118 -0
- google/adk/agents/__init__.py +5 -0
- google/adk/agents/agent_config.py +46 -0
- google/adk/agents/base_agent.py +239 -41
- google/adk/agents/callback_context.py +41 -0
- google/adk/agents/common_configs.py +79 -0
- google/adk/agents/config_agent_utils.py +184 -0
- google/adk/agents/config_schemas/AgentConfig.json +566 -0
- google/adk/agents/invocation_context.py +5 -1
- google/adk/agents/live_request_queue.py +15 -0
- google/adk/agents/llm_agent.py +201 -9
- google/adk/agents/loop_agent.py +35 -1
- google/adk/agents/parallel_agent.py +24 -3
- google/adk/agents/remote_a2a_agent.py +17 -5
- google/adk/agents/sequential_agent.py +22 -1
- google/adk/artifacts/gcs_artifact_service.py +110 -20
- google/adk/auth/auth_handler.py +3 -3
- google/adk/auth/credential_manager.py +23 -23
- google/adk/auth/credential_service/base_credential_service.py +6 -6
- google/adk/auth/credential_service/in_memory_credential_service.py +10 -8
- google/adk/auth/credential_service/session_state_credential_service.py +8 -8
- google/adk/auth/exchanger/oauth2_credential_exchanger.py +3 -3
- google/adk/auth/oauth2_credential_util.py +2 -2
- google/adk/auth/refresher/oauth2_credential_refresher.py +4 -4
- google/adk/cli/agent_graph.py +3 -1
- google/adk/cli/browser/index.html +2 -2
- google/adk/cli/browser/main-W7QZBYAR.js +3914 -0
- google/adk/cli/browser/polyfills-B6TNHZQ6.js +17 -0
- google/adk/cli/cli_eval.py +87 -12
- google/adk/cli/cli_tools_click.py +143 -82
- google/adk/cli/fast_api.py +150 -69
- google/adk/cli/utils/agent_loader.py +35 -1
- google/adk/code_executors/base_code_executor.py +14 -19
- google/adk/code_executors/built_in_code_executor.py +4 -1
- google/adk/evaluation/base_eval_service.py +46 -2
- google/adk/evaluation/eval_metrics.py +4 -0
- google/adk/evaluation/eval_sets_manager.py +5 -1
- google/adk/evaluation/evaluation_generator.py +1 -1
- google/adk/evaluation/final_response_match_v2.py +2 -2
- google/adk/evaluation/gcs_eval_sets_manager.py +2 -1
- google/adk/evaluation/in_memory_eval_sets_manager.py +151 -0
- google/adk/evaluation/local_eval_service.py +389 -0
- google/adk/evaluation/local_eval_set_results_manager.py +2 -2
- google/adk/evaluation/local_eval_sets_manager.py +24 -9
- google/adk/evaluation/metric_evaluator_registry.py +16 -6
- google/adk/evaluation/vertex_ai_eval_facade.py +7 -1
- google/adk/events/event.py +7 -2
- google/adk/flows/llm_flows/auto_flow.py +6 -11
- google/adk/flows/llm_flows/base_llm_flow.py +66 -29
- google/adk/flows/llm_flows/contents.py +16 -10
- google/adk/flows/llm_flows/functions.py +89 -52
- google/adk/memory/in_memory_memory_service.py +21 -15
- google/adk/memory/vertex_ai_memory_bank_service.py +12 -10
- google/adk/models/anthropic_llm.py +46 -6
- google/adk/models/base_llm_connection.py +2 -0
- google/adk/models/gemini_llm_connection.py +17 -6
- google/adk/models/google_llm.py +46 -11
- google/adk/models/lite_llm.py +52 -22
- google/adk/plugins/__init__.py +17 -0
- google/adk/plugins/base_plugin.py +317 -0
- google/adk/plugins/plugin_manager.py +265 -0
- google/adk/runners.py +122 -18
- google/adk/sessions/database_session_service.py +51 -52
- google/adk/sessions/vertex_ai_session_service.py +27 -12
- google/adk/tools/__init__.py +2 -0
- google/adk/tools/_automatic_function_calling_util.py +20 -2
- google/adk/tools/agent_tool.py +15 -3
- google/adk/tools/apihub_tool/apihub_toolset.py +38 -39
- google/adk/tools/application_integration_tool/application_integration_toolset.py +35 -37
- google/adk/tools/application_integration_tool/integration_connector_tool.py +2 -3
- google/adk/tools/base_tool.py +9 -9
- google/adk/tools/base_toolset.py +29 -5
- google/adk/tools/bigquery/__init__.py +3 -3
- google/adk/tools/bigquery/metadata_tool.py +2 -0
- google/adk/tools/bigquery/query_tool.py +15 -1
- google/adk/tools/computer_use/__init__.py +13 -0
- google/adk/tools/computer_use/base_computer.py +265 -0
- google/adk/tools/computer_use/computer_use_tool.py +166 -0
- google/adk/tools/computer_use/computer_use_toolset.py +220 -0
- google/adk/tools/enterprise_search_tool.py +4 -2
- google/adk/tools/exit_loop_tool.py +1 -0
- google/adk/tools/google_api_tool/google_api_tool.py +16 -1
- google/adk/tools/google_api_tool/google_api_toolset.py +9 -7
- google/adk/tools/google_api_tool/google_api_toolsets.py +41 -20
- google/adk/tools/google_search_tool.py +4 -2
- google/adk/tools/langchain_tool.py +16 -6
- google/adk/tools/long_running_tool.py +21 -0
- google/adk/tools/mcp_tool/mcp_toolset.py +27 -28
- google/adk/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.py +5 -0
- google/adk/tools/openapi_tool/openapi_spec_parser/openapi_toolset.py +8 -8
- google/adk/tools/openapi_tool/openapi_spec_parser/rest_api_tool.py +4 -6
- google/adk/tools/retrieval/vertex_ai_rag_retrieval.py +3 -2
- google/adk/tools/tool_context.py +0 -10
- google/adk/tools/url_context_tool.py +4 -2
- google/adk/tools/vertex_ai_search_tool.py +4 -2
- google/adk/utils/model_name_utils.py +90 -0
- google/adk/version.py +1 -1
- {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/METADATA +3 -2
- {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/RECORD +108 -91
- google/adk/cli/browser/main-RXDVX3K6.js +0 -3914
- google/adk/cli/browser/polyfills-FFHMD2TL.js +0 -17
- {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/WHEEL +0 -0
- {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/entry_points.txt +0 -0
- {google_adk-1.6.1.dist-info → google_adk-1.8.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright 2025 Google LLC
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
var ce=globalThis;function te(t){return(ce.__Zone_symbol_prefix||"__zone_symbol__")+t}function ht(){let t=ce.performance;function n(I){t&&t.mark&&t.mark(I)}function a(I,s){t&&t.measure&&t.measure(I,s)}n("Zone");class e{static __symbol__=te;static assertZonePatched(){if(ce.Promise!==S.ZoneAwarePromise)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")}static get root(){let s=e.current;for(;s.parent;)s=s.parent;return s}static get current(){return b.zone}static get currentTask(){return D}static __load_patch(s,i,r=!1){if(S.hasOwnProperty(s)){let E=ce[te("forceDuplicateZoneCheck")]===!0;if(!r&&E)throw Error("Already loaded patch: "+s)}else if(!ce["__Zone_disable_"+s]){let E="Zone:"+s;n(E),S[s]=i(ce,e,R),a(E,E)}}get parent(){return this._parent}get name(){return this._name}_parent;_name;_properties;_zoneDelegate;constructor(s,i){this._parent=s,this._name=i?i.name||"unnamed":"<root>",this._properties=i&&i.properties||{},this._zoneDelegate=new f(this,this._parent&&this._parent._zoneDelegate,i)}get(s){let i=this.getZoneWith(s);if(i)return i._properties[s]}getZoneWith(s){let i=this;for(;i;){if(i._properties.hasOwnProperty(s))return i;i=i._parent}return null}fork(s){if(!s)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,s)}wrap(s,i){if(typeof s!="function")throw new Error("Expecting function got: "+s);let r=this._zoneDelegate.intercept(this,s,i),E=this;return function(){return E.runGuarded(r,this,arguments,i)}}run(s,i,r,E){b={parent:b,zone:this};try{return this._zoneDelegate.invoke(this,s,i,r,E)}finally{b=b.parent}}runGuarded(s,i=null,r,E){b={parent:b,zone:this};try{try{return this._zoneDelegate.invoke(this,s,i,r,E)}catch(x){if(this._zoneDelegate.handleError(this,x))throw x}}finally{b=b.parent}}runTask(s,i,r){if(s.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(s.zone||J).name+"; Execution: "+this.name+")");let E=s,{type:x,data:{isPeriodic:ee=!1,isRefreshable:M=!1}={}}=s;if(s.state===q&&(x===U||x===k))return;let he=s.state!=A;he&&E._transitionTo(A,d);let _e=D;D=E,b={parent:b,zone:this};try{x==k&&s.data&&!ee&&!M&&(s.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,E,i,r)}catch(Q){if(this._zoneDelegate.handleError(this,Q))throw Q}}finally{let Q=s.state;if(Q!==q&&Q!==X)if(x==U||ee||M&&Q===p)he&&E._transitionTo(d,A,p);else{let Te=E._zoneDelegates;this._updateTaskCount(E,-1),he&&E._transitionTo(q,A,q),M&&(E._zoneDelegates=Te)}b=b.parent,D=_e}}scheduleTask(s){if(s.zone&&s.zone!==this){let r=this;for(;r;){if(r===s.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${s.zone.name}`);r=r.parent}}s._transitionTo(p,q);let i=[];s._zoneDelegates=i,s._zone=this;try{s=this._zoneDelegate.scheduleTask(this,s)}catch(r){throw s._transitionTo(X,p,q),this._zoneDelegate.handleError(this,r),r}return s._zoneDelegates===i&&this._updateTaskCount(s,1),s.state==p&&s._transitionTo(d,p),s}scheduleMicroTask(s,i,r,E){return this.scheduleTask(new g(F,s,i,r,E,void 0))}scheduleMacroTask(s,i,r,E,x){return this.scheduleTask(new g(k,s,i,r,E,x))}scheduleEventTask(s,i,r,E,x){return this.scheduleTask(new g(U,s,i,r,E,x))}cancelTask(s){if(s.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(s.zone||J).name+"; Execution: "+this.name+")");if(!(s.state!==d&&s.state!==A)){s._transitionTo(V,d,A);try{this._zoneDelegate.cancelTask(this,s)}catch(i){throw s._transitionTo(X,V),this._zoneDelegate.handleError(this,i),i}return this._updateTaskCount(s,-1),s._transitionTo(q,V),s.runCount=-1,s}}_updateTaskCount(s,i){let r=s._zoneDelegates;i==-1&&(s._zoneDelegates=null);for(let E=0;E<r.length;E++)r[E]._updateTaskCount(s.type,i)}}let c={name:"",onHasTask:(I,s,i,r)=>I.hasTask(i,r),onScheduleTask:(I,s,i,r)=>I.scheduleTask(i,r),onInvokeTask:(I,s,i,r,E,x)=>I.invokeTask(i,r,E,x),onCancelTask:(I,s,i,r)=>I.cancelTask(i,r)};class f{get zone(){return this._zone}_zone;_taskCounts={microTask:0,macroTask:0,eventTask:0};_parentDelegate;_forkDlgt;_forkZS;_forkCurrZone;_interceptDlgt;_interceptZS;_interceptCurrZone;_invokeDlgt;_invokeZS;_invokeCurrZone;_handleErrorDlgt;_handleErrorZS;_handleErrorCurrZone;_scheduleTaskDlgt;_scheduleTaskZS;_scheduleTaskCurrZone;_invokeTaskDlgt;_invokeTaskZS;_invokeTaskCurrZone;_cancelTaskDlgt;_cancelTaskZS;_cancelTaskCurrZone;_hasTaskDlgt;_hasTaskDlgtOwner;_hasTaskZS;_hasTaskCurrZone;constructor(s,i,r){this._zone=s,this._parentDelegate=i,this._forkZS=r&&(r&&r.onFork?r:i._forkZS),this._forkDlgt=r&&(r.onFork?i:i._forkDlgt),this._forkCurrZone=r&&(r.onFork?this._zone:i._forkCurrZone),this._interceptZS=r&&(r.onIntercept?r:i._interceptZS),this._interceptDlgt=r&&(r.onIntercept?i:i._interceptDlgt),this._interceptCurrZone=r&&(r.onIntercept?this._zone:i._interceptCurrZone),this._invokeZS=r&&(r.onInvoke?r:i._invokeZS),this._invokeDlgt=r&&(r.onInvoke?i:i._invokeDlgt),this._invokeCurrZone=r&&(r.onInvoke?this._zone:i._invokeCurrZone),this._handleErrorZS=r&&(r.onHandleError?r:i._handleErrorZS),this._handleErrorDlgt=r&&(r.onHandleError?i:i._handleErrorDlgt),this._handleErrorCurrZone=r&&(r.onHandleError?this._zone:i._handleErrorCurrZone),this._scheduleTaskZS=r&&(r.onScheduleTask?r:i._scheduleTaskZS),this._scheduleTaskDlgt=r&&(r.onScheduleTask?i:i._scheduleTaskDlgt),this._scheduleTaskCurrZone=r&&(r.onScheduleTask?this._zone:i._scheduleTaskCurrZone),this._invokeTaskZS=r&&(r.onInvokeTask?r:i._invokeTaskZS),this._invokeTaskDlgt=r&&(r.onInvokeTask?i:i._invokeTaskDlgt),this._invokeTaskCurrZone=r&&(r.onInvokeTask?this._zone:i._invokeTaskCurrZone),this._cancelTaskZS=r&&(r.onCancelTask?r:i._cancelTaskZS),this._cancelTaskDlgt=r&&(r.onCancelTask?i:i._cancelTaskDlgt),this._cancelTaskCurrZone=r&&(r.onCancelTask?this._zone:i._cancelTaskCurrZone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;let E=r&&r.onHasTask,x=i&&i._hasTaskZS;(E||x)&&(this._hasTaskZS=E?r:c,this._hasTaskDlgt=i,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=this._zone,r.onScheduleTask||(this._scheduleTaskZS=c,this._scheduleTaskDlgt=i,this._scheduleTaskCurrZone=this._zone),r.onInvokeTask||(this._invokeTaskZS=c,this._invokeTaskDlgt=i,this._invokeTaskCurrZone=this._zone),r.onCancelTask||(this._cancelTaskZS=c,this._cancelTaskDlgt=i,this._cancelTaskCurrZone=this._zone))}fork(s,i){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,s,i):new e(s,i)}intercept(s,i,r){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,s,i,r):i}invoke(s,i,r,E,x){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,s,i,r,E,x):i.apply(r,E)}handleError(s,i){return this._handleErrorZS?this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,s,i):!0}scheduleTask(s,i){let r=i;if(this._scheduleTaskZS)this._hasTaskZS&&r._zoneDelegates.push(this._hasTaskDlgtOwner),r=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,s,i),r||(r=i);else if(i.scheduleFn)i.scheduleFn(i);else if(i.type==F)z(i);else throw new Error("Task is missing scheduleFn.");return r}invokeTask(s,i,r,E){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,s,i,r,E):i.callback.apply(r,E)}cancelTask(s,i){let r;if(this._cancelTaskZS)r=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,s,i);else{if(!i.cancelFn)throw Error("Task is not cancelable");r=i.cancelFn(i)}return r}hasTask(s,i){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,s,i)}catch(r){this.handleError(s,r)}}_updateTaskCount(s,i){let r=this._taskCounts,E=r[s],x=r[s]=E+i;if(x<0)throw new Error("More tasks executed then were scheduled.");if(E==0||x==0){let ee={microTask:r.microTask>0,macroTask:r.macroTask>0,eventTask:r.eventTask>0,change:s};this.hasTask(this._zone,ee)}}}class g{type;source;invoke;callback;data;scheduleFn;cancelFn;_zone=null;runCount=0;_zoneDelegates=null;_state="notScheduled";constructor(s,i,r,E,x,ee){if(this.type=s,this.source=i,this.data=E,this.scheduleFn=x,this.cancelFn=ee,!r)throw new Error("callback is not defined");this.callback=r;let M=this;s===U&&E&&E.useG?this.invoke=g.invokeTask:this.invoke=function(){return g.invokeTask.call(ce,M,this,arguments)}}static invokeTask(s,i,r){s||(s=this),K++;try{return s.runCount++,s.zone.runTask(s,i,r)}finally{K==1&&$(),K--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(q,p)}_transitionTo(s,i,r){if(this._state===i||this._state===r)this._state=s,s==q&&(this._zoneDelegates=null);else throw new Error(`${this.type} '${this.source}': can not transition to '${s}', expecting state '${i}'${r?" or '"+r+"'":""}, was '${this._state}'.`)}toString(){return this.data&&typeof this.data.handleId<"u"?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}let T=te("setTimeout"),y=te("Promise"),w=te("then"),_=[],P=!1,L;function H(I){if(L||ce[y]&&(L=ce[y].resolve(0)),L){let s=L[w];s||(s=L.then),s.call(L,I)}else ce[T](I,0)}function z(I){K===0&&_.length===0&&H($),I&&_.push(I)}function $(){if(!P){for(P=!0;_.length;){let I=_;_=[];for(let s=0;s<I.length;s++){let i=I[s];try{i.zone.runTask(i,null,null)}catch(r){R.onUnhandledError(r)}}}R.microtaskDrainDone(),P=!1}}let J={name:"NO ZONE"},q="notScheduled",p="scheduling",d="scheduled",A="running",V="canceling",X="unknown",F="microTask",k="macroTask",U="eventTask",S={},R={symbol:te,currentZoneFrame:()=>b,onUnhandledError:W,microtaskDrainDone:W,scheduleMicroTask:z,showUncaughtError:()=>!e[te("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:W,patchMethod:()=>W,bindArguments:()=>[],patchThen:()=>W,patchMacroTask:()=>W,patchEventPrototype:()=>W,isIEOrEdge:()=>!1,getGlobalObjects:()=>{},ObjectDefineProperty:()=>W,ObjectGetOwnPropertyDescriptor:()=>{},ObjectCreate:()=>{},ArraySlice:()=>[],patchClass:()=>W,wrapWithCurrentZone:()=>W,filterProperties:()=>[],attachOriginToPatched:()=>W,_redefineProperty:()=>W,patchCallbacks:()=>W,nativeScheduleMicroTask:H},b={parent:null,zone:new e(null,null)},D=null,K=0;function W(){}return a("Zone","Zone"),e}function dt(){let t=globalThis,n=t[te("forceDuplicateZoneCheck")]===!0;if(t.Zone&&(n||typeof t.Zone.__symbol__!="function"))throw new Error("Zone already loaded.");return t.Zone??=ht(),t.Zone}var pe=Object.getOwnPropertyDescriptor,Me=Object.defineProperty,Ae=Object.getPrototypeOf,_t=Object.create,Tt=Array.prototype.slice,je="addEventListener",He="removeEventListener",Ne=te(je),Ze=te(He),ae="true",le="false",ve=te("");function Ve(t,n){return Zone.current.wrap(t,n)}function xe(t,n,a,e,c){return Zone.current.scheduleMacroTask(t,n,a,e,c)}var j=te,we=typeof window<"u",be=we?window:void 0,Y=we&&be||globalThis,Et="removeAttribute";function Fe(t,n){for(let a=t.length-1;a>=0;a--)typeof t[a]=="function"&&(t[a]=Ve(t[a],n+"_"+a));return t}function gt(t,n){let a=t.constructor.name;for(let e=0;e<n.length;e++){let c=n[e],f=t[c];if(f){let g=pe(t,c);if(!et(g))continue;t[c]=(T=>{let y=function(){return T.apply(this,Fe(arguments,a+"."+c))};return fe(y,T),y})(f)}}}function et(t){return t?t.writable===!1?!1:!(typeof t.get=="function"&&typeof t.set>"u"):!0}var tt=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,De=!("nw"in Y)&&typeof Y.process<"u"&&Y.process.toString()==="[object process]",Ge=!De&&!tt&&!!(we&&be.HTMLElement),nt=typeof Y.process<"u"&&Y.process.toString()==="[object process]"&&!tt&&!!(we&&be.HTMLElement),Ce={},kt=j("enable_beforeunload"),Xe=function(t){if(t=t||Y.event,!t)return;let n=Ce[t.type];n||(n=Ce[t.type]=j("ON_PROPERTY"+t.type));let a=this||t.target||Y,e=a[n],c;if(Ge&&a===be&&t.type==="error"){let f=t;c=e&&e.call(this,f.message,f.filename,f.lineno,f.colno,f.error),c===!0&&t.preventDefault()}else c=e&&e.apply(this,arguments),t.type==="beforeunload"&&Y[kt]&&typeof c=="string"?t.returnValue=c:c!=null&&!c&&t.preventDefault();return c};function Ye(t,n,a){let e=pe(t,n);if(!e&&a&&pe(a,n)&&(e={enumerable:!0,configurable:!0}),!e||!e.configurable)return;let c=j("on"+n+"patched");if(t.hasOwnProperty(c)&&t[c])return;delete e.writable,delete e.value;let f=e.get,g=e.set,T=n.slice(2),y=Ce[T];y||(y=Ce[T]=j("ON_PROPERTY"+T)),e.set=function(w){let _=this;if(!_&&t===Y&&(_=Y),!_)return;typeof _[y]=="function"&&_.removeEventListener(T,Xe),g?.call(_,null),_[y]=w,typeof w=="function"&&_.addEventListener(T,Xe,!1)},e.get=function(){let w=this;if(!w&&t===Y&&(w=Y),!w)return null;let _=w[y];if(_)return _;if(f){let P=f.call(this);if(P)return e.set.call(this,P),typeof w[Et]=="function"&&w.removeAttribute(n),P}return null},Me(t,n,e),t[c]=!0}function rt(t,n,a){if(n)for(let e=0;e<n.length;e++)Ye(t,"on"+n[e],a);else{let e=[];for(let c in t)c.slice(0,2)=="on"&&e.push(c);for(let c=0;c<e.length;c++)Ye(t,e[c],a)}}var oe=j("originalInstance");function ye(t){let n=Y[t];if(!n)return;Y[j(t)]=n,Y[t]=function(){let c=Fe(arguments,t);switch(c.length){case 0:this[oe]=new n;break;case 1:this[oe]=new n(c[0]);break;case 2:this[oe]=new n(c[0],c[1]);break;case 3:this[oe]=new n(c[0],c[1],c[2]);break;case 4:this[oe]=new n(c[0],c[1],c[2],c[3]);break;default:throw new Error("Arg list too long.")}},fe(Y[t],n);let a=new n(function(){}),e;for(e in a)t==="XMLHttpRequest"&&e==="responseBlob"||function(c){typeof a[c]=="function"?Y[t].prototype[c]=function(){return this[oe][c].apply(this[oe],arguments)}:Me(Y[t].prototype,c,{set:function(f){typeof f=="function"?(this[oe][c]=Ve(f,t+"."+c),fe(this[oe][c],f)):this[oe][c]=f},get:function(){return this[oe][c]}})}(e);for(e in n)e!=="prototype"&&n.hasOwnProperty(e)&&(Y[t][e]=n[e])}function ue(t,n,a){let e=t;for(;e&&!e.hasOwnProperty(n);)e=Ae(e);!e&&t[n]&&(e=t);let c=j(n),f=null;if(e&&(!(f=e[c])||!e.hasOwnProperty(c))){f=e[c]=e[n];let g=e&&pe(e,n);if(et(g)){let T=a(f,c,n);e[n]=function(){return T(this,arguments)},fe(e[n],f)}}return f}function mt(t,n,a){let e=null;function c(f){let g=f.data;return g.args[g.cbIdx]=function(){f.invoke.apply(this,arguments)},e.apply(g.target,g.args),f}e=ue(t,n,f=>function(g,T){let y=a(g,T);return y.cbIdx>=0&&typeof T[y.cbIdx]=="function"?xe(y.name,T[y.cbIdx],y,c):f.apply(g,T)})}function fe(t,n){t[j("OriginalDelegate")]=n}var $e=!1,Le=!1;function yt(){if($e)return Le;$e=!0;try{let t=be.navigator.userAgent;(t.indexOf("MSIE ")!==-1||t.indexOf("Trident/")!==-1||t.indexOf("Edge/")!==-1)&&(Le=!0)}catch{}return Le}function Je(t){return typeof t=="function"}function Ke(t){return typeof t=="number"}var pt={useG:!0},ne={},ot={},st=new RegExp("^"+ve+"(\\w+)(true|false)$"),it=j("propagationStopped");function ct(t,n){let a=(n?n(t):t)+le,e=(n?n(t):t)+ae,c=ve+a,f=ve+e;ne[t]={},ne[t][le]=c,ne[t][ae]=f}function vt(t,n,a,e){let c=e&&e.add||je,f=e&&e.rm||He,g=e&&e.listeners||"eventListeners",T=e&&e.rmAll||"removeAllListeners",y=j(c),w="."+c+":",_="prependListener",P="."+_+":",L=function(p,d,A){if(p.isRemoved)return;let V=p.callback;typeof V=="object"&&V.handleEvent&&(p.callback=k=>V.handleEvent(k),p.originalDelegate=V);let X;try{p.invoke(p,d,[A])}catch(k){X=k}let F=p.options;if(F&&typeof F=="object"&&F.once){let k=p.originalDelegate?p.originalDelegate:p.callback;d[f].call(d,A.type,k,F)}return X};function H(p,d,A){if(d=d||t.event,!d)return;let V=p||d.target||t,X=V[ne[d.type][A?ae:le]];if(X){let F=[];if(X.length===1){let k=L(X[0],V,d);k&&F.push(k)}else{let k=X.slice();for(let U=0;U<k.length&&!(d&&d[it]===!0);U++){let S=L(k[U],V,d);S&&F.push(S)}}if(F.length===1)throw F[0];for(let k=0;k<F.length;k++){let U=F[k];n.nativeScheduleMicroTask(()=>{throw U})}}}let z=function(p){return H(this,p,!1)},$=function(p){return H(this,p,!0)};function J(p,d){if(!p)return!1;let A=!0;d&&d.useG!==void 0&&(A=d.useG);let V=d&&d.vh,X=!0;d&&d.chkDup!==void 0&&(X=d.chkDup);let F=!1;d&&d.rt!==void 0&&(F=d.rt);let k=p;for(;k&&!k.hasOwnProperty(c);)k=Ae(k);if(!k&&p[c]&&(k=p),!k||k[y])return!1;let U=d&&d.eventNameToString,S={},R=k[y]=k[c],b=k[j(f)]=k[f],D=k[j(g)]=k[g],K=k[j(T)]=k[T],W;d&&d.prepend&&(W=k[j(d.prepend)]=k[d.prepend]);function I(o,u){return u?typeof o=="boolean"?{capture:o,passive:!0}:o?typeof o=="object"&&o.passive!==!1?{...o,passive:!0}:o:{passive:!0}:o}let s=function(o){if(!S.isExisting)return R.call(S.target,S.eventName,S.capture?$:z,S.options)},i=function(o){if(!o.isRemoved){let u=ne[o.eventName],v;u&&(v=u[o.capture?ae:le]);let C=v&&o.target[v];if(C){for(let m=0;m<C.length;m++)if(C[m]===o){C.splice(m,1),o.isRemoved=!0,o.removeAbortListener&&(o.removeAbortListener(),o.removeAbortListener=null),C.length===0&&(o.allRemoved=!0,o.target[v]=null);break}}}if(o.allRemoved)return b.call(o.target,o.eventName,o.capture?$:z,o.options)},r=function(o){return R.call(S.target,S.eventName,o.invoke,S.options)},E=function(o){return W.call(S.target,S.eventName,o.invoke,S.options)},x=function(o){return b.call(o.target,o.eventName,o.invoke,o.options)},ee=A?s:r,M=A?i:x,he=function(o,u){let v=typeof u;return v==="function"&&o.callback===u||v==="object"&&o.originalDelegate===u},_e=d?.diff||he,Q=Zone[j("UNPATCHED_EVENTS")],Te=t[j("PASSIVE_EVENTS")];function h(o){if(typeof o=="object"&&o!==null){let u={...o};return o.signal&&(u.signal=o.signal),u}return o}let l=function(o,u,v,C,m=!1,O=!1){return function(){let N=this||t,Z=arguments[0];d&&d.transferEventName&&(Z=d.transferEventName(Z));let G=arguments[1];if(!G)return o.apply(this,arguments);if(De&&Z==="uncaughtException")return o.apply(this,arguments);let B=!1;if(typeof G!="function"){if(!G.handleEvent)return o.apply(this,arguments);B=!0}if(V&&!V(o,G,N,arguments))return;let de=!!Te&&Te.indexOf(Z)!==-1,se=h(I(arguments[2],de)),Ee=se?.signal;if(Ee?.aborted)return;if(Q){for(let ie=0;ie<Q.length;ie++)if(Z===Q[ie])return de?o.call(N,Z,G,se):o.apply(this,arguments)}let Se=se?typeof se=="boolean"?!0:se.capture:!1,Be=se&&typeof se=="object"?se.once:!1,ft=Zone.current,Oe=ne[Z];Oe||(ct(Z,U),Oe=ne[Z]);let ze=Oe[Se?ae:le],ge=N[ze],Ue=!1;if(ge){if(Ue=!0,X){for(let ie=0;ie<ge.length;ie++)if(_e(ge[ie],G))return}}else ge=N[ze]=[];let Pe,We=N.constructor.name,qe=ot[We];qe&&(Pe=qe[Z]),Pe||(Pe=We+u+(U?U(Z):Z)),S.options=se,Be&&(S.options.once=!1),S.target=N,S.capture=Se,S.eventName=Z,S.isExisting=Ue;let me=A?pt:void 0;me&&(me.taskData=S),Ee&&(S.options.signal=void 0);let re=ft.scheduleEventTask(Pe,G,me,v,C);if(Ee){S.options.signal=Ee;let ie=()=>re.zone.cancelTask(re);o.call(Ee,"abort",ie,{once:!0}),re.removeAbortListener=()=>Ee.removeEventListener("abort",ie)}if(S.target=null,me&&(me.taskData=null),Be&&(S.options.once=!0),typeof re.options!="boolean"&&(re.options=se),re.target=N,re.capture=Se,re.eventName=Z,B&&(re.originalDelegate=G),O?ge.unshift(re):ge.push(re),m)return N}};return k[c]=l(R,w,ee,M,F),W&&(k[_]=l(W,P,E,M,F,!0)),k[f]=function(){let o=this||t,u=arguments[0];d&&d.transferEventName&&(u=d.transferEventName(u));let v=arguments[2],C=v?typeof v=="boolean"?!0:v.capture:!1,m=arguments[1];if(!m)return b.apply(this,arguments);if(V&&!V(b,m,o,arguments))return;let O=ne[u],N;O&&(N=O[C?ae:le]);let Z=N&&o[N];if(Z)for(let G=0;G<Z.length;G++){let B=Z[G];if(_e(B,m)){if(Z.splice(G,1),B.isRemoved=!0,Z.length===0&&(B.allRemoved=!0,o[N]=null,!C&&typeof u=="string")){let de=ve+"ON_PROPERTY"+u;o[de]=null}return B.zone.cancelTask(B),F?o:void 0}}return b.apply(this,arguments)},k[g]=function(){let o=this||t,u=arguments[0];d&&d.transferEventName&&(u=d.transferEventName(u));let v=[],C=at(o,U?U(u):u);for(let m=0;m<C.length;m++){let O=C[m],N=O.originalDelegate?O.originalDelegate:O.callback;v.push(N)}return v},k[T]=function(){let o=this||t,u=arguments[0];if(u){d&&d.transferEventName&&(u=d.transferEventName(u));let v=ne[u];if(v){let C=v[le],m=v[ae],O=o[C],N=o[m];if(O){let Z=O.slice();for(let G=0;G<Z.length;G++){let B=Z[G],de=B.originalDelegate?B.originalDelegate:B.callback;this[f].call(this,u,de,B.options)}}if(N){let Z=N.slice();for(let G=0;G<Z.length;G++){let B=Z[G],de=B.originalDelegate?B.originalDelegate:B.callback;this[f].call(this,u,de,B.options)}}}}else{let v=Object.keys(o);for(let C=0;C<v.length;C++){let m=v[C],O=st.exec(m),N=O&&O[1];N&&N!=="removeListener"&&this[T].call(this,N)}this[T].call(this,"removeListener")}if(F)return this},fe(k[c],R),fe(k[f],b),K&&fe(k[T],K),D&&fe(k[g],D),!0}let q=[];for(let p=0;p<a.length;p++)q[p]=J(a[p],e);return q}function at(t,n){if(!n){let f=[];for(let g in t){let T=st.exec(g),y=T&&T[1];if(y&&(!n||y===n)){let w=t[g];if(w)for(let _=0;_<w.length;_++)f.push(w[_])}}return f}let a=ne[n];a||(ct(n),a=ne[n]);let e=t[a[le]],c=t[a[ae]];return e?c?e.concat(c):e.slice():c?c.slice():[]}function bt(t,n){let a=t.Event;a&&a.prototype&&n.patchMethod(a.prototype,"stopImmediatePropagation",e=>function(c,f){c[it]=!0,e&&e.apply(c,f)})}function Pt(t,n){n.patchMethod(t,"queueMicrotask",a=>function(e,c){Zone.current.scheduleMicroTask("queueMicrotask",c[0])})}var Re=j("zoneTask");function ke(t,n,a,e){let c=null,f=null;n+=e,a+=e;let g={};function T(w){let _=w.data;_.args[0]=function(){return w.invoke.apply(this,arguments)};let P=c.apply(t,_.args);return Ke(P)?_.handleId=P:(_.handle=P,_.isRefreshable=Je(P.refresh)),w}function y(w){let{handle:_,handleId:P}=w.data;return f.call(t,_??P)}c=ue(t,n,w=>function(_,P){if(Je(P[0])){let L={isRefreshable:!1,isPeriodic:e==="Interval",delay:e==="Timeout"||e==="Interval"?P[1]||0:void 0,args:P},H=P[0];P[0]=function(){try{return H.apply(this,arguments)}finally{let{handle:A,handleId:V,isPeriodic:X,isRefreshable:F}=L;!X&&!F&&(V?delete g[V]:A&&(A[Re]=null))}};let z=xe(n,P[0],L,T,y);if(!z)return z;let{handleId:$,handle:J,isRefreshable:q,isPeriodic:p}=z.data;if($)g[$]=z;else if(J&&(J[Re]=z,q&&!p)){let d=J.refresh;J.refresh=function(){let{zone:A,state:V}=z;return V==="notScheduled"?(z._state="scheduled",A._updateTaskCount(z,1)):V==="running"&&(z._state="scheduling"),d.call(this)}}return J??$??z}else return w.apply(t,P)}),f=ue(t,a,w=>function(_,P){let L=P[0],H;Ke(L)?(H=g[L],delete g[L]):(H=L?.[Re],H?L[Re]=null:H=L),H?.type?H.cancelFn&&H.zone.cancelTask(H):w.apply(t,P)})}function Rt(t,n){let{isBrowser:a,isMix:e}=n.getGlobalObjects();if(!a&&!e||!t.customElements||!("customElements"in t))return;let c=["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback","formAssociatedCallback","formDisabledCallback","formResetCallback","formStateRestoreCallback"];n.patchCallbacks(n,t.customElements,"customElements","define",c)}function Ct(t,n){if(Zone[n.symbol("patchEventTarget")])return;let{eventNames:a,zoneSymbolEventNames:e,TRUE_STR:c,FALSE_STR:f,ZONE_SYMBOL_PREFIX:g}=n.getGlobalObjects();for(let y=0;y<a.length;y++){let w=a[y],_=w+f,P=w+c,L=g+_,H=g+P;e[w]={},e[w][f]=L,e[w][c]=H}let T=t.EventTarget;if(!(!T||!T.prototype))return n.patchEventTarget(t,n,[T&&T.prototype]),!0}function wt(t,n){n.patchEventPrototype(t,n)}function lt(t,n,a){if(!a||a.length===0)return n;let e=a.filter(f=>f.target===t);if(e.length===0)return n;let c=e[0].ignoreProperties;return n.filter(f=>c.indexOf(f)===-1)}function Qe(t,n,a,e){if(!t)return;let c=lt(t,n,a);rt(t,c,e)}function Ie(t){return Object.getOwnPropertyNames(t).filter(n=>n.startsWith("on")&&n.length>2).map(n=>n.substring(2))}function Dt(t,n){if(De&&!nt||Zone[t.symbol("patchEvents")])return;let a=n.__Zone_ignore_on_properties,e=[];if(Ge){let c=window;e=e.concat(["Document","SVGElement","Element","HTMLElement","HTMLBodyElement","HTMLMediaElement","HTMLFrameSetElement","HTMLFrameElement","HTMLIFrameElement","HTMLMarqueeElement","Worker"]);let f=[];Qe(c,Ie(c),a&&a.concat(f),Ae(c))}e=e.concat(["XMLHttpRequest","XMLHttpRequestEventTarget","IDBIndex","IDBRequest","IDBOpenDBRequest","IDBDatabase","IDBTransaction","IDBCursor","WebSocket"]);for(let c=0;c<e.length;c++){let f=n[e[c]];f?.prototype&&Qe(f.prototype,Ie(f.prototype),a)}}function St(t){t.__load_patch("legacy",n=>{let a=n[t.__symbol__("legacyPatch")];a&&a()}),t.__load_patch("timers",n=>{let a="set",e="clear";ke(n,a,e,"Timeout"),ke(n,a,e,"Interval"),ke(n,a,e,"Immediate")}),t.__load_patch("requestAnimationFrame",n=>{ke(n,"request","cancel","AnimationFrame"),ke(n,"mozRequest","mozCancel","AnimationFrame"),ke(n,"webkitRequest","webkitCancel","AnimationFrame")}),t.__load_patch("blocking",(n,a)=>{let e=["alert","prompt","confirm"];for(let c=0;c<e.length;c++){let f=e[c];ue(n,f,(g,T,y)=>function(w,_){return a.current.run(g,n,_,y)})}}),t.__load_patch("EventTarget",(n,a,e)=>{wt(n,e),Ct(n,e);let c=n.XMLHttpRequestEventTarget;c&&c.prototype&&e.patchEventTarget(n,e,[c.prototype])}),t.__load_patch("MutationObserver",(n,a,e)=>{ye("MutationObserver"),ye("WebKitMutationObserver")}),t.__load_patch("IntersectionObserver",(n,a,e)=>{ye("IntersectionObserver")}),t.__load_patch("FileReader",(n,a,e)=>{ye("FileReader")}),t.__load_patch("on_property",(n,a,e)=>{Dt(e,n)}),t.__load_patch("customElements",(n,a,e)=>{Rt(n,e)}),t.__load_patch("XHR",(n,a)=>{w(n);let e=j("xhrTask"),c=j("xhrSync"),f=j("xhrListener"),g=j("xhrScheduled"),T=j("xhrURL"),y=j("xhrErrorBeforeScheduled");function w(_){let P=_.XMLHttpRequest;if(!P)return;let L=P.prototype;function H(R){return R[e]}let z=L[Ne],$=L[Ze];if(!z){let R=_.XMLHttpRequestEventTarget;if(R){let b=R.prototype;z=b[Ne],$=b[Ze]}}let J="readystatechange",q="scheduled";function p(R){let b=R.data,D=b.target;D[g]=!1,D[y]=!1;let K=D[f];z||(z=D[Ne],$=D[Ze]),K&&$.call(D,J,K);let W=D[f]=()=>{if(D.readyState===D.DONE)if(!b.aborted&&D[g]&&R.state===q){let s=D[a.__symbol__("loadfalse")];if(D.status!==0&&s&&s.length>0){let i=R.invoke;R.invoke=function(){let r=D[a.__symbol__("loadfalse")];for(let E=0;E<r.length;E++)r[E]===R&&r.splice(E,1);!b.aborted&&R.state===q&&i.call(R)},s.push(R)}else R.invoke()}else!b.aborted&&D[g]===!1&&(D[y]=!0)};return z.call(D,J,W),D[e]||(D[e]=R),U.apply(D,b.args),D[g]=!0,R}function d(){}function A(R){let b=R.data;return b.aborted=!0,S.apply(b.target,b.args)}let V=ue(L,"open",()=>function(R,b){return R[c]=b[2]==!1,R[T]=b[1],V.apply(R,b)}),X="XMLHttpRequest.send",F=j("fetchTaskAborting"),k=j("fetchTaskScheduling"),U=ue(L,"send",()=>function(R,b){if(a.current[k]===!0||R[c])return U.apply(R,b);{let D={target:R,url:R[T],isPeriodic:!1,args:b,aborted:!1},K=xe(X,d,D,p,A);R&&R[y]===!0&&!D.aborted&&K.state===q&&K.invoke()}}),S=ue(L,"abort",()=>function(R,b){let D=H(R);if(D&&typeof D.type=="string"){if(D.cancelFn==null||D.data&&D.data.aborted)return;D.zone.cancelTask(D)}else if(a.current[F]===!0)return S.apply(R,b)})}}),t.__load_patch("geolocation",n=>{n.navigator&&n.navigator.geolocation&>(n.navigator.geolocation,["getCurrentPosition","watchPosition"])}),t.__load_patch("PromiseRejectionEvent",(n,a)=>{function e(c){return function(f){at(n,c).forEach(T=>{let y=n.PromiseRejectionEvent;if(y){let w=new y(c,{promise:f.promise,reason:f.rejection});T.invoke(w)}})}}n.PromiseRejectionEvent&&(a[j("unhandledPromiseRejectionHandler")]=e("unhandledrejection"),a[j("rejectionHandledHandler")]=e("rejectionhandled"))}),t.__load_patch("queueMicrotask",(n,a,e)=>{Pt(n,e)})}function Ot(t){t.__load_patch("ZoneAwarePromise",(n,a,e)=>{let c=Object.getOwnPropertyDescriptor,f=Object.defineProperty;function g(h){if(h&&h.toString===Object.prototype.toString){let l=h.constructor&&h.constructor.name;return(l||"")+": "+JSON.stringify(h)}return h?h.toString():Object.prototype.toString.call(h)}let T=e.symbol,y=[],w=n[T("DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION")]!==!1,_=T("Promise"),P=T("then"),L="__creationTrace__";e.onUnhandledError=h=>{if(e.showUncaughtError()){let l=h&&h.rejection;l?console.error("Unhandled Promise rejection:",l instanceof Error?l.message:l,"; Zone:",h.zone.name,"; Task:",h.task&&h.task.source,"; Value:",l,l instanceof Error?l.stack:void 0):console.error(h)}},e.microtaskDrainDone=()=>{for(;y.length;){let h=y.shift();try{h.zone.runGuarded(()=>{throw h.throwOriginal?h.rejection:h})}catch(l){z(l)}}};let H=T("unhandledPromiseRejectionHandler");function z(h){e.onUnhandledError(h);try{let l=a[H];typeof l=="function"&&l.call(this,h)}catch{}}function $(h){return h&&typeof h.then=="function"}function J(h){return h}function q(h){return M.reject(h)}let p=T("state"),d=T("value"),A=T("finally"),V=T("parentPromiseValue"),X=T("parentPromiseState"),F="Promise.then",k=null,U=!0,S=!1,R=0;function b(h,l){return o=>{try{I(h,l,o)}catch(u){I(h,!1,u)}}}let D=function(){let h=!1;return function(o){return function(){h||(h=!0,o.apply(null,arguments))}}},K="Promise resolved with itself",W=T("currentTaskTrace");function I(h,l,o){let u=D();if(h===o)throw new TypeError(K);if(h[p]===k){let v=null;try{(typeof o=="object"||typeof o=="function")&&(v=o&&o.then)}catch(C){return u(()=>{I(h,!1,C)})(),h}if(l!==S&&o instanceof M&&o.hasOwnProperty(p)&&o.hasOwnProperty(d)&&o[p]!==k)i(o),I(h,o[p],o[d]);else if(l!==S&&typeof v=="function")try{v.call(o,u(b(h,l)),u(b(h,!1)))}catch(C){u(()=>{I(h,!1,C)})()}else{h[p]=l;let C=h[d];if(h[d]=o,h[A]===A&&l===U&&(h[p]=h[X],h[d]=h[V]),l===S&&o instanceof Error){let m=a.currentTask&&a.currentTask.data&&a.currentTask.data[L];m&&f(o,W,{configurable:!0,enumerable:!1,writable:!0,value:m})}for(let m=0;m<C.length;)r(h,C[m++],C[m++],C[m++],C[m++]);if(C.length==0&&l==S){h[p]=R;let m=o;try{throw new Error("Uncaught (in promise): "+g(o)+(o&&o.stack?`
|
17
|
+
`+o.stack:""))}catch(O){m=O}w&&(m.throwOriginal=!0),m.rejection=o,m.promise=h,m.zone=a.current,m.task=a.currentTask,y.push(m),e.scheduleMicroTask()}}}return h}let s=T("rejectionHandledHandler");function i(h){if(h[p]===R){try{let l=a[s];l&&typeof l=="function"&&l.call(this,{rejection:h[d],promise:h})}catch{}h[p]=S;for(let l=0;l<y.length;l++)h===y[l].promise&&y.splice(l,1)}}function r(h,l,o,u,v){i(h);let C=h[p],m=C?typeof u=="function"?u:J:typeof v=="function"?v:q;l.scheduleMicroTask(F,()=>{try{let O=h[d],N=!!o&&A===o[A];N&&(o[V]=O,o[X]=C);let Z=l.run(m,void 0,N&&m!==q&&m!==J?[]:[O]);I(o,!0,Z)}catch(O){I(o,!1,O)}},o)}let E="function ZoneAwarePromise() { [native code] }",x=function(){},ee=n.AggregateError;class M{static toString(){return E}static resolve(l){return l instanceof M?l:I(new this(null),U,l)}static reject(l){return I(new this(null),S,l)}static withResolvers(){let l={};return l.promise=new M((o,u)=>{l.resolve=o,l.reject=u}),l}static any(l){if(!l||typeof l[Symbol.iterator]!="function")return Promise.reject(new ee([],"All promises were rejected"));let o=[],u=0;try{for(let m of l)u++,o.push(M.resolve(m))}catch{return Promise.reject(new ee([],"All promises were rejected"))}if(u===0)return Promise.reject(new ee([],"All promises were rejected"));let v=!1,C=[];return new M((m,O)=>{for(let N=0;N<o.length;N++)o[N].then(Z=>{v||(v=!0,m(Z))},Z=>{C.push(Z),u--,u===0&&(v=!0,O(new ee(C,"All promises were rejected")))})})}static race(l){let o,u,v=new this((O,N)=>{o=O,u=N});function C(O){o(O)}function m(O){u(O)}for(let O of l)$(O)||(O=this.resolve(O)),O.then(C,m);return v}static all(l){return M.allWithCallback(l)}static allSettled(l){return(this&&this.prototype instanceof M?this:M).allWithCallback(l,{thenCallback:u=>({status:"fulfilled",value:u}),errorCallback:u=>({status:"rejected",reason:u})})}static allWithCallback(l,o){let u,v,C=new this((Z,G)=>{u=Z,v=G}),m=2,O=0,N=[];for(let Z of l){$(Z)||(Z=this.resolve(Z));let G=O;try{Z.then(B=>{N[G]=o?o.thenCallback(B):B,m--,m===0&&u(N)},B=>{o?(N[G]=o.errorCallback(B),m--,m===0&&u(N)):v(B)})}catch(B){v(B)}m++,O++}return m-=2,m===0&&u(N),C}constructor(l){let o=this;if(!(o instanceof M))throw new Error("Must be an instanceof Promise.");o[p]=k,o[d]=[];try{let u=D();l&&l(u(b(o,U)),u(b(o,S)))}catch(u){I(o,!1,u)}}get[Symbol.toStringTag](){return"Promise"}get[Symbol.species](){return M}then(l,o){let u=this.constructor?.[Symbol.species];(!u||typeof u!="function")&&(u=this.constructor||M);let v=new u(x),C=a.current;return this[p]==k?this[d].push(C,v,l,o):r(this,C,v,l,o),v}catch(l){return this.then(null,l)}finally(l){let o=this.constructor?.[Symbol.species];(!o||typeof o!="function")&&(o=M);let u=new o(x);u[A]=A;let v=a.current;return this[p]==k?this[d].push(v,u,l,l):r(this,v,u,l,l),u}}M.resolve=M.resolve,M.reject=M.reject,M.race=M.race,M.all=M.all;let he=n[_]=n.Promise;n.Promise=M;let _e=T("thenPatched");function Q(h){let l=h.prototype,o=c(l,"then");if(o&&(o.writable===!1||!o.configurable))return;let u=l.then;l[P]=u,h.prototype.then=function(v,C){return new M((O,N)=>{u.call(this,O,N)}).then(v,C)},h[_e]=!0}e.patchThen=Q;function Te(h){return function(l,o){let u=h.apply(l,o);if(u instanceof M)return u;let v=u.constructor;return v[_e]||Q(v),u}}return he&&(Q(he),ue(n,"fetch",h=>Te(h))),Promise[a.__symbol__("uncaughtPromiseErrors")]=y,M})}function Nt(t){t.__load_patch("toString",n=>{let a=Function.prototype.toString,e=j("OriginalDelegate"),c=j("Promise"),f=j("Error"),g=function(){if(typeof this=="function"){let _=this[e];if(_)return typeof _=="function"?a.call(_):Object.prototype.toString.call(_);if(this===Promise){let P=n[c];if(P)return a.call(P)}if(this===Error){let P=n[f];if(P)return a.call(P)}}return a.call(this)};g[e]=a,Function.prototype.toString=g;let T=Object.prototype.toString,y="[object Promise]";Object.prototype.toString=function(){return typeof Promise=="function"&&this instanceof Promise?y:T.call(this)}})}function Zt(t,n,a,e,c){let f=Zone.__symbol__(e);if(n[f])return;let g=n[f]=n[e];n[e]=function(T,y,w){return y&&y.prototype&&c.forEach(function(_){let P=`${a}.${e}::`+_,L=y.prototype;try{if(L.hasOwnProperty(_)){let H=t.ObjectGetOwnPropertyDescriptor(L,_);H&&H.value?(H.value=t.wrapWithCurrentZone(H.value,P),t._redefineProperty(y.prototype,_,H)):L[_]&&(L[_]=t.wrapWithCurrentZone(L[_],P))}else L[_]&&(L[_]=t.wrapWithCurrentZone(L[_],P))}catch{}}),g.call(n,T,y,w)},t.attachOriginToPatched(n[e],g)}function Lt(t){t.__load_patch("util",(n,a,e)=>{let c=Ie(n);e.patchOnProperties=rt,e.patchMethod=ue,e.bindArguments=Fe,e.patchMacroTask=mt;let f=a.__symbol__("BLACK_LISTED_EVENTS"),g=a.__symbol__("UNPATCHED_EVENTS");n[g]&&(n[f]=n[g]),n[f]&&(a[f]=a[g]=n[f]),e.patchEventPrototype=bt,e.patchEventTarget=vt,e.isIEOrEdge=yt,e.ObjectDefineProperty=Me,e.ObjectGetOwnPropertyDescriptor=pe,e.ObjectCreate=_t,e.ArraySlice=Tt,e.patchClass=ye,e.wrapWithCurrentZone=Ve,e.filterProperties=lt,e.attachOriginToPatched=fe,e._redefineProperty=Object.defineProperty,e.patchCallbacks=Zt,e.getGlobalObjects=()=>({globalSources:ot,zoneSymbolEventNames:ne,eventNames:c,isBrowser:Ge,isMix:nt,isNode:De,TRUE_STR:ae,FALSE_STR:le,ZONE_SYMBOL_PREFIX:ve,ADD_EVENT_LISTENER_STR:je,REMOVE_EVENT_LISTENER_STR:He})})}function It(t){Ot(t),Nt(t),Lt(t)}var ut=dt();It(ut);St(ut);
|
google/adk/cli/cli_eval.py
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
from __future__ import annotations
|
16
16
|
|
17
17
|
import importlib.util
|
18
|
+
import inspect
|
18
19
|
import json
|
19
20
|
import logging
|
20
21
|
import os
|
@@ -24,13 +25,22 @@ from typing import AsyncGenerator
|
|
24
25
|
from typing import Optional
|
25
26
|
import uuid
|
26
27
|
|
28
|
+
from typing_extensions import deprecated
|
29
|
+
|
27
30
|
from ..agents import Agent
|
28
31
|
from ..artifacts.base_artifact_service import BaseArtifactService
|
32
|
+
from ..evaluation.base_eval_service import BaseEvalService
|
33
|
+
from ..evaluation.base_eval_service import EvaluateConfig
|
34
|
+
from ..evaluation.base_eval_service import EvaluateRequest
|
35
|
+
from ..evaluation.base_eval_service import InferenceConfig
|
36
|
+
from ..evaluation.base_eval_service import InferenceRequest
|
37
|
+
from ..evaluation.base_eval_service import InferenceResult
|
29
38
|
from ..evaluation.constants import MISSING_EVAL_DEPENDENCIES_MESSAGE
|
30
39
|
from ..evaluation.eval_case import EvalCase
|
31
40
|
from ..evaluation.eval_metrics import EvalMetric
|
32
41
|
from ..evaluation.eval_metrics import EvalMetricResult
|
33
42
|
from ..evaluation.eval_metrics import EvalMetricResultPerInvocation
|
43
|
+
from ..evaluation.eval_metrics import JudgeModelOptions
|
34
44
|
from ..evaluation.eval_result import EvalCaseResult
|
35
45
|
from ..evaluation.evaluator import EvalStatus
|
36
46
|
from ..evaluation.evaluator import Evaluator
|
@@ -42,6 +52,7 @@ logger = logging.getLogger("google_adk." + __name__)
|
|
42
52
|
TOOL_TRAJECTORY_SCORE_KEY = "tool_trajectory_avg_score"
|
43
53
|
RESPONSE_MATCH_SCORE_KEY = "response_match_score"
|
44
54
|
SAFETY_V1_KEY = "safety_v1"
|
55
|
+
FINAL_RESPONSE_MATCH_V2 = "final_response_match_v2"
|
45
56
|
# This evaluation is not very stable.
|
46
57
|
# This is always optional unless explicitly specified.
|
47
58
|
RESPONSE_EVALUATION_SCORE_KEY = "response_evaluation_score"
|
@@ -107,26 +118,80 @@ def try_get_reset_func(agent_module_file_path: str) -> Any:
|
|
107
118
|
|
108
119
|
|
109
120
|
def parse_and_get_evals_to_run(
|
110
|
-
|
121
|
+
evals_to_run_info: list[str],
|
111
122
|
) -> dict[str, list[str]]:
|
112
|
-
"""Returns a dictionary of eval
|
123
|
+
"""Returns a dictionary of eval set info to evals that should be run.
|
124
|
+
|
125
|
+
Args:
|
126
|
+
evals_to_run_info: While the structure is quite simple, a list of string,
|
127
|
+
each string actually is formatted with the following convention:
|
128
|
+
<eval_set_file_path | eval_set_id>:[comma separated eval case ids]
|
129
|
+
"""
|
113
130
|
eval_set_to_evals = {}
|
114
|
-
for input_eval_set in
|
131
|
+
for input_eval_set in evals_to_run_info:
|
115
132
|
evals = []
|
116
133
|
if ":" not in input_eval_set:
|
117
|
-
|
134
|
+
# We don't have any eval cases specified. This would be the case where the
|
135
|
+
# the user wants to run all eval cases in the eval set.
|
136
|
+
eval_set = input_eval_set
|
118
137
|
else:
|
119
|
-
|
138
|
+
# There are eval cases that we need to parse. The user wants to run
|
139
|
+
# specific eval cases from the eval set.
|
140
|
+
eval_set = input_eval_set.split(":")[0]
|
120
141
|
evals = input_eval_set.split(":")[1].split(",")
|
142
|
+
evals = [s for s in evals if s.strip()]
|
121
143
|
|
122
|
-
if
|
123
|
-
eval_set_to_evals[
|
144
|
+
if eval_set not in eval_set_to_evals:
|
145
|
+
eval_set_to_evals[eval_set] = []
|
124
146
|
|
125
|
-
eval_set_to_evals[
|
147
|
+
eval_set_to_evals[eval_set].extend(evals)
|
126
148
|
|
127
149
|
return eval_set_to_evals
|
128
150
|
|
129
151
|
|
152
|
+
async def _collect_inferences(
|
153
|
+
inference_requests: list[InferenceRequest],
|
154
|
+
eval_service: BaseEvalService,
|
155
|
+
) -> list[InferenceResult]:
|
156
|
+
"""Simple utility methods to collect inferences from an eval service.
|
157
|
+
|
158
|
+
The method is intentionally kept private to prevent general usage.
|
159
|
+
"""
|
160
|
+
inference_results = []
|
161
|
+
for inference_request in inference_requests:
|
162
|
+
async for inference_result in eval_service.perform_inference(
|
163
|
+
inference_request=inference_request
|
164
|
+
):
|
165
|
+
inference_results.append(inference_result)
|
166
|
+
return inference_results
|
167
|
+
|
168
|
+
|
169
|
+
async def _collect_eval_results(
|
170
|
+
inference_results: list[InferenceResult],
|
171
|
+
eval_service: BaseEvalService,
|
172
|
+
eval_metrics: list[EvalMetric],
|
173
|
+
) -> list[EvalCaseResult]:
|
174
|
+
"""Simple utility methods to collect eval results from an eval service.
|
175
|
+
|
176
|
+
The method is intentionally kept private to prevent general usage.
|
177
|
+
"""
|
178
|
+
eval_results = []
|
179
|
+
evaluate_request = EvaluateRequest(
|
180
|
+
inference_results=inference_results,
|
181
|
+
evaluate_config=EvaluateConfig(eval_metrics=eval_metrics),
|
182
|
+
)
|
183
|
+
async for eval_result in eval_service.evaluate(
|
184
|
+
evaluate_request=evaluate_request
|
185
|
+
):
|
186
|
+
eval_results.append(eval_result)
|
187
|
+
|
188
|
+
return eval_results
|
189
|
+
|
190
|
+
|
191
|
+
@deprecated(
|
192
|
+
"This method is deprecated and will be removed in fututre release. Please"
|
193
|
+
" use LocalEvalService to define your custom evals."
|
194
|
+
)
|
130
195
|
async def run_evals(
|
131
196
|
eval_cases_by_eval_set_id: dict[str, list[EvalCase]],
|
132
197
|
root_agent: Agent,
|
@@ -191,10 +256,16 @@ async def run_evals(
|
|
191
256
|
for eval_metric in eval_metrics:
|
192
257
|
metric_evaluator = _get_evaluator(eval_metric)
|
193
258
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
259
|
+
if inspect.iscoroutinefunction(metric_evaluator.evaluate_invocations):
|
260
|
+
evaluation_result = await metric_evaluator.evaluate_invocations(
|
261
|
+
actual_invocations=inference_result,
|
262
|
+
expected_invocations=eval_case.conversation,
|
263
|
+
)
|
264
|
+
else:
|
265
|
+
evaluation_result = metric_evaluator.evaluate_invocations(
|
266
|
+
actual_invocations=inference_result,
|
267
|
+
expected_invocations=eval_case.conversation,
|
268
|
+
)
|
198
269
|
|
199
270
|
overall_eval_metric_results.append(
|
200
271
|
EvalMetricResult(
|
@@ -260,6 +331,7 @@ async def run_evals(
|
|
260
331
|
|
261
332
|
def _get_evaluator(eval_metric: EvalMetric) -> Evaluator:
|
262
333
|
try:
|
334
|
+
from ..evaluation.final_response_match_v2 import FinalResponseMatchV2Evaluator
|
263
335
|
from ..evaluation.response_evaluator import ResponseEvaluator
|
264
336
|
from ..evaluation.safety_evaluator import SafetyEvaluatorV1
|
265
337
|
from ..evaluation.trajectory_evaluator import TrajectoryEvaluator
|
@@ -276,5 +348,8 @@ def _get_evaluator(eval_metric: EvalMetric) -> Evaluator:
|
|
276
348
|
)
|
277
349
|
elif eval_metric.metric_name == SAFETY_V1_KEY:
|
278
350
|
return SafetyEvaluatorV1(eval_metric)
|
351
|
+
elif eval_metric.metric_name == FINAL_RESPONSE_MATCH_V2:
|
352
|
+
eval_metric.judge_model_options = JudgeModelOptions()
|
353
|
+
return FinalResponseMatchV2Evaluator(eval_metric)
|
279
354
|
|
280
355
|
raise ValueError(f"Unsupported eval metric: {eval_metric}")
|
@@ -32,10 +32,6 @@ from . import cli_create
|
|
32
32
|
from . import cli_deploy
|
33
33
|
from .. import version
|
34
34
|
from ..evaluation.constants import MISSING_EVAL_DEPENDENCIES_MESSAGE
|
35
|
-
from ..evaluation.gcs_eval_set_results_manager import GcsEvalSetResultsManager
|
36
|
-
from ..evaluation.gcs_eval_sets_manager import GcsEvalSetsManager
|
37
|
-
from ..evaluation.local_eval_set_results_manager import LocalEvalSetResultsManager
|
38
|
-
from ..sessions.in_memory_session_service import InMemorySessionService
|
39
35
|
from .cli import run_cli
|
40
36
|
from .fast_api import get_fast_api_app
|
41
37
|
from .utils import envs
|
@@ -276,7 +272,7 @@ def cli_run(
|
|
276
272
|
exists=True, dir_okay=True, file_okay=False, resolve_path=True
|
277
273
|
),
|
278
274
|
)
|
279
|
-
@click.argument("
|
275
|
+
@click.argument("eval_set_file_path_or_id", nargs=-1)
|
280
276
|
@click.option("--config_file_path", help="Optional. The path to config file.")
|
281
277
|
@click.option(
|
282
278
|
"--print_detailed_results",
|
@@ -296,7 +292,7 @@ def cli_run(
|
|
296
292
|
)
|
297
293
|
def cli_eval(
|
298
294
|
agent_module_file_path: str,
|
299
|
-
|
295
|
+
eval_set_file_path_or_id: list[str],
|
300
296
|
config_file_path: str,
|
301
297
|
print_detailed_results: bool,
|
302
298
|
eval_storage_uri: Optional[str] = None,
|
@@ -306,20 +302,51 @@ def cli_eval(
|
|
306
302
|
AGENT_MODULE_FILE_PATH: The path to the __init__.py file that contains a
|
307
303
|
module by the name "agent". "agent" module contains a root_agent.
|
308
304
|
|
309
|
-
|
305
|
+
EVAL_SET_FILE_PATH_OR_ID: You can specify one or more eval set file paths or
|
306
|
+
eval set id.
|
310
307
|
|
308
|
+
Mixing of eval set file paths with eval set ids is not allowed.
|
309
|
+
|
310
|
+
*Eval Set File Path*
|
311
311
|
For each file, all evals will be run by default.
|
312
312
|
|
313
313
|
If you want to run only specific evals from a eval set, first create a comma
|
314
314
|
separated list of eval names and then add that as a suffix to the eval set
|
315
315
|
file name, demarcated by a `:`.
|
316
316
|
|
317
|
-
For example,
|
317
|
+
For example, we have `sample_eval_set_file.json` file that has following the
|
318
|
+
eval cases:
|
319
|
+
sample_eval_set_file.json:
|
320
|
+
|....... eval_1
|
321
|
+
|....... eval_2
|
322
|
+
|....... eval_3
|
323
|
+
|....... eval_4
|
324
|
+
|....... eval_5
|
318
325
|
|
319
326
|
sample_eval_set_file.json:eval_1,eval_2,eval_3
|
320
327
|
|
321
328
|
This will only run eval_1, eval_2 and eval_3 from sample_eval_set_file.json.
|
322
329
|
|
330
|
+
*Eval Set Id*
|
331
|
+
For each eval set, all evals will be run by default.
|
332
|
+
|
333
|
+
If you want to run only specific evals from a eval set, first create a comma
|
334
|
+
separated list of eval names and then add that as a suffix to the eval set
|
335
|
+
file name, demarcated by a `:`.
|
336
|
+
|
337
|
+
For example, we have `sample_eval_set_id` that has following the eval cases:
|
338
|
+
sample_eval_set_id:
|
339
|
+
|....... eval_1
|
340
|
+
|....... eval_2
|
341
|
+
|....... eval_3
|
342
|
+
|....... eval_4
|
343
|
+
|....... eval_5
|
344
|
+
|
345
|
+
If we did:
|
346
|
+
sample_eval_set_id:eval_1,eval_2,eval_3
|
347
|
+
|
348
|
+
This will only run eval_1, eval_2 and eval_3 from sample_eval_set_id.
|
349
|
+
|
323
350
|
CONFIG_FILE_PATH: The path to config file.
|
324
351
|
|
325
352
|
PRINT_DETAILED_RESULTS: Prints detailed results on the console.
|
@@ -327,17 +354,23 @@ def cli_eval(
|
|
327
354
|
envs.load_dotenv_for_agent(agent_module_file_path, ".")
|
328
355
|
|
329
356
|
try:
|
357
|
+
from ..evaluation.base_eval_service import InferenceConfig
|
358
|
+
from ..evaluation.base_eval_service import InferenceRequest
|
359
|
+
from ..evaluation.eval_metrics import EvalMetric
|
360
|
+
from ..evaluation.eval_result import EvalCaseResult
|
361
|
+
from ..evaluation.evaluator import EvalStatus
|
362
|
+
from ..evaluation.in_memory_eval_sets_manager import InMemoryEvalSetsManager
|
363
|
+
from ..evaluation.local_eval_service import LocalEvalService
|
364
|
+
from ..evaluation.local_eval_set_results_manager import LocalEvalSetResultsManager
|
330
365
|
from ..evaluation.local_eval_sets_manager import load_eval_set_from_file
|
331
|
-
from .
|
332
|
-
from .cli_eval import
|
333
|
-
from .cli_eval import
|
366
|
+
from ..evaluation.local_eval_sets_manager import LocalEvalSetsManager
|
367
|
+
from .cli_eval import _collect_eval_results
|
368
|
+
from .cli_eval import _collect_inferences
|
334
369
|
from .cli_eval import get_evaluation_criteria_or_default
|
335
370
|
from .cli_eval import get_root_agent
|
336
371
|
from .cli_eval import parse_and_get_evals_to_run
|
337
|
-
|
338
|
-
|
339
|
-
except ModuleNotFoundError:
|
340
|
-
raise click.ClickException(MISSING_EVAL_DEPENDENCIES_MESSAGE)
|
372
|
+
except ModuleNotFoundError as mnf:
|
373
|
+
raise click.ClickException(MISSING_EVAL_DEPENDENCIES_MESSAGE) from mnf
|
341
374
|
|
342
375
|
evaluation_criteria = get_evaluation_criteria_or_default(config_file_path)
|
343
376
|
eval_metrics = []
|
@@ -349,81 +382,104 @@ def cli_eval(
|
|
349
382
|
print(f"Using evaluation criteria: {evaluation_criteria}")
|
350
383
|
|
351
384
|
root_agent = get_root_agent(agent_module_file_path)
|
352
|
-
|
353
|
-
|
354
|
-
|
385
|
+
app_name = os.path.basename(agent_module_file_path)
|
386
|
+
agents_dir = os.path.dirname(agent_module_file_path)
|
387
|
+
eval_sets_manager = None
|
355
388
|
eval_set_results_manager = None
|
389
|
+
|
356
390
|
if eval_storage_uri:
|
357
391
|
gcs_eval_managers = evals.create_gcs_eval_managers_from_uri(
|
358
392
|
eval_storage_uri
|
359
393
|
)
|
360
|
-
|
394
|
+
eval_sets_manager = gcs_eval_managers.eval_sets_manager
|
361
395
|
eval_set_results_manager = gcs_eval_managers.eval_set_results_manager
|
362
396
|
else:
|
363
|
-
eval_set_results_manager = LocalEvalSetResultsManager(
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
)
|
375
|
-
|
397
|
+
eval_set_results_manager = LocalEvalSetResultsManager(agents_dir=agents_dir)
|
398
|
+
|
399
|
+
inference_requests = []
|
400
|
+
eval_set_file_or_id_to_evals = parse_and_get_evals_to_run(
|
401
|
+
eval_set_file_path_or_id
|
402
|
+
)
|
403
|
+
|
404
|
+
# Check if the first entry is a file that exists, if it does then we assume
|
405
|
+
# rest of the entries are also files. We enforce this assumption in the if
|
406
|
+
# block.
|
407
|
+
if eval_set_file_or_id_to_evals and os.path.exists(
|
408
|
+
list(eval_set_file_or_id_to_evals.keys())[0]
|
409
|
+
):
|
410
|
+
eval_sets_manager = InMemoryEvalSetsManager()
|
411
|
+
|
412
|
+
# Read the eval_set files and get the cases.
|
413
|
+
for (
|
414
|
+
eval_set_file_path,
|
415
|
+
eval_case_ids,
|
416
|
+
) in eval_set_file_or_id_to_evals.items():
|
417
|
+
try:
|
418
|
+
eval_set = load_eval_set_from_file(
|
419
|
+
eval_set_file_path, eval_set_file_path
|
420
|
+
)
|
421
|
+
except FileNotFoundError as fne:
|
376
422
|
raise click.ClickException(
|
377
|
-
f"
|
423
|
+
f"`{eval_set_file_path}` should be a valid eval set file."
|
424
|
+
) from fne
|
425
|
+
|
426
|
+
eval_sets_manager.create_eval_set(
|
427
|
+
app_name=app_name, eval_set_id=eval_set.eval_set_id
|
428
|
+
)
|
429
|
+
for eval_case in eval_set.eval_cases:
|
430
|
+
eval_sets_manager.add_eval_case(
|
431
|
+
app_name=app_name,
|
432
|
+
eval_set_id=eval_set.eval_set_id,
|
433
|
+
eval_case=eval_case,
|
378
434
|
)
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
user_id=eval_case_result.user_id,
|
404
|
-
session_id=eval_case_result.session_id,
|
435
|
+
inference_requests.append(
|
436
|
+
InferenceRequest(
|
437
|
+
app_name=app_name,
|
438
|
+
eval_set_id=eval_set.eval_set_id,
|
439
|
+
eval_case_ids=eval_case_ids,
|
440
|
+
inference_config=InferenceConfig(),
|
441
|
+
)
|
442
|
+
)
|
443
|
+
else:
|
444
|
+
# We assume that what we have are eval set ids instead.
|
445
|
+
eval_sets_manager = (
|
446
|
+
eval_sets_manager
|
447
|
+
if eval_storage_uri
|
448
|
+
else LocalEvalSetsManager(agents_dir=agents_dir)
|
449
|
+
)
|
450
|
+
|
451
|
+
for eval_set_id_key, eval_case_ids in eval_set_file_or_id_to_evals.items():
|
452
|
+
inference_requests.append(
|
453
|
+
InferenceRequest(
|
454
|
+
app_name=app_name,
|
455
|
+
eval_set_id=eval_set_id_key,
|
456
|
+
eval_case_ids=eval_case_ids,
|
457
|
+
inference_config=InferenceConfig(),
|
458
|
+
)
|
405
459
|
)
|
406
|
-
eval_case_results.append(eval_case_result)
|
407
|
-
return eval_case_results
|
408
460
|
|
409
461
|
try:
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
# Write eval set results.
|
415
|
-
eval_set_id_to_eval_results = collections.defaultdict(list)
|
416
|
-
for eval_case_result in eval_results:
|
417
|
-
eval_set_id = eval_case_result.eval_set_id
|
418
|
-
eval_set_id_to_eval_results[eval_set_id].append(eval_case_result)
|
419
|
-
|
420
|
-
for eval_set_id, eval_case_results in eval_set_id_to_eval_results.items():
|
421
|
-
eval_set_results_manager.save_eval_set_result(
|
422
|
-
app_name=os.path.basename(agent_module_file_path),
|
423
|
-
eval_set_id=eval_set_id,
|
424
|
-
eval_case_results=eval_case_results,
|
462
|
+
eval_service = LocalEvalService(
|
463
|
+
root_agent=root_agent,
|
464
|
+
eval_sets_manager=eval_sets_manager,
|
465
|
+
eval_set_results_manager=eval_set_results_manager,
|
425
466
|
)
|
426
467
|
|
468
|
+
inference_results = asyncio.run(
|
469
|
+
_collect_inferences(
|
470
|
+
inference_requests=inference_requests, eval_service=eval_service
|
471
|
+
)
|
472
|
+
)
|
473
|
+
eval_results = asyncio.run(
|
474
|
+
_collect_eval_results(
|
475
|
+
inference_results=inference_results,
|
476
|
+
eval_service=eval_service,
|
477
|
+
eval_metrics=eval_metrics,
|
478
|
+
)
|
479
|
+
)
|
480
|
+
except ModuleNotFoundError as mnf:
|
481
|
+
raise click.ClickException(MISSING_EVAL_DEPENDENCIES_MESSAGE) from mnf
|
482
|
+
|
427
483
|
print("*********************************************************************")
|
428
484
|
eval_run_summary = {}
|
429
485
|
|
@@ -461,7 +517,10 @@ def adk_services_options():
|
|
461
517
|
"--session_service_uri",
|
462
518
|
help=(
|
463
519
|
"""Optional. The URI of the session service.
|
464
|
-
- Use 'agentengine://<
|
520
|
+
- Use 'agentengine://<agent_engine>' to connect to Agent Engine
|
521
|
+
sessions. <agent_engine> can either be the full qualified resource
|
522
|
+
name 'projects/abc/locations/us-central1/reasoningEngines/123' or
|
523
|
+
the resource id '123'.
|
465
524
|
- Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
|
466
525
|
- See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported database URIs."""
|
467
526
|
),
|
@@ -487,11 +546,12 @@ def adk_services_options():
|
|
487
546
|
@click.option(
|
488
547
|
"--memory_service_uri",
|
489
548
|
type=str,
|
490
|
-
help=(
|
491
|
-
"""Optional. The URI of the memory service.
|
549
|
+
help=("""Optional. The URI of the memory service.
|
492
550
|
- Use 'rag://<rag_corpus_id>' to connect to Vertex AI Rag Memory Service.
|
493
|
-
- Use 'agentengine://<
|
494
|
-
|
551
|
+
- Use 'agentengine://<agent_engine>' to connect to Agent Engine
|
552
|
+
sessions. <agent_engine> can either be the full qualified resource
|
553
|
+
name 'projects/abc/locations/us-central1/reasoningEngines/123' or
|
554
|
+
the resource id '123'."""),
|
495
555
|
default=None,
|
496
556
|
)
|
497
557
|
@functools.wraps(func)
|
@@ -1021,7 +1081,8 @@ def cli_deploy_agent_engine(
|
|
1021
1081
|
Example:
|
1022
1082
|
|
1023
1083
|
adk deploy agent_engine --project=[project] --region=[region]
|
1024
|
-
--staging_bucket=[staging_bucket] --display_name=[app_name]
|
1084
|
+
--staging_bucket=[staging_bucket] --display_name=[app_name]
|
1085
|
+
path/to/my_agent
|
1025
1086
|
"""
|
1026
1087
|
try:
|
1027
1088
|
cli_deploy.to_agent_engine(
|