Spaces:
Runtime error
Runtime error
Update run.py
Browse files
run.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
# Title: German AI-Interface with advanced RAG
|
| 3 |
# Author: Andreas Fischer
|
| 4 |
# Date: January 31st, 2023
|
| 5 |
-
# Last update: February
|
| 6 |
##########################################################################################
|
| 7 |
|
| 8 |
#https://github.com/abetlen/llama-cpp-python/issues/306
|
|
@@ -187,18 +187,25 @@ else:
|
|
| 187 |
#------------
|
| 188 |
|
| 189 |
def extend_prompt(message="", history=None, system=None, RAGAddon=None, system2=None, zeichenlimit=None,historylimit=4): #float("Inf")
|
|
|
|
| 190 |
if zeichenlimit is None: zeichenlimit=1000000000 # :-)
|
| 191 |
-
template0="[INST] {system} [/INST]</s>"
|
| 192 |
-
template1="[INST] {message} [/INST]
|
| 193 |
-
template2="{response}</s>"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
if("mixtral-8x7b-instruct" in modelPath): # https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
|
|
|
| 198 |
if("Mistral-7B-Instruct" in modelPath): #https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
|
|
|
| 202 |
if("openchat-3.5" in modelPath): #https://huggingface.co/TheBloke/openchat-3.5-0106-GGUF
|
| 203 |
template0="GPT4 Correct User: {system}<|end_of_turn|>GPT4 Correct Assistant: Okay.<|end_of_turn|>"
|
| 204 |
template1="GPT4 Correct User: {message}<|end_of_turn|>GPT4 Correct Assistant: "
|
|
@@ -231,7 +238,7 @@ def extend_prompt(message="", history=None, system=None, RAGAddon=None, system2=
|
|
| 231 |
if message is not None: prompt += template1.format(message=message[:zeichenlimit]) #"[INST] {message} [/INST]"
|
| 232 |
if system2 is not None:
|
| 233 |
prompt += system2
|
| 234 |
-
return prompt
|
| 235 |
|
| 236 |
import gradio as gr
|
| 237 |
import requests
|
|
|
|
| 2 |
# Title: German AI-Interface with advanced RAG
|
| 3 |
# Author: Andreas Fischer
|
| 4 |
# Date: January 31st, 2023
|
| 5 |
+
# Last update: February 25st, 2024
|
| 6 |
##########################################################################################
|
| 7 |
|
| 8 |
#https://github.com/abetlen/llama-cpp-python/issues/306
|
|
|
|
| 187 |
#------------
|
| 188 |
|
| 189 |
def extend_prompt(message="", history=None, system=None, RAGAddon=None, system2=None, zeichenlimit=None,historylimit=4): #float("Inf")
|
| 190 |
+
startOfString=""
|
| 191 |
if zeichenlimit is None: zeichenlimit=1000000000 # :-)
|
| 192 |
+
template0=" [INST]{system}\n [/INST] </s>" if onPrem else "<s> [INST] {system} [/INST] </s>"
|
| 193 |
+
template1=" [INST] {message} [/INST]"
|
| 194 |
+
template2=" {response}</s>"
|
| 195 |
+
if("gemma-" in modelPath): # https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1
|
| 196 |
+
template0="<start_of_turn>user{system}</end_of_turn>"
|
| 197 |
+
template1="<start_of_turn>user{message}</end_of_turn><start_of_turn>model"
|
| 198 |
+
template2="{response}</end_of_turn>"
|
| 199 |
if("mixtral-8x7b-instruct" in modelPath): # https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1
|
| 200 |
+
startOfString="<s>"
|
| 201 |
+
template0=" [INST]{system}\n [/INST] </s>" if onPrem else "<s> [INST]{system}\n [/INST] </s>"
|
| 202 |
+
template1=" [INST] {message} [/INST]"
|
| 203 |
+
template2=" {response}</s>"
|
| 204 |
if("Mistral-7B-Instruct" in modelPath): #https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2
|
| 205 |
+
startOfString="<s>"
|
| 206 |
+
template0="[INST]{system}\n [/INST]</s>" if onPrem else "<s>[INST]{system}\n [/INST]</s>"
|
| 207 |
+
template1="[INST] {message} [/INST]"
|
| 208 |
+
template2=" {response}</s>"
|
| 209 |
if("openchat-3.5" in modelPath): #https://huggingface.co/TheBloke/openchat-3.5-0106-GGUF
|
| 210 |
template0="GPT4 Correct User: {system}<|end_of_turn|>GPT4 Correct Assistant: Okay.<|end_of_turn|>"
|
| 211 |
template1="GPT4 Correct User: {message}<|end_of_turn|>GPT4 Correct Assistant: "
|
|
|
|
| 238 |
if message is not None: prompt += template1.format(message=message[:zeichenlimit]) #"[INST] {message} [/INST]"
|
| 239 |
if system2 is not None:
|
| 240 |
prompt += system2
|
| 241 |
+
return startOfString+prompt
|
| 242 |
|
| 243 |
import gradio as gr
|
| 244 |
import requests
|