Skip to content

Commit

Permalink
deploy: 3ea680b
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c committed Mar 7, 2024
1 parent 84788b7 commit ad66272
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
19 changes: 9 additions & 10 deletions _modules/agentscope/utils/logging_utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ <h1>Source code for agentscope.utils.logging_utils</h1><div class="highlight"><p
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">threading</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Optional</span><span class="p">,</span> <span class="n">Literal</span><span class="p">,</span> <span class="n">Union</span><span class="p">,</span> <span class="n">Any</span>

<span class="kn">from</span> <span class="nn">loguru</span> <span class="kn">import</span> <span class="n">logger</span>
Expand All @@ -101,6 +100,7 @@ <h1>Source code for agentscope.utils.logging_utils</h1><div class="highlight"><p
<span class="n">generate_image_from_name</span><span class="p">,</span>
<span class="n">send_msg</span><span class="p">,</span>
<span class="n">get_reset_msg</span><span class="p">,</span>
<span class="n">thread_local_data</span><span class="p">,</span>
<span class="p">)</span>

<span class="n">LOG_LEVEL</span> <span class="o">=</span> <span class="n">Literal</span><span class="p">[</span>
Expand Down Expand Up @@ -212,9 +212,8 @@ <h1>Source code for agentscope.utils.logging_utils</h1><div class="highlight"><p
<span class="p">)</span>
<span class="n">logger</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">LEVEL_CHAT_LOG</span><span class="p">,</span> <span class="n">print_str</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

<span class="n">thread_name</span> <span class="o">=</span> <span class="n">threading</span><span class="o">.</span><span class="n">current_thread</span><span class="p">()</span><span class="o">.</span><span class="n">name</span>
<span class="k">if</span> <span class="n">thread_name</span> <span class="o">!=</span> <span class="s2">&quot;MainThread&quot;</span><span class="p">:</span>
<span class="n">log_gradio</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">thread_name</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">thread_local_data</span><span class="p">,</span> <span class="s2">&quot;uid&quot;</span><span class="p">):</span>
<span class="n">log_gradio</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">thread_local_data</span><span class="o">.</span><span class="n">uid</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="k">return</span>

<span class="n">message</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">message</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;{&quot;</span><span class="p">,</span> <span class="s2">&quot;{{&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;}&quot;</span><span class="p">,</span> <span class="s2">&quot;}}&quot;</span><span class="p">)</span>
Expand All @@ -223,19 +222,19 @@ <h1>Source code for agentscope.utils.logging_utils</h1><div class="highlight"><p

<div class="viewcode-block" id="log_gradio">
<a class="viewcode-back" href="../../../agentscope.utils.html#agentscope.utils.logging_utils.log_gradio">[docs]</a>
<span class="k">def</span> <span class="nf">log_gradio</span><span class="p">(</span><span class="n">message</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">thread_name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">log_gradio</span><span class="p">(</span><span class="n">message</span><span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">uid</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kc">None</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Send chat message to gradio.</span>

<span class="sd"> Args:</span>
<span class="sd"> message (`dict`):</span>
<span class="sd"> The message to be logged. It should have &quot;name&quot;(or &quot;role&quot;) and</span>
<span class="sd"> &quot;content&quot; keys, and the message will be logged as &quot;&lt;name/role&gt;:</span>
<span class="sd"> &lt;content&gt;&quot;.</span>
<span class="sd"> thread_name (`str`):</span>
<span class="sd"> The name of the thread.</span>
<span class="sd"> uid (`str`):</span>
<span class="sd"> The local value &#39;uid&#39; of the thread.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">thread_name</span> <span class="o">!=</span> <span class="s2">&quot;MainThread&quot;</span><span class="p">:</span>
<span class="n">get_reset_msg</span><span class="p">(</span><span class="n">uid</span><span class="o">=</span><span class="n">thread_name</span><span class="p">)</span>
<span class="k">if</span> <span class="n">uid</span><span class="p">:</span>
<span class="n">get_reset_msg</span><span class="p">(</span><span class="n">uid</span><span class="o">=</span><span class="n">uid</span><span class="p">)</span>
<span class="n">name</span> <span class="o">=</span> <span class="n">message</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;name&quot;</span><span class="p">,</span> <span class="s2">&quot;default&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="n">message</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;role&quot;</span><span class="p">,</span> <span class="s2">&quot;default&quot;</span><span class="p">)</span>
<span class="n">avatar</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;avatar&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span> <span class="ow">or</span> <span class="n">generate_image_from_name</span><span class="p">(</span>
<span class="n">message</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">],</span>
Expand Down Expand Up @@ -267,7 +266,7 @@ <h1>Source code for agentscope.utils.logging_utils</h1><div class="highlight"><p
<span class="n">send_msg</span><span class="p">(</span>
<span class="n">msg</span><span class="p">,</span>
<span class="n">role</span><span class="o">=</span><span class="n">name</span><span class="p">,</span>
<span class="n">uid</span><span class="o">=</span><span class="n">thread_name</span><span class="p">,</span>
<span class="n">uid</span><span class="o">=</span><span class="n">uid</span><span class="p">,</span>
<span class="n">flushing</span><span class="o">=</span><span class="n">flushing</span><span class="p">,</span>
<span class="n">avatar</span><span class="o">=</span><span class="n">avatar</span><span class="p">,</span>
<span class="p">)</span></div>
Expand Down
4 changes: 2 additions & 2 deletions agentscope.utils.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ <h1>Utils package<a class="headerlink" href="#utils-package" title="Link to this
<p>Logging utilities.</p>
<dl class="py function">
<dt class="sig sig-object py" id="agentscope.utils.logging_utils.log_gradio">
<span class="sig-prename descclassname"><span class="pre">agentscope.utils.logging_utils.</span></span><span class="sig-name descname"><span class="pre">log_gradio</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">message</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">thread_name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="_modules/agentscope/utils/logging_utils.html#log_gradio"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#agentscope.utils.logging_utils.log_gradio" title="Link to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">agentscope.utils.logging_utils.</span></span><span class="sig-name descname"><span class="pre">log_gradio</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">message</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">dict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">uid</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="reference internal" href="_modules/agentscope/utils/logging_utils.html#log_gradio"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#agentscope.utils.logging_utils.log_gradio" title="Link to this definition"></a></dt>
<dd><p>Send chat message to gradio.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>message</strong> (<cite>dict</cite>) – The message to be logged. It should have “name”(or “role”) and
“content” keys, and the message will be logged as “&lt;name/role&gt;:
&lt;content&gt;”.</p></li>
<li><p><strong>thread_name</strong> (<cite>str</cite>) – The name of the thread.</p></li>
<li><p><strong>uid</strong> (<cite>str</cite>) – The local value ‘uid’ of the thread.</p></li>
</ul>
</dd>
</dl>
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit ad66272

Please sign in to comment.