Quardo commited on
Commit
e3738fa
1 Parent(s): 5974345

Updated Space.

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. index.html +43 -15
app.py CHANGED
@@ -559,7 +559,7 @@ async def respond(
559
 
560
 
561
  handleApiKeys();loadModels();checkModels();loadENV();
562
- lastUpdateMessage = "Better TOS handle."
563
  demo = gr.ChatInterface(
564
  respond,
565
  title="GPT-4O-mini",
 
559
 
560
 
561
  handleApiKeys();loadModels();checkModels();loadENV();
562
+ lastUpdateMessage = "Better search faketool."
563
  demo = gr.ChatInterface(
564
  respond,
565
  title="GPT-4O-mini",
index.html CHANGED
@@ -28,7 +28,7 @@
28
  </style>
29
  <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.min.js"></script>
30
  <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/mode/python/python.min.js"></script>
31
- <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/mode/shell/shell.min.js"></script>
32
  </head>
33
  <body>
34
  <div class="main">
@@ -38,6 +38,18 @@
38
  <h2>Updates</h2>
39
  <button onclick="if (updates.style.display === 'none') { updates.style.display = 'block'; } else { updates.style.display = 'none'; }">Show/Hide updates</button>
40
  <div style="display: none;" id="updates">
 
 
 
 
 
 
 
 
 
 
 
 
41
  <div>
42
  <strong> - 11. Update.</strong>
43
  <p> * Finally found out a better way for TOS acception.</p>
@@ -119,13 +131,13 @@ from openai import OpenAI
119
 
120
  client = OpenAI(
121
  # Or use the `OPENAI_BASE_URL` env var
122
- base_url="https://chat.cow.rip/api/v1",
123
-
124
- # No key is needed cause this is a proxy
125
- api_key="none"
126
  )
127
 
128
- completion = client.chat.completions.create( # or openai.ChatCompletion.create (idk)
129
  model="gpt-4o-mini",
130
  messages=[
131
  {
@@ -140,10 +152,10 @@ print(completion.choices[0].message.content)</textarea>
140
  <textarea id="example2" name="example2"># Example 2: Using OpenAI Python client with different syntax
141
  import openai
142
 
143
- openai.api_key = 'none'
144
- openai.base_url = "https://chat.cow.rip/api/v1"
145
 
146
- completion = openai.chat.completions.create( # or openai.ChatCompletion.create (idk)
147
  model="gpt-4o-mini",
148
  messages=[
149
  {
@@ -155,22 +167,38 @@ completion = openai.chat.completions.create( # or openai.ChatCompletion.create (
155
 
156
  print(completion.choices[0].message.content)</textarea>
157
  <hr/>
158
- <textarea id="example3" name="example3"># For Node.js:
159
- # I am too lazy to look into openai's docs
160
- # so please kindly take a look at github there is probably examples there.</textarea>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  <hr/>
162
  <div>
163
  <h3>Actual endpoints:</h3>
164
- <p><strong>1. [GET]</strong> <a href="https://chat.cow.rip/api/v1/models">/api/v1/models</a></p>
165
  <label>Simply shows you the available models</label>
166
- <p><strong>3. [POST]</strong> <a href="https://chat.cow.rip/api/v1/chat/completions">/api/v1/chat/completions</a></p>
167
  <label>Generates a chat completion based on the provided messages and model</label>
168
  </div>
169
  </div>
170
  <script>
171
  CodeMirror.fromTextArea(document.getElementById("example1"), { lineNumbers: true, mode: "python", theme: "monokai", readOnly: true });
172
  CodeMirror.fromTextArea(document.getElementById("example2"), { lineNumbers: true, mode: "python", theme: "monokai", readOnly: true });
173
- CodeMirror.fromTextArea(document.getElementById("example3"), { lineNumbers: true, mode: "shell", theme: "monokai", readOnly: true });
174
  </script>
175
  </body>
176
  </html>
 
28
  </style>
29
  <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/codemirror.min.js"></script>
30
  <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/mode/python/python.min.js"></script>
31
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.5/mode/javascript/javascript.min.js"></script>
32
  </head>
33
  <body>
34
  <div class="main">
 
38
  <h2>Updates</h2>
39
  <button onclick="if (updates.style.display === 'none') { updates.style.display = 'block'; } else { updates.style.display = 'none'; }">Show/Hide updates</button>
40
  <div style="display: none;" id="updates">
41
+ <div>
42
+ <strong> - 13. Update.</strong>
43
+ <p> * New API endpoint.</p>
44
+ <p> - To get an API key you can login at <a href="https://api.cow.rip/api/v1/oauth/hf">Here!</a></p>
45
+ <p> - Note: any key found on anywhere on the internet will get force-reset</p>
46
+ </div><hr/>
47
+ <div>
48
+ <strong> - 12. Update.</strong>
49
+ <p> * Updated faketool [search].</p>
50
+ <p> - on performance (30s => 22~s) by switching search API.</p>
51
+ <p> - on knowledge (better scraping).</p>
52
+ </div><hr/>
53
  <div>
54
  <strong> - 11. Update.</strong>
55
  <p> * Finally found out a better way for TOS acception.</p>
 
131
 
132
  client = OpenAI(
133
  # Or use the `OPENAI_BASE_URL` env var
134
+ base_url="https://api.cow.rip/api/v1",
135
+
136
+ # You can get a key by logging in at https://api.cow.rip/api/v1/oauth/hf
137
+ api_key="..."
138
  )
139
 
140
+ completion = client.ChatCompletion.acreate(
141
  model="gpt-4o-mini",
142
  messages=[
143
  {
 
152
  <textarea id="example2" name="example2"># Example 2: Using OpenAI Python client with different syntax
153
  import openai
154
 
155
+ openai.api_key = '...' # You can get a key by logging in at https://api.cow.rip/api/v1/oauth/hf
156
+ openai.base_url = "https://chat.cow.rip/api/v1" # Or use the `OPENAI_BASE_URL` env var
157
 
158
+ completion = openai.ChatCompletion.acreate(
159
  model="gpt-4o-mini",
160
  messages=[
161
  {
 
167
 
168
  print(completion.choices[0].message.content)</textarea>
169
  <hr/>
170
+ <textarea id="example3" name="example3">// For Node.js:
171
+ const openai = new (require('openai')).OpenAI({
172
+ baseURL: "https://api.cow.rip/api/v1", // Or use the `OPENAI_BASE_URL` env var
173
+ apiKey: "..." // You can get a key by logging in at https://api.cow.rip/api/v1/oauth/hf
174
+ });
175
+ (async()=>{
176
+ var completion = await openai.chat.completions.create({
177
+ model: "gpt-4o-mini",
178
+ messages=[
179
+ {
180
+ "role": "user",
181
+ "content": "Say this is a test",
182
+ }
183
+ ]
184
+ });
185
+
186
+ console.log(completion.choices[0].message.content)
187
+ })()
188
+ </textarea>
189
  <hr/>
190
  <div>
191
  <h3>Actual endpoints:</h3>
192
+ <p><strong>1. [GET]</strong> <a href="https://api.cow.rip/api/v1/models">/api/v1/models</a></p>
193
  <label>Simply shows you the available models</label>
194
+ <p><strong>3. [POST]</strong> <a href="https://api.cow.rip/api/v1/chat/completions">/api/v1/chat/completions</a></p>
195
  <label>Generates a chat completion based on the provided messages and model</label>
196
  </div>
197
  </div>
198
  <script>
199
  CodeMirror.fromTextArea(document.getElementById("example1"), { lineNumbers: true, mode: "python", theme: "monokai", readOnly: true });
200
  CodeMirror.fromTextArea(document.getElementById("example2"), { lineNumbers: true, mode: "python", theme: "monokai", readOnly: true });
201
+ CodeMirror.fromTextArea(document.getElementById("example3"), { lineNumbers: true, mode: "javascript", theme: "monokai", readOnly: true });
202
  </script>
203
  </body>
204
  </html>