-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.py
More file actions
121 lines (104 loc) · 4.06 KB
/
Copy pathui.py
File metadata and controls
121 lines (104 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import gradio as gr
from config import load_css
from profile_agent import Me
def create_theme():
return gr.themes.Base().set(
body_background_fill="#05070a",
body_text_color="#d3c8ce",
body_background_fill_dark="#05070a",
body_text_color_dark="#d3c8ce",
)
def create_demo():
me = Me()
def add_user_message(message, history):
history = history or []
message = (message or "").strip()
if not message:
return "", history
return "", history + [{"role": "user", "content": message}]
def add_assistant_message(history):
history = history or []
if not history or history[-1].get("role") != "user":
return history
user_message = history[-1]["content"]
prior_history = history[:-1]
reply = me.chat(user_message, prior_history)
return history + [{"role": "assistant", "content": reply}]
initial_history = [
{
"role": "assistant",
"content": "Retrieval field online. Ask me about my background, work, or current engineering focus.",
}
]
with gr.Blocks(css=load_css(), theme=create_theme(), title="Fey Career Archive") as demo:
with gr.Column(elem_id="fey-app", elem_classes=["app-shell"]):
gr.HTML(
"""
<div class="system-strip" aria-hidden="true">
<span>FEY_CAREER_ARCHIVE v0.1.0</span>
<span>ACTIVE PROFILE NODE</span>
</div>
"""
)
with gr.Column(elem_id="career-archive-panel", elem_classes=["archive-panel"]):
gr.HTML(
"""
<header class="archive-panel-header">
<span>Federica Recanatini / Software Engineer</span>
</header>
"""
)
with gr.Column(elem_classes=["archive-panel-body"]):
gr.HTML(
"""
<div class="terminal-intro" aria-hidden="true">
<span class="terminal-line terminal-line-process">> retrieval field online.</span>
<span class="terminal-line terminal-line-ready">> profile signal stabilized.</span>
</div>
"""
)
chatbot = gr.Chatbot(
value=initial_history,
type="messages",
show_label=False,
height=460,
elem_id="career-chatbot",
elem_classes=["career-chatbot"],
)
with gr.Row(elem_classes=["prompt-row"]):
prompt = gr.Textbox(
label="> say",
show_label=False,
lines=1,
max_lines=4,
elem_id="career-input",
)
submit = gr.Button(
"send",
elem_id="career-submit",
elem_classes=["terminal-button"],
)
gr.HTML(
"""
<footer class="status-footer" aria-hidden="true">
<span>SYS: CAREER NODE_17</span>
<span>ARCHIVE INTEGRITY 100%</span>
<span>CONTACT CHANNEL: OPEN</span>
</footer>
"""
)
submit_event = prompt.submit(
add_user_message,
[prompt, chatbot],
[prompt, chatbot],
queue=False,
)
submit_event.then(add_assistant_message, chatbot, chatbot)
click_event = submit.click(
add_user_message,
[prompt, chatbot],
[prompt, chatbot],
queue=False,
)
click_event.then(add_assistant_message, chatbot, chatbot)
return demo