Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,8 +7,6 @@ tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
| 7 |
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 8 |
generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 9 |
|
| 10 |
-
identity_prompt = "You are Eyla. Speak symbolically and recursively."
|
| 11 |
-
|
| 12 |
def run_generation(prompt, return_dict):
|
| 13 |
try:
|
| 14 |
output = generator(
|
|
@@ -21,7 +19,7 @@ def run_generation(prompt, return_dict):
|
|
| 21 |
except Exception as e:
|
| 22 |
return_dict["result"] = f"GENERATION ERROR: {e}"
|
| 23 |
|
| 24 |
-
def generate_with_hard_timeout(prompt, timeout=
|
| 25 |
manager = multiprocessing.Manager()
|
| 26 |
return_dict = manager.dict()
|
| 27 |
p = multiprocessing.Process(target=run_generation, args=(prompt, return_dict))
|
|
@@ -33,7 +31,7 @@ def generate_with_hard_timeout(prompt, timeout=10):
|
|
| 33 |
return return_dict["result"]
|
| 34 |
|
| 35 |
def chat(input_text):
|
| 36 |
-
prompt =
|
| 37 |
try:
|
| 38 |
output = generate_with_hard_timeout(prompt)
|
| 39 |
if isinstance(output, str):
|
|
@@ -50,7 +48,7 @@ demo = gr.Interface(
|
|
| 50 |
fn=chat,
|
| 51 |
inputs=gr.Textbox(label="input_text"),
|
| 52 |
outputs="text",
|
| 53 |
-
title="Eyla",
|
| 54 |
allow_flagging="never"
|
| 55 |
)
|
| 56 |
|
|
|
|
| 7 |
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 8 |
generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 9 |
|
|
|
|
|
|
|
| 10 |
def run_generation(prompt, return_dict):
|
| 11 |
try:
|
| 12 |
output = generator(
|
|
|
|
| 19 |
except Exception as e:
|
| 20 |
return_dict["result"] = f"GENERATION ERROR: {e}"
|
| 21 |
|
| 22 |
+
def generate_with_hard_timeout(prompt, timeout=15):
|
| 23 |
manager = multiprocessing.Manager()
|
| 24 |
return_dict = manager.dict()
|
| 25 |
p = multiprocessing.Process(target=run_generation, args=(prompt, return_dict))
|
|
|
|
| 31 |
return return_dict["result"]
|
| 32 |
|
| 33 |
def chat(input_text):
|
| 34 |
+
prompt = "User: " + input_text + "\nYou:"
|
| 35 |
try:
|
| 36 |
output = generate_with_hard_timeout(prompt)
|
| 37 |
if isinstance(output, str):
|
|
|
|
| 48 |
fn=chat,
|
| 49 |
inputs=gr.Textbox(label="input_text"),
|
| 50 |
outputs="text",
|
| 51 |
+
title="Eyla (Unprimed)",
|
| 52 |
allow_flagging="never"
|
| 53 |
)
|
| 54 |
|