gptq processing

This commit is contained in:
kwaroran
2023-08-18 19:38:52 +09:00
parent b465d2639e
commit bf1bd127ab
5 changed files with 47 additions and 20 deletions

7
.gitignore vendored
View File

@@ -30,4 +30,9 @@ src-others/
/src-taurl/gen/ /src-taurl/gen/
/build/ /build/
pycache/ pycache/
test.ts test.ts
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

View File

@@ -115,16 +115,9 @@
{/if} {/if}
</Arcodion> </Arcodion>
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('reverse_proxy')}}>Reverse Proxy</button> <button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('reverse_proxy')}}>Reverse Proxy</button>
<!-- <button class="hover:bg-selected px-6 py-2 text-lg" on:click={async () => { <button class="hover:bg-selected px-6 py-2 text-lg" on:click={async () => {
const res = (await checkLocalModel()) changeModel('local_gptq')
if(res === 'success'){ }}>Local Model GPTQ</button>
changeModel('local_gptq')
}
else{
alertError("python 3.10, cuda 11.7 and git must be installed to run it. " + res)
}
// changeModel('local_gptq')
}}>Local Model GPTQ</button> -->
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('textgen_webui')}}>Oobabooga WebUI</button> <button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('textgen_webui')}}>Oobabooga WebUI</button>
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('mancer')}}>Mancer</button> <button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('mancer')}}>Mancer</button>
<button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('palm2')}}>Google PaLM2</button> <button class="hover:bg-selected px-6 py-2 text-lg" on:click={() => {changeModel('palm2')}}>Google PaLM2</button>

View File

@@ -79,7 +79,7 @@ export function alertToast(msg:string){
} }
export function alertWait(msg:string){ export function alertWait(msg:string){
console.log(msg)
alertStore.set({ alertStore.set({
'type': 'wait', 'type': 'wait',
'msg': msg 'msg': msg

View File

@@ -21,7 +21,8 @@ export async function startLocalModelServer(){
} }
export async function checkLocalServerInstalled() { export async function checkLocalServerInstalled() {
const p = await path.join(await path.appDataDir(), 'local_server') console.log(await path.appDataDir())
const p = await path.join(await path.appDataDir(), 'local_server', 'key.txt')
return await exists(p) return await exists(p)
} }
@@ -76,6 +77,17 @@ interface LocalGeneratorItem {
max_new_tokens?: number; max_new_tokens?: number;
} }
export async function checkServerRunning() {
try {
console.log("checking server")
const res = await fetch("http://localhost:7239/")
console.log(res)
return res.ok
} catch (error) {
return false
}
}
export async function loadExllamaFull(){ export async function loadExllamaFull(){
@@ -89,17 +101,20 @@ export async function loadExllamaFull(){
} }
while(true){ while(true){
//check is server is running by fetching the status //check is server is running by fetching the status
try { if(await checkLocalServerInstalled()){
const res = await globalFetch("http://localhost:7239/") await sleep(1000)
if(res.ok){ try {
break const res = await fetch("http://localhost:7239/")
} if(res.status === 200){
} catch (error) {} break
}
} catch (error) {}
}
await sleep(1000) await sleep(1000)
} }
const body:LocalLoaderItem = { const body:LocalLoaderItem = {
dir: "exllama", dir: "C:\\Users\\blueb\\Downloads\\model",
} }
alertWait("Loading Local Model") alertWait("Loading Local Model")
@@ -117,6 +132,10 @@ export async function loadExllamaFull(){
export async function runLocalModel(prompt:string){ export async function runLocalModel(prompt:string){
const db = get(DataBase) const db = get(DataBase)
if(!serverRunning){
await loadExllamaFull()
}
const body:LocalGeneratorItem = { const body:LocalGeneratorItem = {
prompt: prompt, prompt: prompt,
temperature: db.temperature, temperature: db.temperature,
@@ -126,6 +145,8 @@ export async function runLocalModel(prompt:string){
max_new_tokens: db.maxResponse max_new_tokens: db.maxResponse
} }
console.log("generating")
const gen = await globalFetch("http://localhost:7239/generate/", { const gen = await globalFetch("http://localhost:7239/generate/", {
body: body body: body
}) })

View File

@@ -10,6 +10,7 @@ import { createDeep } from "./deepai";
import { hubURL } from "../characterCards"; import { hubURL } from "../characterCards";
import { NovelAIBadWordIds, stringlizeNAIChat } from "./models/nai"; import { NovelAIBadWordIds, stringlizeNAIChat } from "./models/nai";
import { tokenizeNum } from "../tokenizer"; import { tokenizeNum } from "../tokenizer";
import { runLocalModel } from "./models/local";
interface requestDataArgument{ interface requestDataArgument{
formated: OpenAIChat[] formated: OpenAIChat[]
@@ -957,6 +958,13 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
} }
}
if(aiModel.startsWith('local_')){
console.log('running local model')
const suggesting = model === "submodel"
const proompt = stringlizeChatOba(formated, currentChar.name, suggesting, arg.continue)
const stopStrings = getStopStrings(suggesting)
await runLocalModel(proompt)
} }
return { return {
type: 'fail', type: 'fail',