Skip to content

Commit bc7802e

Browse files
orionrmalfet
authored andcommitted
[Bug] Fixing the browser chat interface after my cli changes. Also GET support. (#315)
1 parent 514a4bf commit bc7802e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

chat_in_browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ def main():
3030
output += line.decode('utf-8').strip() + "\n"
3131
return render_template('chat.html', convo="Hello! What is your prompt?", disable_input=disable_input)
3232

33-
@app.route('/chat', methods=['POST'])
33+
@app.route('/chat', methods=['GET', 'POST'])
3434
def chat():
3535
# Retrieve the HTTP POST request parameter value from 'request.form' dictionary
36-
_prompt = request.form.get('prompt')
36+
_prompt = request.form.get('prompt', '')
3737
proc.stdin.write((_prompt + "\n").encode('utf-8'))
3838
proc.stdin.flush()
3939

torchchat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@
125125
else:
126126
i += 1
127127

128-
args_plus_chat = ['"{}"'.format(s) for s in sys.argv[2:]] + ["\"--chat\""]
128+
# Construct arguments for the flask app minus 'browser' command plus '--chat'
129+
args_plus_chat = ['"{}"'.format(s) for s in sys.argv[1:] if s != "browser"] + ['"--chat"']
129130
formatted_args = ", ".join(args_plus_chat)
130131
command = ["flask", "--app", "chat_in_browser:create_app(" + formatted_args + ")", "run", "--port", f"{port}"]
131132
subprocess.run(command)

0 commit comments

Comments
 (0)