Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ubuntu committed May 28, 2024
1 parent 5764ca1 commit de63f6d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
11 changes: 4 additions & 7 deletions docs/openai.html
Original file line number Diff line number Diff line change
Expand Up @@ -879,9 +879,10 @@ <h3 id='api-create-images'>API - Create images</h3>
<p><code>POST https://openai.pgpt.cloud/v1/images/generations</code></p>
<h4 id='request-body-4'>Request body</h4>
<blockquote>
<p>Create image 请求示范 (openai &lt; 1.0)</p>
<p>Create image 请求示范</p>
</blockquote>
<div class="highlight"><pre class="highlight python tab-python"><code><span class="kn">import</span> <span class="nn">openai</span>
<div class="highlight"><pre class="highlight python tab-python"><code><span class="c1"># openai &lt; 1.0
</span><span class="kn">import</span> <span class="nn">openai</span>
<span class="n">openai</span><span class="p">.</span><span class="n">api_key</span> <span class="o">=</span> <span class="s">'&lt;YOUR_API_KEY&gt;'</span>
<span class="n">openai</span><span class="p">.</span><span class="n">api_base</span> <span class="o">=</span> <span class="s">'https://openai.pgpt.cloud/v1'</span>
<span class="n">generation_response</span> <span class="o">=</span> <span class="n">openai</span><span class="p">.</span><span class="n">Image</span><span class="p">.</span><span class="n">create</span><span class="p">(</span>
Expand All @@ -891,11 +892,7 @@ <h4 id='request-body-4'>Request body</h4>
<span class="n">model</span><span class="o">=</span><span class="s">'dall-e-3'</span>
<span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">generation_response</span><span class="p">)</span>
</code></pre></div>
<blockquote>
<p>Create image 请求示范 (openai &gt; 1.0)</p>
</blockquote>
<div class="highlight"><pre class="highlight python tab-python"><code><span class="c1"># openai &gt;= 1.0
</code></pre></div><div class="highlight"><pre class="highlight python tab-python"><code><span class="c1"># openai &gt;= 1.0
</span><span class="kn">from</span> <span class="nn">openai</span> <span class="kn">import</span> <span class="n">OpenAI</span>

<span class="n">api_key</span> <span class="o">=</span> <span class="s">'&lt;YOUR_API_KEY&gt;'</span>
Expand Down
5 changes: 2 additions & 3 deletions source/openai.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,10 @@ PGPT 支持 OpenAI DALL-E接口,这是OpenAI官方训练出的根据文本说

#### Request body

> Create image 请求示范 (openai < 1.0)
> Create image 请求示范
```python
# openai < 1.0
import openai
openai.api_key = '<YOUR_API_KEY>'
openai.api_base = 'https://openai.pgpt.cloud/v1'
Expand All @@ -568,8 +569,6 @@ generation_response = openai.Image.create(
print(generation_response)
```

> Create image 请求示范 (openai > 1.0)
```python
# openai >= 1.0
from openai import OpenAI
Expand Down

0 comments on commit de63f6d

Please sign in to comment.