From 97ab88d31232ecc95e6bf721212e77e593109f6a Mon Sep 17 00:00:00 2001 From: root Date: Mon, 14 Oct 2024 19:41:51 +0000 Subject: [PATCH] new file: index.html --- index.html | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..7999031 --- /dev/null +++ b/index.html @@ -0,0 +1,172 @@ + + + + + + Using Hermes AI - Free AI Service + + + +

Welcome to ai.unturf.com

+

At ai.unturf.com, we offer a free AI service powered by the model NousResearch/Hermes-3-Llama-3.1-8B. Our mission is to provide accessible AI tools for everyone, embodying the principles of free beer and free freedom. You can interact with our model without any cost, and you are encouraged to contribute and build upon our open-source framework.

+ +

Using the Hermes AI Model

+

This guide explains how to use the official OpenAI client to interact with the Hermes AI model hosted at hermes.ai.unturf.com/v1. You can use this endpoint without an API key.

+ +

Installing the OpenAI Client

+

Python

+

To install the OpenAI package for Python, use pip:

+
pip install openai
+ +

Node.js

+

To install the OpenAI package for Node.js, you can use npm in your package.json:

+
{
+  "dependencies": {
+    "openai": "^3.1.0"  // Use the latest version
+  }
+}
+    
+

Run the following command to install it:

+
npm install
+ +

Python Example

+

Non-Streaming

+
from openai import OpenAI
+
+client = OpenAI(base_url="https://hermes.ai.unturf.com/v1", api_key="none")
+
+# Set your model
+MODEL = "NousResearch/Hermes-3-Llama-3.1-8B"
+
+# Define your messages
+messages = [{"role": "user", "content": "Hello, how can I use Hermes?"}]
+
+# Make the request
+response = client.chat.completions.create(
+    model=MODEL,
+    messages=messages,
+    temperature=0.5,
+    max_tokens=150
+)
+
+# Print the response
+print(response.choices[0].message.content)
+    
+ +

Streaming

+
from openai import OpenAI
+
+client = OpenAI(base_url="https://hermes.ai.unturf.com/v1", api_key="none")
+
+# Set your model
+MODEL = "NousResearch/Hermes-3-Llama-3.1-8B"
+
+# Define your messages
+messages = [{"role": "user", "content": "Hello, how can I use Hermes?"}]
+
+# Make the streaming request
+response = client.chat.completions.create(
+    model=MODEL,
+    messages=messages,
+    temperature=0.5,
+    max_tokens=150,
+    stream=True  # Enable streaming
+)
+
+# Print each message in the streaming response
+for msg in response:
+    print(msg['choices'][0]['delta']['content'], end='')
+    
+ +

Node.js Example

+

Non-Streaming

+
const OpenAI = require('openai');
+
+const client = new OpenAI({
+    baseURL: "https://hermes.ai.unturf.com/v1",
+    apiKey: "dummy-api-key",
+});
+
+const MODEL = "NousResearch/Hermes-3-Llama-3.1-8B";
+
+const messages = [{"role": "user", "content": "Give a Python Fizzbuzz solution in one line of code?"}];
+
+async function getResponse() {
+    try {
+        const response = await client.chat.completions.create({
+            model: MODEL,
+            messages: messages,
+            temperature: 0.5,
+            max_tokens: 150,
+        });
+
+        console.log(response.choices[0].message.content);
+    } catch (error) {
+        console.error("Error:", error.response ? error.response.data : error.message);
+    }
+}
+
+getResponse();
+    
+ +

Streaming

+

+const OpenAI = require('openai');
+
+const client = new OpenAI({
+    baseURL: "https://hermes.ai.unturf.com/v1",
+    apiKey: "dummy-api-key",
+});
+
+const MODEL = "NousResearch/Hermes-3-Llama-3.1-8B";
+
+const messages = [{"role": "user", "content": "Give a Python Fizzbuzz solution in one line of code?"}];
+
+async function streamResponse() {
+    try {
+        const stream = await client.chat.completions.create({
+            model: MODEL,
+            messages: messages,
+            temperature: 0.5,
+            max_tokens: 150,
+            stream: true,  // Enable streaming
+        });
+
+        // Use async iterator to read each chunk
+        for await (const chunk of stream) {
+            const msg = chunk.choices[0].delta.content;
+            process.stdout.write(msg);  // Print each chunk as it arrives
+        }
+    } catch (error) {
+        console.error("Error:", error.response ? error.response.data : error.message);
+    }
+}
+
+streamResponse();
+    
+ +

Feel free to modify the messages array to ask different questions or adjust the temperature and max_tokens parameters according to your needs. Happy querying!

+ +