globalsprak
Advanced tools
Comparing version 1.0.3 to 1.0.4
76
index.js
@@ -433,23 +433,2 @@ const axios = require('axios'); | ||
// PixArt v2 Function | ||
async function pixartv2(prompt, prompt_negative, image_style, width, height, lcm_inference_steps) { | ||
try { | ||
const response = await axios.get(`${API}/v2/pixart?prompt=${encodeURIComponent(prompt)}&prompt_negative=${encodeURIComponent(prompt_negative)}&image_style=${encodeURIComponent(image_style)}&width=${encodeURIComponent(width)}&height=${encodeURIComponent(height)}&lcm_inference_steps=${encodeURIComponent(lcm_inference_steps)}`); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Error fetching PixArt v2 response:', error); | ||
return null; | ||
} | ||
} | ||
// PixArt Function | ||
async function pixart(prompt, prompt_negative, image_style, width, height, sampler, dpm_guidance_scale, dpm_inference_steps, sa_guidance_scale, sa_inference_steps) { | ||
try { | ||
const response = await axios.get(`${API}/v1/pixart?prompt=${encodeURIComponent(prompt)}&prompt_negative=${encodeURIComponent(prompt_negative)}&image_style=${encodeURIComponent(image_style)}&width=${encodeURIComponent(width)}&height=${encodeURIComponent(height)}&sampler=${encodeURIComponent(sampler)}&dpm_guidance_scale=${encodeURIComponent(dpm_guidance_scale)}&dpm_inference_steps=${encodeURIComponent(dpm_inference_steps)}&sa_guidance_scale=${encodeURIComponent(sa_guidance_scale)}&sa_inference_steps=${encodeURIComponent(sa_inference_steps)}`); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Error fetching PixArt response:', error); | ||
return null; | ||
} | ||
} | ||
async function translate(text, lang) { | ||
@@ -524,3 +503,51 @@ try { | ||
} | ||
async function animagen(prompt, count) { | ||
try { | ||
const response = await axios.get(`${API}/v1/animagen?prompt=${encodeURIComponent(prompt)}&count=${count}`); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
return null; | ||
} | ||
} | ||
async function pixelart(prompt, count) { // Changed the function name from "pixel-art" to "pixelArt" | ||
try { | ||
const response = await axios.get(`${API}/v1/pixel-art?prompt=${encodeURIComponent(prompt)}&count=${count}`); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
return null; | ||
} | ||
} | ||
async function xi(prompt, count) { | ||
try { | ||
const response = await axios.get(`${API}/v1/xi?prompt=${encodeURIComponent(prompt)}&count=${count}`); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
return null; | ||
} | ||
} | ||
async function gen(prompt, count) { | ||
try { | ||
const response = await axios.get(`${API}/v1/gen?prompt=${encodeURIComponent(prompt)}&count=${count}`); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
return null; | ||
} | ||
} | ||
async function gen2(prompt, count) { | ||
try { | ||
const response = await axios.get(`${API}/v1/generate?prompt=${encodeURIComponent(prompt)}&count=${count}`); | ||
return response.data; | ||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
return null; | ||
} | ||
} | ||
// Exporting All Functions | ||
@@ -568,4 +595,4 @@ module.exports = { | ||
generate, | ||
pixart, | ||
pixartv2, | ||
gen, | ||
gen2, | ||
translate, | ||
@@ -577,2 +604,5 @@ lyrics, | ||
weather, | ||
xi, | ||
animagen, | ||
pixelart, | ||
}; |
{ | ||
"name": "globalsprak", | ||
"version": "1.0.3", | ||
"description": "", | ||
"version": "1.0.4", | ||
"description": "globalsprak is a Node.js package that provides access to various AI models, image generation, content downloading from various platforms, and more.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node index.js" | ||
"start": "node index.js" | ||
}, | ||
@@ -32,8 +32,14 @@ "keywords": [ | ||
"dalle", | ||
"xl", | ||
"xl3", | ||
"GlobalSprak" | ||
"animagen", | ||
"image2art", | ||
"upscale", | ||
"pinterest", | ||
"generate", | ||
"openai", | ||
"prodia", | ||
"flux" | ||
], | ||
"author": "Aryan Chauhan", | ||
"license": "ISC", | ||
"license": "MIT", | ||
"dependencies": { | ||
@@ -40,0 +46,0 @@ "@types/node": "^18.0.6", |
438
readme.md
@@ -83,4 +83,201 @@ # GLOBALSPRAK | ||
main(); | ||
main(); | ||
``` | ||
### GPTWeb | ||
- **Function**: `gptweb(prompt)` | ||
- **Description**: Retrieves a web-enhanced response from the GPT model based on the provided prompt. | ||
- **Example**: | ||
```javascript | ||
const { gptweb } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Latest tech trends in 2024"; | ||
const response = await gptweb(prompt); | ||
console.log("GPTWeb Response:", response); | ||
} | ||
main(); | ||
``` | ||
### Llama | ||
Get a response from the Llama AI model. | ||
```javascript | ||
const { llama } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Tell me a joke"; | ||
const response = await llama(prompt); | ||
console.log("Llama Response:", response); | ||
} | ||
main(); | ||
``` | ||
### Mixtral | ||
Get a response from the Mixtral AI model. | ||
```javascript | ||
const { mixtral } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Explain quantum mechanics"; | ||
const response = await mixtral(prompt); | ||
console.log("Mixtral Response:", response); | ||
} | ||
main(); | ||
``` | ||
### Coral | ||
Interact with Coral or reset conversation context. | ||
#### Regular Chat with Coral | ||
```javascript | ||
const { coral } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "How's the weather today?"; | ||
const response = await coral(prompt); | ||
console.log("Coral Response:", response); | ||
} | ||
main(); | ||
``` | ||
#### Chat with Coral using User ID | ||
```javascript | ||
const { coralchat } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Tell me a story"; | ||
const uid = "user123"; | ||
const response = await coralchat(prompt, uid); | ||
console.log("Coral Chat Response:", response); | ||
} | ||
main(); | ||
``` | ||
#### Reset Coral Conversation | ||
```javascript | ||
const { coralreset } = require('globalsprak'); | ||
async function main() { | ||
const uid = "user123"; | ||
const response = await coralreset(uid); | ||
console.log("Coral Reset Response:", response); | ||
} | ||
main(); | ||
``` | ||
### Animagen | ||
- **Function**: `animagen(prompt, count)` | ||
- **Description**: Generates anime-style art based on the provided prompt. | ||
- **Parameters**: | ||
- `prompt` (string): The prompt to generate anime-style art. | ||
- `count` (number): The number of images to generate. | ||
- **Example**: | ||
```javascript | ||
const { animagen } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Create anime-style art"; | ||
const count = 3; | ||
const response = await animagen(prompt, count); | ||
console.log("Animagen Response:", response); | ||
} | ||
main(); | ||
``` | ||
### PixelArt | ||
- **Function**: `pixelart(prompt, count)` | ||
- **Description**: Generates pixel art based on the provided prompt. | ||
- **Parameters**: | ||
- `prompt` (string): The prompt to generate pixel art. | ||
- `count` (number): The number of images to generate. | ||
- **Example**: | ||
```javascript | ||
const { pixelart } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Create a pixel art character"; | ||
const count = 2; | ||
const response = await pixelArt(prompt, count); | ||
console.log("PixelArt Response:", response); | ||
} | ||
main(); | ||
``` | ||
### Xi | ||
- **Function**: `xi(prompt, count)` | ||
- **Description**: Generates art based on the Xi engine using the provided prompt. | ||
- **Parameters**: | ||
- `prompt` (string): The prompt to generate art with the Xi engine. | ||
- `count` (number): The number of images to generate. | ||
- **Example**: | ||
```javascript | ||
const { xi } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Create surreal landscape art"; | ||
const count = 1; | ||
const response = await xi(prompt, count); | ||
console.log("Xi Response:", response); | ||
} | ||
main(); | ||
``` | ||
### Gen | ||
- **Function**: `gen(prompt, count)` | ||
- **Description**: Generates art based on a generic engine using the provided prompt. | ||
- **Parameters**: | ||
- `prompt` (string): The prompt to generate generic art. | ||
- `count` (number): The number of images to generate. | ||
- **Example**: | ||
```javascript | ||
const { gen } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Generate futuristic city art"; | ||
const count = 4; | ||
const response = await gen(prompt, count); | ||
console.log("Gen Response:", response); | ||
} | ||
main(); | ||
``` | ||
### Gen2 | ||
- **Function**: `gen2(prompt, count)` | ||
- **Description**: Generates art using the Gen2 engine based on the provided prompt. | ||
- **Parameters**: | ||
- `prompt` (string): The prompt to generate Gen2 art. | ||
- `count` (number): The number of images to generate. | ||
- **Example**: | ||
```javascript | ||
const { gen2 } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Create abstract artwork"; | ||
const count = 5; | ||
const response = await gen2(prompt, count); | ||
console.log("Gen2 Response:", response); | ||
} | ||
main(); | ||
``` | ||
### XL3 | ||
@@ -95,3 +292,3 @@ | ||
async function main() { | ||
const prompt = "Your XL3 prompt"; | ||
const prompt = "Prompts"; | ||
const response = await xl3(prompt); | ||
@@ -104,4 +301,2 @@ console.log("XL3 Response:", response); | ||
--- | ||
### Flux | ||
@@ -124,4 +319,2 @@ | ||
--- | ||
### Mini DALL-E | ||
@@ -144,4 +337,2 @@ | ||
--- | ||
### DALL-E v2 | ||
@@ -163,5 +354,2 @@ | ||
``` | ||
--- | ||
### DALL-E v3 | ||
@@ -188,4 +376,2 @@ | ||
--- | ||
### XL | ||
@@ -211,4 +397,2 @@ | ||
--- | ||
### Generate | ||
@@ -230,100 +414,2 @@ | ||
``` | ||
--- | ||
### PixArt v2 | ||
- **Function**: `pixartv2(prompt, prompt_negative, image_style, width, height, lcm_inference_steps)` | ||
- **Description**: Fetches a response from PixArt v2 API using the provided parameters for detailed image control. | ||
- **Example**: | ||
```javascript | ||
const { pixartv2 } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Your PixArt v2 prompt"; | ||
const prompt_negative = "Negative prompt"; | ||
const image_style = "photorealistic"; | ||
const width = 512; | ||
const height = 512; | ||
const lcm_inference_steps = 50; | ||
const response = await pixartv2(prompt, prompt_negative, image_style, width, height, lcm_inference_steps); | ||
console.log("PixArt v2 Response:", response); | ||
} | ||
main(); | ||
``` | ||
## Image Styles | ||
Choose from the following available image types: | ||
- **(No style)** | ||
- **Cinematic** | ||
- **Photographic** | ||
- **Anime** | ||
- **Manga** | ||
- **Digital Art** | ||
- **Pixel Art** | ||
- **Fantasy Art** | ||
- **Neonpunk** | ||
- **3D Model** | ||
### PixArt | ||
- **Function**: `pixart(prompt, prompt_negative, image_style, width, height, sampler, dpm_guidance_scale, dpm_inference_steps, sa_guidance_scale, sa_inference_steps)` | ||
- **Description**: Fetches a response from the PixArt API with extended parameters for precise image generation. | ||
- **Example**: | ||
```javascript | ||
const { pixart } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Your PixArt prompt"; | ||
const prompt_negative = "Negative prompt"; | ||
const image_style = "artistic"; | ||
const width = 512; | ||
const height = 512; | ||
const sampler = "euler_a"; | ||
const dpm_guidance_scale = 7.5; | ||
const dpm_inference_steps = 50; | ||
const sa_guidance_scale = 5.0; | ||
const sa_inference_steps = 25; | ||
const response = await pixart(prompt, prompt_negative, image_style, width, height, sampler, dpm_guidance_scale, dpm_inference_steps, sa_guidance_scale, sa_inference_steps); | ||
console.log("PixArt Response:", response); | ||
} | ||
main(); | ||
``` | ||
## Image Styles | ||
Choose from the following available image types: | ||
- **(No style)** | ||
- **Cinematic** | ||
- **Photographic** | ||
- **Anime** | ||
- **Manga** | ||
- **Digital Art** | ||
- **Pixel Art** | ||
- **Fantasy Art** | ||
- **Neonpunk** | ||
- **3D Model** | ||
### GPTWeb | ||
- **Function**: `gptweb(prompt)` | ||
- **Description**: Retrieves a web-enhanced response from the GPT model based on the provided prompt. | ||
- **Example**: | ||
```javascript | ||
const { gptweb } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Latest tech trends in 2024"; | ||
const response = await gptweb(prompt); | ||
console.log("GPTWeb Response:", response); | ||
} | ||
main(); | ||
``` | ||
### EMI | ||
@@ -448,82 +534,2 @@ | ||
### Llama | ||
Get a response from the Llama AI model. | ||
```javascript | ||
const { llama } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Tell me a joke"; | ||
const response = await llama(prompt); | ||
console.log("Llama Response:", response); | ||
} | ||
main(); | ||
``` | ||
### Mixtral | ||
Get a response from the Mixtral AI model. | ||
```javascript | ||
const { mixtral } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Explain quantum mechanics"; | ||
const response = await mixtral(prompt); | ||
console.log("Mixtral Response:", response); | ||
} | ||
main(); | ||
``` | ||
### Coral | ||
Interact with Coral or reset conversation context. | ||
#### Regular Chat with Coral | ||
```javascript | ||
const { coral } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "How's the weather today?"; | ||
const response = await coral(prompt); | ||
console.log("Coral Response:", response); | ||
} | ||
main(); | ||
``` | ||
#### Chat with Coral using User ID | ||
```javascript | ||
const { coralchat } = require('globalsprak'); | ||
async function main() { | ||
const prompt = "Tell me a story"; | ||
const uid = "user123"; | ||
const response = await coralchat(prompt, uid); | ||
console.log("Coral Chat Response:", response); | ||
} | ||
main(); | ||
``` | ||
#### Reset Coral Conversation | ||
```javascript | ||
const { coralreset } = require('globalsprak'); | ||
async function main() { | ||
const uid = "user123"; | ||
const response = await coralreset(uid); | ||
console.log("Coral Reset Response:", response); | ||
} | ||
main(); | ||
``` | ||
### Download Tools | ||
@@ -840,26 +846,2 @@ | ||
## Error Handling | ||
Each function has built-in error handling. If an error occurs during the API request, an error message will be logged, and `null` will be returned as the response. Example: | ||
```javascript | ||
const { gpt } = require('globalsprak'); | ||
async function main() { | ||
try { | ||
const response = await gpt("Explain AI"); | ||
if (response) { | ||
console.log("GPT Response:", response); | ||
} else { | ||
console.error("Failed to fetch GPT response."); | ||
} | ||
} catch (error) { | ||
console.error("An error occurred:", error); | ||
} | ||
} | ||
main(); | ||
``` | ||
### Translate | ||
@@ -1075,3 +1057,25 @@ | ||
``` | ||
## Error Handling | ||
Each function has built-in error handling. If an error occurs during the API request, an error message will be logged, and `null` will be returned as the response. Example: | ||
```javascript | ||
const { gpt } = require('globalsprak'); | ||
async function main() { | ||
try { | ||
const response = await gpt("Explain AI"); | ||
if (response) { | ||
console.log("GPT Response:", response); | ||
} else { | ||
console.error("Failed to fetch GPT response."); | ||
} | ||
} catch (error) { | ||
console.error("An error occurred:", error); | ||
} | ||
} | ||
main(); | ||
``` | ||
## API Reference | ||
@@ -1078,0 +1082,0 @@ |
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
48657
0
554
1106