Skip to content

Commit c8f5d46

Browse files
authored
Update main.py
1 parent c8872e8 commit c8f5d46

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

Diff for: main.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ async def handle_request(request):
3636
model("gpt-4"),
3737
]
3838
}
39-
# print(data)
4039
return web.json_response(data)
4140
else:
42-
# Handle POST requests here
4341
data = await request.json()
4442
preprompt = [
45-
"[Use proper language regarding on a context.]"
43+
"[Use proper language regarding on a context.]" # No use for forcing a specific language now.
4644
]
4745
system = {
4846
"role":"system",
@@ -51,7 +49,6 @@ async def handle_request(request):
5149
system['content'] += ' '.join(preprompt)
5250
oldmsg = [system] + data['messages'][:-1]
5351
msg = data['messages'][-1]['content']
54-
print(oldmsg)
5552
response = web.StreamResponse()
5653
response.headers['Content-Type'] = 'application/json'
5754
await response.prepare(request)
@@ -65,7 +62,6 @@ async def handle_request(request):
6562
"choices": [{ "delta": {"role": "assistant"}, "finish_reason": None, "index": 0 }]
6663
}
6764
await response.write(f"data: {json.dumps(chunk)}\n\n".encode())
68-
print(chunk)
6965
async for res_text in Wrtn.chat_by_json(await Wrtn.make_chatbot(),
7066
msg=msg,
7167
oldmsg=oldmsg,
@@ -80,7 +76,6 @@ async def handle_request(request):
8076
"choices": [{ "delta": {"content": res_text}, "finish_reason": None, "index": 0 }]
8177
}
8278
await response.write(f"data: {json.dumps(chunk)}\n\n".encode())
83-
# print(chunk)
8479
except Exception as ex:
8580
print(f"Error: {str(ex)}\n Chunk: {temp_res_text}")
8681
finally:
@@ -97,4 +92,4 @@ async def handle_request(request):
9792

9893
app = web.Application()
9994
app.router.add_route('*', '/{path:.*}', handle_request)
100-
web.run_app(app, host='127.0.0.1', port = 41323)
95+
web.run_app(app, host='127.0.0.1', port = 41323)

0 commit comments

Comments
 (0)