mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-14 10:59:41 +00:00
fixed colab (+1 squashed commits)
Squashed commits: [1d1c686f] updated colab and docs
This commit is contained in:
parent
0978134f65
commit
59c5448ac8
4 changed files with 222 additions and 56 deletions
11
colab.ipynb
11
colab.ipynb
|
@ -52,6 +52,9 @@
|
|||
"Layers = 99 #@param [99]{allow-input: true}\r\n",
|
||||
"ContextSize = 4096 #@param [4096] {allow-input: true}\r\n",
|
||||
"ForceRebuild = False #@param {type:\"boolean\"}\r\n",
|
||||
"LoadImageModel = True #@param {type:\"boolean\"}\r\n",
|
||||
"SDModel = \"https://huggingface.co/Yntec/Deliberate2/resolve/main/Deliberate_v2.safetensors\" #@param [\"https://huggingface.co/Yntec/Deliberate2/resolve/main/Deliberate_v2.safetensors\",\"https://huggingface.co/admruul/anything-v3.0/resolve/main/Anything-V3.0-pruned-fp16.safetensors\"]{allow-input: true}\r\n",
|
||||
"SDCommand = \"\"\r\n",
|
||||
"\r\n",
|
||||
"import os\r\n",
|
||||
"if not os.path.isfile(\"/opt/bin/nvidia-smi\"):\r\n",
|
||||
|
@ -64,6 +67,10 @@
|
|||
"kvers = kvers[0]\r\n",
|
||||
"if ForceRebuild:\r\n",
|
||||
" kvers = \"force_rebuild\"\r\n",
|
||||
"if SDModel and LoadImageModel:\r\n",
|
||||
" SDCommand = \"--sdconfig sdmodel.safetensors normal 4 noquant\"\r\n",
|
||||
"else:\r\n",
|
||||
" SDCommand = \"\"\r\n",
|
||||
"!echo Finding prebuilt binary for {kvers}\r\n",
|
||||
"!wget -O dlfile.tmp https://kcppcolab.concedo.workers.dev/?{kvers} && mv dlfile.tmp koboldcpp_cublas.so\r\n",
|
||||
"!test -f koboldcpp_cublas.so && echo Prebuilt Binary Exists || echo Prebuilt Binary Does Not Exist\r\n",
|
||||
|
@ -71,7 +78,9 @@
|
|||
"!cp koboldcpp_cublas.so koboldcpp_cublas.dat\r\n",
|
||||
"!apt install aria2 -y\r\n",
|
||||
"!aria2c -x 10 -o model.gguf --summary-interval=5 --download-result=default --allow-overwrite=true --file-allocation=none $Model\r\n",
|
||||
"!python koboldcpp.py model.gguf --usecublas 0 mmq --multiuser --gpulayers $Layers --contextsize $ContextSize --quiet --remotetunnel\r\n"
|
||||
"if SDCommand:\r\n",
|
||||
" !aria2c -x 10 -o sdmodel.safetensors --summary-interval=5 --download-result=default --allow-overwrite=true --file-allocation=none $SDModel\r\n",
|
||||
"!python koboldcpp.py model.gguf --usecublas 0 mmq --multiuser --gpulayers $Layers --contextsize $ContextSize --quiet --remotetunnel $SDCommand\r\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
218
kcpp_docs.embd
218
kcpp_docs.embd
|
@ -345,11 +345,11 @@
|
|||
"info": {
|
||||
"title": "KoboldCpp API",
|
||||
"description": "For swagger.json, <a href=\"?json=1\">click here</a>.",
|
||||
"version": "1.58"
|
||||
"version": "1.60"
|
||||
},
|
||||
"openapi": "3.0.3",
|
||||
"paths": {
|
||||
"/v1/config/max_context_length": {
|
||||
"/api/v1/config/max_context_length": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
|
@ -368,11 +368,11 @@
|
|||
},
|
||||
"summary": "Retrieve the current max context length setting value that horde sees",
|
||||
"tags": [
|
||||
"v1"
|
||||
"api/v1"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/config/max_length": {
|
||||
"/api/v1/config/max_length": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
|
@ -391,11 +391,11 @@
|
|||
},
|
||||
"summary": "Retrieve the current max length (amount to generate) setting value",
|
||||
"tags": [
|
||||
"v1"
|
||||
"api/v1"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/generate": {
|
||||
"/api/v1/generate": {
|
||||
"post": {
|
||||
"description": "Generates text given a prompt and generation settings.\n\nUnspecified values are set to defaults.",
|
||||
"requestBody": {
|
||||
|
@ -460,11 +460,11 @@
|
|||
},
|
||||
"summary": "Generate text with a specified prompt",
|
||||
"tags": [
|
||||
"v1"
|
||||
"api/v1"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/info/version": {
|
||||
"/api/v1/info/version": {
|
||||
"get": {
|
||||
"description": "Returns the matching *KoboldAI* (United) version of the API that you are currently using. This is not the same as the KoboldCpp API version - this is used to feature match against KoboldAI United.",
|
||||
"responses": {
|
||||
|
@ -484,11 +484,11 @@
|
|||
},
|
||||
"summary": "Current KoboldAI United API version",
|
||||
"tags": [
|
||||
"v1"
|
||||
"api/v1"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/model": {
|
||||
"/api/v1/model": {
|
||||
"get": {
|
||||
"description": "Gets the current model display name, set with hordeconfig.",
|
||||
"responses": {
|
||||
|
@ -508,11 +508,11 @@
|
|||
},
|
||||
"summary": "Retrieve the current model string from hordeconfig",
|
||||
"tags": [
|
||||
"v1"
|
||||
"api/v1"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/extra/true_max_context_length": {
|
||||
"/api/extra/true_max_context_length": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
|
@ -532,11 +532,11 @@
|
|||
"summary": "Retrieve the actual max context length setting value set from the launcher",
|
||||
"description": "Retrieve the actual max context length setting value set from the launcher",
|
||||
"tags": [
|
||||
"extra"
|
||||
"api/extra"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/extra/version": {
|
||||
"/api/extra/version": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
|
@ -557,11 +557,11 @@
|
|||
"description": "Retrieve the KoboldCpp backend version",
|
||||
"summary": "Retrieve the KoboldCpp backend version",
|
||||
"tags": [
|
||||
"extra"
|
||||
"api/extra"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/extra/preloadstory": {
|
||||
"/api/extra/preloadstory": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
|
@ -581,11 +581,11 @@
|
|||
"description": "Retrieves the KoboldCpp preloaded story, --preloadstory configures a prepared story json save file to be hosted on the server, which frontends (such as Kobold Lite) can access over the API.",
|
||||
"summary": "Retrieves the KoboldCpp preloaded story",
|
||||
"tags": [
|
||||
"extra"
|
||||
"api/extra"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/extra/perf": {
|
||||
"/api/extra/perf": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
|
@ -611,11 +611,11 @@
|
|||
"description": "Retrieve the KoboldCpp recent performance information",
|
||||
"summary": "Retrieve the KoboldCpp recent performance information",
|
||||
"tags": [
|
||||
"extra"
|
||||
"api/extra"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/extra/generate/stream": {
|
||||
"/api/extra/generate/stream": {
|
||||
"post": {
|
||||
"description": "Generates text given a prompt and generation settings, with SSE streaming.\n\nUnspecified values are set to defaults.\n\nSSE streaming establishes a persistent connection, returning ongoing process in the form of message events.\n\n``` \nevent: message\ndata: {data}\n\n```",
|
||||
"requestBody": {
|
||||
|
@ -670,11 +670,11 @@
|
|||
},
|
||||
"summary": "Generate text with a specified prompt. SSE streamed results.",
|
||||
"tags": [
|
||||
"extra"
|
||||
"api/extra"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/extra/generate/check": {
|
||||
"/api/extra/generate/check": {
|
||||
"get": {
|
||||
"responses": {
|
||||
"200": {
|
||||
|
@ -698,7 +698,7 @@
|
|||
"summary": "Poll the incomplete results of the currently ongoing text generation.",
|
||||
"description": "Poll the incomplete results of the currently ongoing text generation. Will not work when multiple requests are in queue.",
|
||||
"tags": [
|
||||
"extra"
|
||||
"api/extra"
|
||||
]
|
||||
},
|
||||
"post": {
|
||||
|
@ -743,11 +743,11 @@
|
|||
},
|
||||
"summary": "Poll the incomplete results of the currently ongoing text generation. Supports multiuser mode.",
|
||||
"tags": [
|
||||
"extra"
|
||||
"api/extra"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/extra/tokencount": {
|
||||
"/api/extra/tokencount": {
|
||||
"post": {
|
||||
"description": "Counts the number of tokens in a string.",
|
||||
"requestBody": {
|
||||
|
@ -797,11 +797,11 @@
|
|||
},
|
||||
"summary": "Counts the number of tokens in a string.",
|
||||
"tags": [
|
||||
"extra"
|
||||
"api/extra"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/extra/abort": {
|
||||
"/api/extra/abort": {
|
||||
"post": {
|
||||
"description": "Aborts the currently ongoing text generation. Does not work when multiple requests are in queue.",
|
||||
"requestBody": {
|
||||
|
@ -845,24 +845,180 @@
|
|||
},
|
||||
"summary": "Aborts the currently ongoing text generation.",
|
||||
"tags": [
|
||||
"extra"
|
||||
"api/extra"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/sdapi/v1/sd-models": {
|
||||
"get": {
|
||||
"description": "Gets a list of image generation models. For koboldcpp, only one model will be returned. If no model is loaded, the list is empty.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": [{
|
||||
"title":"stable_diffusion",
|
||||
"model_name":"stable_diffusion",
|
||||
"hash":"8888888888",
|
||||
"sha256":"8888888888888888888888888888888888888888888888888888888888888888",
|
||||
"filename":"path_to_safetensors_model_file",
|
||||
"config": null
|
||||
}]
|
||||
}
|
||||
},
|
||||
"description": "Successful request"
|
||||
}
|
||||
},
|
||||
"summary": "Gets a list of image generation models",
|
||||
"tags": [
|
||||
"sdapi/v1"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/sdapi/v1/options": {
|
||||
"get": {
|
||||
"description": "Gets configuration info for image generation, used to get loaded model name in A1111.",
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {"samples_format":"png","sd_model_checkpoint":"stable_diffusion"}
|
||||
}
|
||||
},
|
||||
"description": "Successful request"
|
||||
}
|
||||
},
|
||||
"summary": "Gets configuration info for image generation",
|
||||
"tags": [
|
||||
"sdapi/v1"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/sdapi/v1/txt2img": {
|
||||
"post": {
|
||||
"description": "Generates an image from a text prompt, and returns a base64 encoded png.",
|
||||
"requestBody": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example": {
|
||||
"prompt": "picture of a kobold, high quality HD render",
|
||||
"negative_prompt": "ugly, deformed, censored",
|
||||
"cfg_scale": 5,
|
||||
"steps": 20,
|
||||
"seed": -1,
|
||||
"sampler_name": "Euler a"
|
||||
},
|
||||
"schema": {
|
||||
"properties": {
|
||||
"prompt": {
|
||||
"type": "string"
|
||||
},
|
||||
"negative_prompt": {
|
||||
"type": "string"
|
||||
},
|
||||
"cfg_scale": {
|
||||
"type": "number"
|
||||
},
|
||||
"steps": {
|
||||
"type": "number"
|
||||
},
|
||||
"seed": {
|
||||
"type": "number"
|
||||
},
|
||||
"sampler_name": {
|
||||
"type": "string"
|
||||
},
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": false
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"example":
|
||||
{
|
||||
"images":["base64_image_data"],"parameters":{},"info":""
|
||||
},
|
||||
"schema": {
|
||||
"properties": {
|
||||
"images": {
|
||||
"type": "string",
|
||||
"description": "A base64 string containing the encoded PNG of the generated image."
|
||||
},
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"description": "Not used. Will be empty."
|
||||
},
|
||||
"info": {
|
||||
"type": "string",
|
||||
"description": "Not used. Will be empty."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Successful request"
|
||||
}
|
||||
},
|
||||
"summary": "Generates an image from a text prompt",
|
||||
"tags": [
|
||||
"sdapi/v1"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/completions": {
|
||||
"post": {
|
||||
"summary": "Generates text continuations given a prompt. Please refer to OpenAI documentation",
|
||||
"description": "Generates text continuations given a prompt.\n\nThis is an OpenAI compatibility endpoint.\n\n Please refer to OpenAI documentation at [https://platform.openai.com/docs/api-reference/completions](https://platform.openai.com/docs/api-reference/completions)",
|
||||
"tags": [
|
||||
"v1"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/chat/completions": {
|
||||
"post": {
|
||||
"summary": "Generates a response from a list of messages. Please refer to OpenAI documentation",
|
||||
"description": "Given a list of messages comprising a conversation, the model will return a response.\n\n This is an OpenAI compatibility endpoint.\n\n Please refer to OpenAI documentation at [https://platform.openai.com/docs/api-reference/chat](https://platform.openai.com/docs/api-reference/chat)",
|
||||
"tags": [
|
||||
"v1"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v1/models": {
|
||||
"get": {
|
||||
"summary": "List and describe the various models available in the API. Please refer to OpenAI documentation",
|
||||
"description": "List and describe the various models available in the API.\n\n This is an OpenAI compatibility endpoint.\n\n Please refer to OpenAI documentation at [https://platform.openai.com/docs/api-reference/models](https://platform.openai.com/docs/api-reference/models)",
|
||||
"tags": [
|
||||
"v1"
|
||||
]
|
||||
}
|
||||
},
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "/api"
|
||||
"url": "/"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"description": "KoboldAI United compatible API core endpoints",
|
||||
"name": "v1"
|
||||
"name": "api/v1"
|
||||
},
|
||||
{
|
||||
"description": "Extended API unique to KoboldCpp",
|
||||
"name": "extra"
|
||||
"name": "api/extra"
|
||||
},
|
||||
{
|
||||
"description": "Image Generation API (A1111 compatible)",
|
||||
"name": "sdapi/v1"
|
||||
},
|
||||
{
|
||||
"description": "OpenAI compatible textgen API (not recommended)",
|
||||
"name": "v1"
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
|
@ -6958,11 +6958,9 @@ Current version: 118
|
|||
.then(response => response.json())
|
||||
.then(values6 => {
|
||||
console.log(values6);
|
||||
if(values6 && values6.length>0)
|
||||
if(values6 && values6.length>0 && values6[0].model_name!="inactive" && values6[0].filename!=null)
|
||||
{
|
||||
let firstitem = values6[0];
|
||||
if(firstitem.model_name!="inactive" && firstitem.filename!=null)
|
||||
{
|
||||
//local image gen is available
|
||||
if(localsettings.generate_images_mode==0)
|
||||
{
|
||||
|
@ -6983,7 +6981,7 @@ Current version: 118
|
|||
render_gametext(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}).catch(error => {
|
||||
console.log("Failed to get local image models: " + error);
|
||||
});
|
||||
|
|
|
@ -962,6 +962,9 @@ Enter Prompt:<br>
|
|||
response_body = (json.dumps({"object":"list","data":[{"id":friendlymodelname,"object":"model","created":1,"owned_by":"koboldcpp","permission":[],"root":"koboldcpp"}]}).encode())
|
||||
|
||||
elif self.path.endswith('/sdapi/v1/sd-models'):
|
||||
if friendlysdmodelname=="inactive" or fullsdmodelpath=="":
|
||||
response_body = (json.dumps([]).encode())
|
||||
else:
|
||||
response_body = (json.dumps([{"title":friendlysdmodelname,"model_name":friendlysdmodelname,"hash":"8888888888","sha256":"8888888888888888888888888888888888888888888888888888888888888888","filename":fullsdmodelpath,"config": None}]).encode())
|
||||
elif self.path.endswith('/sdapi/v1/options'):
|
||||
response_body = (json.dumps({"samples_format":"png","sd_model_checkpoint":friendlysdmodelname}).encode())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue