172 lines
5.2 KiB
HTML
172 lines
5.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Using Hermes AI - Free AI Service</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
line-height: 1.6;
|
|
margin: 20px;
|
|
padding: 20px;
|
|
background-color: #f4f4f4;
|
|
}
|
|
h1, h2, h3 {
|
|
color: #333;
|
|
}
|
|
code {
|
|
background-color: #e8e8e8;
|
|
padding: 5px;
|
|
border-radius: 5px;
|
|
}
|
|
pre {
|
|
background-color: #e8e8e8;
|
|
padding: 10px;
|
|
border-radius: 5px;
|
|
overflow-x: auto;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Welcome to ai.unturf.com</h1>
|
|
<p>At <strong>ai.unturf.com</strong>, we offer a free AI service powered by the model <strong>NousResearch/Hermes-3-Llama-3.1-8B</strong>. 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.</p>
|
|
|
|
<h2>Using the Hermes AI Model</h2>
|
|
<p>This guide explains how to use the official OpenAI client to interact with the Hermes AI model hosted at <a href="https://hermes.ai.unturf.com/v1">hermes.ai.unturf.com/v1</a>. You can use this endpoint without an API key.</p>
|
|
|
|
<h3>Installing the OpenAI Client</h3>
|
|
<h4>Python</h4>
|
|
<p>To install the OpenAI package for Python, use <code>pip</code>:</p>
|
|
<pre><code>pip install openai</code></pre>
|
|
|
|
<h4>Node.js</h4>
|
|
<p>To install the OpenAI package for Node.js, you can use <code>npm</code> in your <code>package.json</code>:</p>
|
|
<pre><code>{
|
|
"dependencies": {
|
|
"openai": "^3.1.0" // Use the latest version
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>Run the following command to install it:</p>
|
|
<pre><code>npm install</code></pre>
|
|
|
|
<h2>Python Example</h2>
|
|
<h3>Non-Streaming</h3>
|
|
<pre><code>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": "Give a Python Fizzbuzz solution in one line of code?"}]
|
|
|
|
# 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)
|
|
</code></pre>
|
|
|
|
<h3>Streaming</h3>
|
|
<pre><code>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": "Give a Python Fizzbuzz solution in one line of code?"}]
|
|
|
|
# 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='')
|
|
</code></pre>
|
|
|
|
<h2>Node.js Example</h2>
|
|
<h3>Non-Streaming</h3>
|
|
<pre><code>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();
|
|
</code></pre>
|
|
|
|
<h3>Streaming</h3>
|
|
<pre><code>
|
|
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();
|
|
</code></pre>
|
|
|
|
<p>Feel free to modify the <code>messages</code> array to ask different questions or adjust the <code>temperature</code> and <code>max_tokens</code> parameters according to your needs. Happy querying!</p>
|
|
</body>
|
|
</html>
|