Spaces:
Running
Running
Update index.html
Browse files- index.html +47 -4
index.html
CHANGED
@@ -340,18 +340,61 @@ header:hover .scroll-indicator .arrow {
|
|
340 |
<section class="section">
|
341 |
<h2>Request Format</h2>
|
342 |
<pre><code class="language-json">{
|
343 |
-
"model": "
|
344 |
"messages": [
|
345 |
{
|
346 |
"role": "user",
|
347 |
"content": "Hello, AI!"
|
348 |
}
|
349 |
],
|
350 |
-
"stream":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
}</code></pre>
|
352 |
</section>
|
353 |
-
|
354 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
<section class="section">
|
356 |
<h2>Available Models</h2>
|
357 |
<p>More info at <span style="text-decoration: underline; cursor: pointer;" onclick="window.location.href='https://parthsadaria-lokiai.hf.space/models'">https://parthsadaria-lokiai.hf.space/models</span></p>
|
|
|
340 |
<section class="section">
|
341 |
<h2>Request Format</h2>
|
342 |
<pre><code class="language-json">{
|
343 |
+
"model": "gpt-4o",
|
344 |
"messages": [
|
345 |
{
|
346 |
"role": "user",
|
347 |
"content": "Hello, AI!"
|
348 |
}
|
349 |
],
|
350 |
+
"stream": False #specify it
|
351 |
+
}</code></pre>
|
352 |
+
<h3>Response Format</h3>
|
353 |
+
<pre><code class="language-json">{{
|
354 |
+
"id": "chatcmpl-89DmxGJl4oqEultjlLBnGfdkV7Euk",
|
355 |
+
"model": "gpt-4o",
|
356 |
+
"object": "chat.completion",
|
357 |
+
"created": 1731674826,
|
358 |
+
"choices": [
|
359 |
+
{
|
360 |
+
"index": 0,
|
361 |
+
"message": {
|
362 |
+
"role": "assistant",
|
363 |
+
"content": "Hello! How can I assist you today?"
|
364 |
+
},
|
365 |
+
"finish_reason": "stop"
|
366 |
+
}
|
367 |
+
],
|
368 |
+
"usage": {
|
369 |
+
"prompt_tokens": 11,
|
370 |
+
"completion_tokens": 9,
|
371 |
+
"total_tokens": 20
|
372 |
+
}
|
373 |
+
}
|
374 |
}</code></pre>
|
375 |
</section>
|
376 |
+
<section class="section">
|
377 |
+
<h2>Example Usage</h2>
|
378 |
+
<pre><code class="language-python">
|
379 |
+
import openai
|
380 |
+
# hampe to he hi no :p (not needed)
|
381 |
+
api_key = ''
|
382 |
+
# Use the custom API endpoint
|
383 |
+
openai.api_base = "https://parthsadaria-lokiai.hf.space"
|
384 |
+
openai.api_key = api_key
|
385 |
+
def chat_with_gpt():
|
386 |
+
try:
|
387 |
+
response = openai.ChatCompletion.create(
|
388 |
+
model="gpt-4o",
|
389 |
+
messages=[{"role": "user", "content": "hi homie"}],
|
390 |
+
stream=False
|
391 |
+
)
|
392 |
+
print(response['choices'][0]['message']['content'])
|
393 |
+
except Exception as e:
|
394 |
+
print(f"Error: {e}")
|
395 |
+
chat_with_gpt()
|
396 |
+
</code></pre>
|
397 |
+
</section>
|
398 |
<section class="section">
|
399 |
<h2>Available Models</h2>
|
400 |
<p>More info at <span style="text-decoration: underline; cursor: pointer;" onclick="window.location.href='https://parthsadaria-lokiai.hf.space/models'">https://parthsadaria-lokiai.hf.space/models</span></p>
|