Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,14 @@ user_db = {os.environ['username']: os.environ['password']}
|
|
12 |
|
13 |
messages = [{"role": "system", "content": 'You are a helpful technology assistant.'}]
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
def audioGPT(audio):
|
16 |
global messages
|
17 |
|
@@ -77,7 +85,7 @@ def fileGPT(prompt, file_obj):
|
|
77 |
global messages
|
78 |
|
79 |
file_text = extract_text(file_obj.name)
|
80 |
-
text = prompt + file_text
|
81 |
|
82 |
messages.append({"role": "user", "content": text})
|
83 |
|
@@ -122,11 +130,12 @@ with gr.Blocks() as chatHistory:
|
|
122 |
|
123 |
|
124 |
|
|
|
125 |
text = gr.Interface(fn=textGPT, inputs="text", outputs="text")
|
126 |
audio = gr.Interface(fn=audioGPT, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text")
|
127 |
siri = gr.Interface(fn=siriGPT, inputs=gr.Audio(source="microphone", type="filepath"), outputs = "audio")
|
128 |
-
file = gr.Interface(fn=fileGPT, inputs=["text", "file"], outputs="text", description = "Enter prompt sentences and your PDF. e.g. lets think step by step, summarize this following text:")
|
129 |
-
demo = gr.TabbedInterface([text, audio, siri, file, chatHistory], [ "chatGPT", "audioGPT", "siriGPT", "fileGPT", "ChatHistory"])
|
130 |
|
131 |
if __name__ == "__main__":
|
132 |
demo.launch(enable_queue=False, auth=lambda u, p: user_db.get(u) == p,
|
|
|
12 |
|
13 |
messages = [{"role": "system", "content": 'You are a helpful technology assistant.'}]
|
14 |
|
15 |
+
|
16 |
+
|
17 |
+
def roleChoice(role):
|
18 |
+
global messages
|
19 |
+
messages = [{"role": "system", "content": role}]
|
20 |
+
return "role:" + messages
|
21 |
+
|
22 |
+
|
23 |
def audioGPT(audio):
|
24 |
global messages
|
25 |
|
|
|
85 |
global messages
|
86 |
|
87 |
file_text = extract_text(file_obj.name)
|
88 |
+
text = prompt + "\n" + file_text
|
89 |
|
90 |
messages.append({"role": "user", "content": text})
|
91 |
|
|
|
130 |
|
131 |
|
132 |
|
133 |
+
role = gr.Interface(fn=roleChoice, inputs="text", outputs="text", description = "Choose your GPT roles, e.g. You are a helpful technology assistant. 你是一位 IT 架构师。 你是一位开发者关系顾问。你是一位机器学习工程师。你是一位高级 C++ 开发人员 ")
|
134 |
text = gr.Interface(fn=textGPT, inputs="text", outputs="text")
|
135 |
audio = gr.Interface(fn=audioGPT, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text")
|
136 |
siri = gr.Interface(fn=siriGPT, inputs=gr.Audio(source="microphone", type="filepath"), outputs = "audio")
|
137 |
+
file = gr.Interface(fn=fileGPT, inputs=["text", "file"], outputs="text", description = "Enter prompt sentences and your PDF. e.g. lets think step by step, summarize this following text: 或者 让我们一步一步地思考,总结以下的内容:")
|
138 |
+
demo = gr.TabbedInterface([role, text, audio, siri, file, chatHistory], [ "roleChoice", "chatGPT", "audioGPT", "siriGPT", "fileGPT", "ChatHistory"])
|
139 |
|
140 |
if __name__ == "__main__":
|
141 |
demo.launch(enable_queue=False, auth=lambda u, p: user_db.get(u) == p,
|