D"h :ddlZddlZddlmZmZddlZddlZddl m Z ddl m Z ddlmZddlmZddlmZmZmZddlmZddlmZddlmZddlmZdd lmZej e!Z"d Z#e#dtd e$d e$de$fdZ%e#dtde$d e$de$fdZ&e#dtde$d e$de$fdZ'e# dude$d e$de$de$fdZ(e#de$de$fdZ)e#de$de$fdZ*e#de$de$fdZ+e#deee,deee,deee,fdZ-e#deee,deee,deee,fdZ.e#deee,deee,deee,fdZ/e#deee,deee,fdZ0e#deee,de,fd Z1e#deee,deee,fd!Z2e#deee,de3fd"Z4e#deee,de,fd#Z5e#dvdeee,d%e$de,fd&Z6e#deee,dee7fd'Z8e#deee,deee7fd(Z9e#deee,dee$effd)Z:e#deee,dee$effd*Z;e#deee,dee$effd+Ze#dwd,ee,d0e3de,fd1Z?e#dwd,ee,d0e3de,fd2Z@e#d,ee,d3e,de,fd4ZAe#dwd ee,d5ee,d0e3de,fd6ZBe#d ee,d5ee,de,fd7ZCe#d ee,d5ee,dee$e,ffd8ZDe#d9ee,dee7fd:ZEe#d;ee,de$de,de,d e$de,f d?ZGe# dxd>e$dAe,dBee,dCeHdee,f dDZIe#dee,dee,de,fdEZJe#dee,dee,dee,fdFZKe#dee,de,fdGZLe#dee,dee,fdHZMe#dydee,dee,dJeNde,fdKZOe#dLe3dMe3dNe,de,fdOZPe#dzd e,dPe,dQe,de,fdRZQe#dzd e,dPe,dQe,de,fdSZRe#dLe3dTe,de,fdUZSe#d e,de,fdVZTe#d e,d5e,de,fdWZUe#d e,de,fdXZVe#d5ee,dee7fdYZWe#dZee7dee7fd[ZXdeefd\ZYdaZdeefd]Z[ eZ\e\]Z^e^s e_d^e`d_e^DdZaea e_d`e"bdan3#ec$r+Zde"edbeddcde_deeddZd[dwwxYwdefdfZfe!dgkrejgejhdhie"bdjdkgZidleiDZjejr$ekdmdnlejdodSejmdps ekdq efZnekdrdS#ec$rZdekdsedYdZd[ddSdZd[dwwxYwdS){N)ListDict)CodeInterpreterToolSpec)quad)binomnormpoisson) ReActAgent) FunctionTool) GoogleGenAI)WolframAlphaToolSpeccfdS)Nc~j}td|d|d| |i|}td|dt|dddt |t jr|St |t jt j t j t j t j t j t jt jt jt jt jf rt'|St |t jt jt jt jfrt1|St |t jt jt jfrt9|St |t jrt=|St |t>r fd| DS|S#tBj"tFtHt j%j&tNf$r2}t(d |d |d |d |cYd}~Sd}~wtR$r4}t*d |d |d d |d |cYd}~Sd}~wwxYw)NzExecuting math tool: z with args: z , kwargs: zTool z executed successfully. Result: z...c i|]D\}}|t|tjtjtjfr |n|ES) isinstancenpndarraynumberbool_).0kvwrappers 8/Users/aedelon/Workspace/GAIA_Agent/agents/math_agent.py z6math_tool_handler..wrapper..,sM}}}fjfgij*QRYPRPX8Y*Z*ZaGGAJJJ`a}}}zMath error in : z Error in zUnexpected error in Texc_info)+__name__loggerinfostrrrrtolistint_intcintpint8int16int32int64uint8uint16uint32uint64intfloat_float16float32float64floatcomplex_ complex64 complex128complexrbooldictitemssp SympifyError TypeError ValueErrorlinalg LinAlgErrorZeroDivisionErrorwarning Exceptionerror)argskwargs func_nameresultefuncrs rrz"math_tool_handler..wrappersM  [I[[4[[SY[[\\\ ;T4*6**F KKa aa3v;;W[X[W[K\aaa b b b&"*-- '}}&&27BGRWbgrxQSQY[][cegemoqoxz|{DFHFO#PQQ $F #&29bj"*bj"QRR &f %&2; bm"LMM ('&"(++ %V $&$'' ~}}}}ntnznzn|n|}}}}MJ 8MO`a 0 0 0 NN>#q))SuRZ ,,bj.E.EFFv&&I $ $ $$r expressionctj|}tj|}tj||}d|S)zGCompute the symbolic derivative of an expression (e.g., 'sin(x)*x**2').z Derivative: )r?rWrXdiff)rcrRr]r^derivs rcompute_derivativergDsAZ ! !F :j ! !D GD& ! !E !% ! !!rctj|}tj|}tj||}d|dS)zHCompute the symbolic indefinite integral of an expression (e.g., '1/x').z Integral: z + C)r?rWrX integrate)rcrRr]r^integs rcompute_integralrkLsDZ ! !F :j ! !D Lv & &E # # # ##roopointctj|}tj|}|dkr tj}n_|dkrtj }n9|dkr tj}ntj|}tj|||}d|d|S)zeCompute the limit of an expression (e.g., 'sin(x)/x') as variable approaches point (e.g., '0', 'oo').rlz-oozooz Limit at r)r?rWrXlowerrlrolimit)rcrRrmr]r^ptlims r compute_limitrtTs Z ! !F :j ! !D {{}} U %  eV %   V Z   (4 $ $C %u % % % %%rc\tj|}tj|}d|S)z?Simplify a symbolic expression (e.g., 'sin(x)**2 + cos(x)**2').zSimplified expression: )r?rXsimplify)rcr^simps rsimplify_expressionrxgs0 :j ! !D ;t  D +T + ++rc\tj|}tj|}d|S)z0Expand a symbolic expression (e.g., '(x+y)**2').zExpanded expression: )r?rXexpand)rcr^exps rexpand_expressionr|ns. :j ! !D )D//C (3 ( ((rc\tj|}tj|}d|S)z3Factor a symbolic expression (e.g., 'x**2 - y**2').zFactored expression: )r?rXfactor)rcr^facts rfactor_expressionrus. :j ! !D 9T??D )4 ) ))rabctj|}tj|}|j|jkrtd||zS)zIAdd two matrices element-wise. Input: [[1, 2], [3, 4]], [[5, 6], [7, 8]].z/Matrices must have the same shape for addition.rarrayshaperBrrABs rmatrix_additionr~sE  A  Aw!'JKKK ENrctj|}tj|}|j|jkrtd||z S)zXSubtract matrix B from matrix A element-wise. Input: [[5, 6], [7, 8]], [[1, 2], [3, 4]].z2Matrices must have the same shape for subtraction.rrs rmatrix_subtractionrsE  A  Aw!'MNNN ENrctj|}tj|}|jd|jdkrtdtj||S)zAMultiply two matrices. Input: [[1, 2], [3, 4]], [[5, 6], [7, 8]].rVrz6Inner dimensions must match for matrix multiplication.)rrrrBmatmulrs rmatrix_multiplicationrsT  A  AwqzQWQZQRRR 9Q??rmatrixctj|}|jd|jdkrtdtj|S)z@Compute the inverse of a square matrix. Input: [[1, 2], [3, 4]].rrVz)Matrix must be square to compute inverse.)rrrrBrCinvrMs rmatrix_inversersM AwqzQWQZDEEE 9==  rctj|}|jd|jdkrtdtj|S)zDCompute the determinant of a square matrix. Input: [[1, 2], [3, 4]].rrVz-Matrix must be square to compute determinant.)rrrrBrCdetrs rmatrix_determinantrsM AwqzQWQZHIII 9==  rc8tj|}|jS)z2Transpose a matrix. Input: [[1, 2, 3], [4, 5, 6]].)rrTrs rmatrix_transposers A 3Jrchtj|}tj|S)z6Compute the rank of a matrix. Input: [[1, 2], [2, 4]].)rrrC matrix_rankrs rrrs) A 9  # ##rctj|}|jd|jdkrtdtj|S)z>Compute the trace of a square matrix. Input: [[1, 2], [3, 4]].rrVz'Matrix must be square to compute trace.)rrrrBtracers r matrix_tracersG AwqzQWQZBCCC 8A;;rfroord_strc Btj|}ddtjtj ddddd}||}|4t d |d t |tj|| S) zCompute the norm of a matrix. ord_str can be 'fro' (Frobenius), 'nuc' (nuclear), inf, -inf, 1, -1, 2, -2. Input: [[1, 2], [3, 4]].rnucrV)rrinfz-inf1z-12z-2NzInvalid ord_str: z. Must be one of )ord) rrrgetrBlistkeysrCr)rrrord_mapord_vals r matrix_normrs AE"&26'PQY[bckmnnGkk'""G]W]]tGLLNNG[G[]]^^^ 9>>!> ) ))rctj|}|jd|jdkrtdtj|}|S)zACompute eigenvalues of a square matrix. Input: [[1, -1], [1, 1]].rrVz-Matrix must be square to compute eigenvalues.)rrrrBrCeigvals)rrvalss r eigenvaluesrsS AwqzQWQZHIII 9  Q  D Krctj|}|jd|jdkrtdtj|\}}|jS)z`Compute eigenvectors of a square matrix. Returns list of eigenvectors. Input: [[1, -1], [1, 1]].rrVz.Matrix must be square to compute eigenvectors.)rrrrBrCeigr)rrrvecss r eigenvectorsrsW AwqzQWQZIJJJq!!JD$ 6Mrc|tj|}tj|\}}}|||dS)zaCompute the singular value decomposition (U, S, Vh) of a matrix. Input: [[1, 2], [3, 4], [5, 6]].)USVh)rrrCsvd)rrrrrs r svd_decomposers< Ay}}QHAq"" % %%rcftj|}tj|\}}}|||dS)zLCompute the LU decomposition (P, L, U) of a matrix. Input: [[1, 2], [3, 4]].)PLr)rrlalu)rrrrrs r lu_decomposers6 AeAhhGAq! # ##rcxtj|}tj|\}}||dS)zICompute the QR decomposition (Q, R) of a matrix. Input: [[1, 2], [3, 4]].)QR)rrrCqr)rrrrs r qr_decomposers6 A 9<<??DAq  rvaluescp|stdtjtj|S)z>Compute the mean of a list of numbers. Input: [1, 2, 3, 4, 5].z0Input list cannot be empty for mean calculation.)rBrmeanrrs rrrs6 MKLLL 728F## $ $$rcp|stdtjtj|S)z@Compute the median of a list of numbers. Input: [1, 3, 2, 4, 5].z2Input list cannot be empty for median calculation.)rBrmedianrrs rrrs6 OMNNN 9RXf%% & &&rrVddofc|rt||krtd|d|dtjtj||S)zhCompute the sample standard deviation (ddof=1) or population (ddof=0) of a list. Input: [1, 2, 3, 4, 5].Input list must have at least z elements for std dev with ddof=.r)lenrBrstdrrrs rstd_devrs_ jS[[4''h4hhaehhhii i 6"(6"" . . ..rc|rt||krtd|d|dtjtj||S)z^Compute the sample variance (ddof=1) or population (ddof=0) of a list. Input: [1, 2, 3, 4, 5].rz! elements for variance with ddof=rr)rrBrvarrrs rvariancers_ kS[[4''i4iibfiiijj j 6"(6"" . . ..rpercentc|stdd|cxkrdksntdtjtj||S)zNCompute the q-th percentile (0<=q<=100) of a list. Input: [1, 2, 3, 4, 5], 75.z6Input list cannot be empty for percentile calculation.rdz"Percent must be between 0 and 100.)rBr percentiler)rrs rrr sf SQRRR     C    =>>> =&))7 3 33ryc"tj|}tj|}|j|jkrtd|jdks |j|krtd|d|dtj|||dS)ziCompute sample covariance (ddof=1) or population (ddof=0) between two lists. Input: [1, 2, 3], [4, 5, 6].z5Input lists must have the same length for covariance.rzInput lists must have at least z# elements for covariance with ddof=rrrrV)rrsizerBcov)rPrrXYs r covariancers  A  AvPQQQv{{aftmmlDlleilllmm m 6!QT " " "4 ((rcjtj|}tj|}|j|jkrtd|jdkrtdtj||}tj|drt ddS|dS)zYCompute Pearson correlation coefficient between two lists. Input: [1, 2, 3], [1, 2, 3.1].z6Input lists must have the same length for correlation.rz,Need at least 2 data points for correlation.rzYCorrelation resulted in NaN, likely due to zero standard deviation in one or both inputs.g)rrrrBcorrcoefisnanr#rF)rPrrr corr_matrixs r correlationr!s  A  AvQRRRvzzGHHH+a##K x D!""rssss t rctj|}tj|}|j|jkrtd|jdkrtdtj||d\}}||dS)ztPerform simple linear regression (y = mx + c). Returns slope (m) and intercept (c). Input: [1, 2, 3], [2, 4.1, 5.9].z<=== 8L ! !!rx_valsy_valsc`t|t|krtdt|dkrtdtj|}tj||}tj||}tj|||S)zeLinear interpolate a value at x given data points (x_vals, y_vals). Input: [0, 1, 2], [0, 1, 4], 1.5.z,x_vals and y_vals must have the same length.rz.Need at least 2 data points for interpolation.)rrBrargsortrinterp)rrrPsorted_indicesx_sortedy_sorteds rinterpolate_valuerGs 6{{c&kk!!GHHH 6{{QIJJJZ''Nx/Hx/H 9Q( + ++rfunc_strcRtj|} tj|}tj||dg}n3#tjt f$r}t d|d|d}~wwxYwt|||\}} t d| |S)zXNumerically integrate func_str (e.g., 'x**2 * sin(x)') from a to b. Input: 'x**2', 0, 1.numpy)moduleszInvalid function string: z . Error: Nz0Numerical integration estimated absolute error: ) r?rWrXlambdifyr@ SyntaxErrorrBrr#r$) rrrrRr]rN f_lambdifiedsym_errrLabserrs rnumerical_integrationr Ts Z ! !FSz(##{64'CCC O[ )SSSQXQQQQRRRS,1--NFF KKK6KKLLL Ms,AA3A..A3ry0t_evalrIcddlm}ddlfd}|stdt |t |f}||||g||}|jstd|j|j dS)a~Solve a first-order ODE dy/dt = f(t, y) using scipy.integrate.solve_ivp. func_str should define f(t, y), e.g., '-y + sin(t)'. y0 is the initial condition y(t_eval[0]). t_eval is the list of time points to evaluate the solution at. args are optional additional arguments passed to f(t, y, *args). Input: func_str='-y', y0=1, t_eval=[0, 1, 2, 3, 4].r) solve_ivpNc  ||td}|r t|D]\}}||d|dz<tdii|S#t$r=}tdd|d|d|t d |d}~wwxYw) N)trmathrprV __builtins__zError evaluating ODE function z at t=z, y=rz"Error in ODE function definition: )r enumerateevalrGr#rHrB) rrrI local_varsiarg_valrMrrs rode_funczsolve_ode..ode_funcus G q$bAAJ 4"+D//44JAw,3Jy1Q3yy))>2"6 CC C G G G LLY(YY!YYQRYYVWYY Z Z ZE!EEFF F GsAA B 8BB zt_eval list cannot be empty.)r rIzODE solver failed: ) scipy.integrater rrBminmaxsuccess RuntimeErrormessager) rr r rIr rt_spansolrs ` @r solve_oder!fs*)))))KKK G G G G G G 97888&kk3v;; 'F )Hfrd6 E E EC ;@>>>??? 58Orctj|}tj|}|j|jkrtdtj||S)z@Compute dot product of two vectors. Input: [1, 2, 3], [4, 5, 6].z5Vectors must have the same dimension for dot product.)rrrrBdotrs r dot_productr$sL  A  Aw!'PQQQ 6!Q<<rctj|}tj|}|jdks |jdkrtdtj||S)zECompute cross product of two 3D vectors. Input: [1, 0, 0], [0, 1, 0].z-Cross product is only defined for 3D vectors.)rrrrBcrossrs r cross_productr(sR  A  Av{{afkkHIII 8Aq>>rc|stdtjtj|S)z>Compute magnitude (Euclidean norm) of a vector. Input: [3, 4].zInput vector cannot be empty.)rBrrCrr)rs rvector_magnituder*s7 :8999 9>>"(1++ & &&rctj|}tj|}|dkrt d||z S)z1Normalize a vector to unit length. Input: [3, 4].rzCannot normalize a zero vector.)rrrCrrB)rrrs rvector_normalizer,sF  A 9>>!  D qyy:;;; HrFdegreesc$t||}t|}t|}|dks|dkrtdtj|||zz dd}tj|}|rtj|n|S)zUCompute the angle (in radians or degrees) between two vectors. Input: [1, 0], [0, 1].rz)Cannot compute angle with zero vector(s).gg?)r$r*rBrcliparccosr-)rrr-r#norm_anorm_b cos_theta angle_rads r vector_angler5s a  C a F a F {{fkkDEEEv/s;;I )$$I$+ :2:i :rrnrcd|cxkrdksntdd|cxkr|ksntdtj|||S)zQCompute binomial probability mass function P(X=k | n, p). Input: k=2, n=5, p=0.5.rrVz&Probability p must be between 0 and 1.z&k must be between 0 and n (inclusive).)rBrpmf)rr6rs r binomial_pmfr9sd KKKKaKKKKABBB KKKKaKKKKABBB 9Q1  rmusigmacX|dkrtdtj|||S)zeCompute normal distribution probability density function N(x | mu, sigma). Input: x=0, mu=0, sigma=1.r*Standard deviation sigma must be positive.)rBrpdfrPr:r;s r normal_pdfr@0 zzEFFF 8Ar5 ! !!rcX|dkrtdtj|||S)zlCompute normal distribution cumulative distribution function P(X<=x | mu, sigma). Input: x=0, mu=0, sigma=1.rr=)rBrcdfr?s r normal_cdfrDrArlamc|dkrtd|dkst|tstdtj||S)zMCompute Poisson probability mass function P(X=k | lambda). Input: k=2, lam=3.rz+Rate parameter lambda must be non-negative.z!k must be a non-negative integer.)rBrr2r r8)rrEs r poisson_pmfrGsT QwwFGGG1uuJq#&&u<=== ;q#  rc*tj|S)z.Compute the gamma function Gamma(x). Input: 5.)specialgammarPs rgamma_functionrLs =  rc,tj||S)z/Compute the beta function B(x, y). Input: 2, 3.)rIbeta)rPrs r beta_functionrOs <1  rc*tj|S)z,Compute the error function erf(x). Input: 1.)rIerfrKs r erf_functionrRs ;q>>rcp|stdtjtj|S)zTCompute the Fast Fourier Transform (FFT) of a real sequence y. Input: [0, 1, 0, -1].z#Input list cannot be empty for FFT.)rBfftrr)rs r fft_transformrUs4 @>??? 728A;;  r y_complexcp|stdtjtj|S)zjCompute the inverse Fast Fourier Transform (IFFT) of a complex sequence. Input: result from fft_transform.z$Input list cannot be empty for IFFT.)rBrTifftrr)rVs rifft_transformrYs6 A?@@@ 8BHY'' ( ((rc( gtjttjttjttjt tjt tjttjttjttjttjttjttjttjttjttjt tjt"tjt$tjt&tjt(tjt*tjt,tjt.tjt0tjt2tjt4tjt6tjt8tjt:tjt<tjt>tjt@tjtBtjtDtjtFtjtHtjtJtjtLtjtNtjtPtjtRtjtTtjtVtjtXtjtZtjt\tjt^tjt`}|D]}d|j1j2|j1_2tf4dtk|d|S)z>Returns a list of FunctionTools for the Python math functions.)fnz (Python) zCreated z Python math tools.)6r from_defaultsrbrgrkrtrxr|rrrrrrrrrrrrrrrrrrrrrrrrrr r!r$r(r*r,r5r9r@rDrGrLrOrRrUrYmetadata descriptionr#r$r)py_toolstools rget_python_math_toolsras8"&=>>>8 "&89998 "&6777 8 "m444 8 "&9::: 8 "&78888 "&78888 "o6668 "&89998 "&;<<<8 "n5558 "&89998 "&67778 "k222!8" "l333#8$ "k222%8& "k222'8( "l333)8* "m444+8, "l333-8. "l333/82 "d+++384 "f---586 "g...788 "h///98: "j111;8< "j111=8> "k222?8@ "&7888A8D "&;<<>> Orcttdtjd}|stdgan t |}|atD]}d|jj |j_ tdttdn8#t$r+}t d |d gaYd}~nd}~wwxYwtS) z8Initializes and returns Wolfram Alpha tools (singleton).Nz$Initializing WolframAlphaToolSpec...WOLFRAM_ALPHA_APP_IDzFWOLFRAM_ALPHA_APP_ID not set. Wolfram Alpha tools will be unavailable.)app_idz(WolframAlpha) z WolframAlpha tools initialized: z tools.z)Failed to initialize WolframAlpha tools: Tr ) _wolfram_alpha_toolsr#r$osgetenvrFr to_tool_listr]r^rrGrH)wolfram_alpha_app_idspecr`rMs rget_wolfram_alpha_toolsrkEs+# :;;;!y)?@@# * NNc d d d#%  *+3GHHH'+'8'8':':$0__D1^4=C\1^1^T].. asCW?X?Xaaabbbb * * * LLLW[ \\\')$$$$$$ * sA7C D!C>>Dz1CodeInterpreterToolSpec did not return any tools.c#:K|]}|jjdk|VdS)code_interpreterN)r]name)rrs r roes1!m!mqzZlGlGl!GlGlGlGl!m!mrzJCould not find 'code_interpreter' tool in CodeInterpreterToolSpec results.z1CodeInterpreterToolSpec initialized successfully.z.Failed to initialize CodeInterpreterToolSpec: Tr zGCodeInterpreterToolSpec failed to initialize. Cannot create code_agent.c tdtjdd}tjd}|s)tdt d t ||d}td |ttztgz}|st d d }td d |||ddg}td|S#t$r%}td|dd}~wwxYw)z?Initializes the Math Agent with Python and Wolfram Alpha tools.zInitializing MathAgent...MATH_AGENT_LLM_MODELzgemini-2.5-pro-preview-03-25GEMINI_API_KEYz@GEMINI_API_KEY not found in environment variables for MathAgent.z(GEMINI_API_KEY must be set for MathAgentg?)api_keymodel temperaturezUsing agent LLM: zONo math tools available (Python or WolframAlpha). MathAgent may be ineffective.u You are MathAgent, a powerful mathematical problem solver. Your goal is to accurately answer mathematical questions using the available tools. Available Tools: - Python Tools: A comprehensive suite for symbolic math (SymPy), numerical computation (NumPy/SciPy), statistics, linear algebra, calculus, ODEs, and transforms. Prefixed with '(Python)'. Use these for precise calculations when the method is clear. - WolframAlpha Tool: Accesses Wolfram Alpha for complex queries, natural language math questions, data, and real-world facts. Prefixed with '(WolframAlpha)'. Use this for broader questions, knowledge-based math, or when Python tools are insufficient. Workflow: 1. **Thought**: Analyze the question. Determine the mathematical concepts involved. Decide the best tool or sequence of tools to use. Prefer Python tools for specific, well-defined calculations. Use WolframAlpha for complex, ambiguous, or knowledge-based queries. 2. **Action**: Call the chosen tool with the correct arguments. Ensure inputs match the tool's requirements (e.g., list of lists for matrices, strings for symbolic expressions). 3. **Observation**: Examine the tool's output. Check for errors or unexpected results. 4. **Iteration**: If the result is incorrect or incomplete, rethink the approach. Try a different tool, adjust parameters, or break the problem down further. If a Python tool fails, consider rephrasing for WolframAlpha. 5. **Final Answer**: Once the correct answer is obtained, state it clearly and concisely. Provide the numerical result, symbolic expression, or explanation as requested. 6. **Hand-Off**: Pass the final mathematical result or analysis to **planner_agent** for integration into the overall response. Constraints: - Always use a tool for calculations; do not perform calculations yourself. - Clearly state which tool you are using and why. - Handle potential errors gracefully and report them if they prevent finding a solution. - Pay close attention to input formats required by each tool (e.g., lists for vectors/matrices, strings for symbolic expressions). If your response exceeds the maximum token limit and cannot be completed in a single reply, please conclude your output with the marker [CONTINUE]. In subsequent interactions, I will prompt you with “continue” to receive the next portion of the response. math_agentzMathAgent solves mathematical problems using a suite of Python tools (SymPy, NumPy, SciPy) and WolframAlpha. It handles symbolic math, numerical computation, statistics, linear algebra, calculus, and more. planner_agentreasoning_agent)rnr^toolsllm system_promptcan_handoff_toz#MathAgent initialized successfully.z'Error during MathAgent initialization: Tr N) r#r$rfrgrHrBr rarkcode_interpreter_toolrFr rG)agent_llm_modelgemini_api_keyrz all_toolsr{agentrMs rinitialize_math_agentrqsw KK+,,,i 68VWWOY/00N E WXXXCDDD6"!     999:::*++.E.G.GGK`Jaa  o ^^m n n n 0s'+->?      9:::  BqBBT RRR s0B%D E EE__main__z4%(asctime)s - %(name)s - %(levelname)s - %(message)s)levelformatz-Running math_agent.py directly for testing...rrc:g|]}tj||Sr)rfrg)rkeys r rs%GGGC #GCGGGrz1Error: Required environment variable(s) not set: z, z. Cannot run test.rczZWarning: WOLFRAM_ALPHA_APP_ID not set. WolframAlpha tools will be unavailable for testing.z0Math Agent initialized successfully for testing.zError during testing: rK)rPrl)r)rV)r)Fr)orfloggingtypingrrsympyr?rr scipy.linalgrCr scipy.specialrI"llama_index.tools.code_interpreterrrr scipy.statsrrr numpy.fftrTllama_index.core.agent.workflowr llama_index.core.toolsr llama_index.llms.google_genair llama_index.tools.wolfram_alphar getLoggerr"r#rOr%rbrgrkrtrxr|rr7rrrrrrr2rrrr;rrrrrrrrrrrrrrrr tupler!r$r(r*r,r<r5r9r@rDrGrLrOrRrUrYrarerkcode_interpreter_specrhcode_interpreter_toolsrnextr}r$rGrMrHr basicConfigINFO required_keys missing_keysprintjoinrg test_agentrrrrs FFFFFF ,,,,,,,,,,666666//////555555@@@@@@  8 $ $ < % %c %S %3 % % % %""3"#"""""$$$$c$$$$7;&&&"&14&&&&&$,C,C,,,, )#)#)))) *#*#****tDK(T$u+->4U CT$tE{+T%[0Ad4PU;FWT$u+.4U 3DdSXkIZ4U ,d5k1BtDK0UT$u+.4U 3D $T%[)$c$$$$ d5k*u**T%[)*C*E****T%[)d7md5k*tDM/B&$tE{+&S$Y&&&& $d5k*$tCI$$$$ d5k*tCI%e%%%%% '4;'5'''' //DK/s/5//// //T%[//E//// 4tE{4U4u4444 ) )$u+ )$u+ )S ) ) ) ) )4;4;5" 4e 4e 4c5j9I 4 4 4 4"U "W """"  ,d5k ,4; ,5 ,U , , , ,7: %14 "AC&&&&&*5k&9>& %[&&&&R4;4;5T%[T%[T%['U ''''' U U  ; ;DK ;DK ;$ ;5 ; ; ; ;CCEe""%"U"u"U"""" ""%"U"u"U"""" 3UueUuEe  T%[ T']    )d7m)W ))))?tL1????D l!3    2i33552??AA !PlNOOO D!m!m-C!m!m!mostt$|hii i KKCDDDDiii LLE!EEPTLUUU ,` a aghh iBzBBBBJ zGgl3ijjjj KK?@@@&&MGG=GGGL0 m$))LBYBYmmmnnnnnry/00 p En o o o 0..00J ED E E E E E  0 0 0 E.1.. / / / / / / / / / 0)s1A#X''Y,&YY#[::\?\\