mirror of
https://github.com/ParisNeo/lollms-webui.git
synced 2024-12-28 08:08:50 +00:00
1.0 KiB
1.0 KiB
Lollms Text to Image Library
-
Include the library:
<script src="/lollms_assets/js/lollms_tti"></script>
-
Initialize in your JavaScript:
const ttiClient = new LollmsTTI();// You can also add a parameter BaseUrl which is by default "http://localhost:9600"
-
Generate and display an image:
const container = document.getElementById('image-container'); await ttiClient.generateAndDisplayImage('prompt', 'negative prompt', 512, 512, container); // The container must be a div
-
Or generate image separately:
ttiClient.generateImage('prompt', 'negative prompt', 512, 512)// prompt, negative prompt, width, height .then(base64Image => { // Use base64Image });
-
To change the server base url, we can use:
ttiClient.setBaseUrl("http://localhost:9600"); // Change to the right server address
This library simplifies image generation requests to the LoLLMs backend, handling the API call and image display.