Skip to content

Commit

Permalink
deploy: ad54862
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c committed Feb 2, 2024
1 parent 8364395 commit 2601372
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
3 changes: 3 additions & 0 deletions _modules/agentscope/constants.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ <h1>Source code for agentscope.constants</h1><div class="highlight"><pre>
<span class="n">_DEFAULT_SUBDIR_CODE</span> <span class="o">=</span> <span class="s2">&quot;code&quot;</span>
<span class="n">_DEFAULT_SUBDIR_FILE</span> <span class="o">=</span> <span class="s2">&quot;file&quot;</span>
<span class="n">_DEFAULT_SUBDIR_INVOKE</span> <span class="o">=</span> <span class="s2">&quot;invoke&quot;</span>
<span class="n">_DEFAULT_CFG_NAME</span> <span class="o">=</span> <span class="s2">&quot;.config&quot;</span>
<span class="n">_DEFAULT_IMAGE_NAME</span> <span class="o">=</span> <span class="s2">&quot;image_</span><span class="si">{}</span><span class="s2">_</span><span class="si">{}</span><span class="s2">.png&quot;</span>
<span class="n">_DEFAULT_SQLITE_DB_PATH</span> <span class="o">=</span> <span class="s2">&quot;agentscope.db&quot;</span>


<span class="c1"># for model wrapper</span>
<span class="n">_DEFAULT_MAX_RETRIES</span> <span class="o">=</span> <span class="mi">3</span>
<span class="n">_DEFAULT_MESSAGES_KEY</span> <span class="o">=</span> <span class="s2">&quot;inputs&quot;</span>
Expand Down
25 changes: 21 additions & 4 deletions _modules/agentscope/utils/tools.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,15 @@ <h1>Source code for agentscope.utils.tools</h1><div class="highlight"><pre>



<span class="k">def</span> <span class="nf">_get_timestamp</span><span class="p">(</span><span class="n">format_</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;%Y-%m-</span><span class="si">%d</span><span class="s2"> %H:%M:%S&quot;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">_get_timestamp</span><span class="p">(</span>
<span class="n">format_</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;%Y-%m-</span><span class="si">%d</span><span class="s2"> %H:%M:%S&quot;</span><span class="p">,</span>
<span class="n">time</span><span class="p">:</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Get current timestamp.&quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="n">format_</span><span class="p">)</span>
<span class="k">if</span> <span class="n">time</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">now</span><span class="p">()</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="n">format_</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="n">time</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span><span class="n">format_</span><span class="p">)</span>


<div class="viewcode-block" id="to_openai_dict">
Expand Down Expand Up @@ -239,9 +245,20 @@ <h1>Source code for agentscope.utils.tools</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="kc">False</span>


<span class="k">def</span> <span class="nf">_generate_random_code</span><span class="p">(</span><span class="n">length</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">6</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">_generate_random_code</span><span class="p">(</span>
<span class="n">length</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">6</span><span class="p">,</span>
<span class="n">uppercase</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
<span class="n">lowercase</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
<span class="n">digits</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Get random code.&quot;&quot;&quot;</span>
<span class="n">characters</span> <span class="o">=</span> <span class="n">string</span><span class="o">.</span><span class="n">ascii_letters</span> <span class="o">+</span> <span class="n">string</span><span class="o">.</span><span class="n">digits</span>
<span class="n">characters</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
<span class="k">if</span> <span class="n">uppercase</span><span class="p">:</span>
<span class="n">characters</span> <span class="o">+=</span> <span class="n">string</span><span class="o">.</span><span class="n">ascii_uppercase</span>
<span class="k">if</span> <span class="n">lowercase</span><span class="p">:</span>
<span class="n">characters</span> <span class="o">+=</span> <span class="n">string</span><span class="o">.</span><span class="n">ascii_lowercase</span>
<span class="k">if</span> <span class="n">digits</span><span class="p">:</span>
<span class="n">characters</span> <span class="o">+=</span> <span class="n">string</span><span class="o">.</span><span class="n">digits</span>
<span class="k">return</span> <span class="s2">&quot;&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">secrets</span><span class="o">.</span><span class="n">choice</span><span class="p">(</span><span class="n">characters</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">length</span><span class="p">))</span>
</pre></div>

Expand Down

0 comments on commit 2601372

Please sign in to comment.