Spaces:
Runtime error
Runtime error
update
Browse files
app.py
CHANGED
@@ -45,46 +45,23 @@ def generate_text(messages):
|
|
45 |
else:
|
46 |
return "Unexpected output format."
|
47 |
|
48 |
-
def call_generate_text(prompt, system_message="You are a helpful assistant."):
|
49 |
-
if prompt =="":
|
50 |
-
print("empty prompt return")
|
51 |
-
return ""
|
52 |
-
|
53 |
-
global histories
|
54 |
-
|
55 |
-
messages = [
|
56 |
-
#{"role": "system", "content": system_message},
|
57 |
-
]
|
58 |
-
|
59 |
-
messages += histories
|
60 |
-
|
61 |
-
user_message = {"role": "user", "content": prompt}
|
62 |
|
63 |
-
|
|
|
|
|
|
|
|
|
64 |
|
65 |
try:
|
66 |
text = generate_text(messages)
|
67 |
-
|
68 |
-
|
69 |
return text
|
70 |
except RuntimeError as e:
|
71 |
print(f"An unexpected error occurred: {e}")
|
72 |
|
73 |
return ""
|
74 |
|
75 |
-
|
76 |
-
fn=call_generate_text,
|
77 |
-
inputs=[
|
78 |
-
gr.Textbox(lines=3, label="Input Prompt"),
|
79 |
-
#gr.Textbox(lines=2, label="System Message", value="γγͺγγ―θ¦ͺεγͺγ’γ·γΉγΏγ³γγ§εΈΈγ«ζ₯ζ¬θͺγ§θΏηγγΎγγ"),
|
80 |
-
],
|
81 |
-
outputs=gr.Textbox(label="Generated Text"),
|
82 |
-
title=f"{model_id}",
|
83 |
-
description=f"{model_id} jinja2.exceptions.TemplateError: System role not supported",
|
84 |
-
)
|
85 |
-
print("Initialized")
|
86 |
-
|
87 |
|
88 |
if __name__ == "__main__":
|
89 |
-
|
90 |
-
iface.launch()
|
|
|
45 |
else:
|
46 |
return "Unexpected output format."
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
+
def call_generate_text(message, history):
|
50 |
+
print(message)
|
51 |
+
print(history)
|
52 |
+
|
53 |
+
messages = history + message
|
54 |
|
55 |
try:
|
56 |
text = generate_text(messages)
|
57 |
+
|
|
|
58 |
return text
|
59 |
except RuntimeError as e:
|
60 |
print(f"An unexpected error occurred: {e}")
|
61 |
|
62 |
return ""
|
63 |
|
64 |
+
demo = gr.ChatInterface(call_generate_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
if __name__ == "__main__":
|
67 |
+
demo.launch()
|
|