martins0n commited on
Commit ·
e90f014
1
Parent(s): 76b40aa
fix: keys
Browse filesFiles changed (2)
- .gitignoreAdded+3
- app.py+14-9
123.env__pycache__.pytest_cache6 unmodified lines78910111219 unmodified lines323334353637383940414243444546474849505152536 unmodified linesopenai.api_key = OPENAI_API_KEYdef audio_response(audio, chat_history):with open(audio, "rb") as f:text = transcribe(f)history = [dict(content=content, role=role) for messages in chat_history for role, content in zip(("user", "assistant"), messages)]19 unmodified linesclear = gr.ClearButton([msg, chatbot, audio_in])def echo(name, request: gr.Request):print("Request headers dictionary:", request.headers)print("IP address:", request.client.host)return namemsg.submit(echo, [msg], [msg])with gr.Accordion("System Prompt", open=False):msg = gr.Textbox(SYSTEM_PROMPT)def update_prompt(msg):global SYSTEM_PROMPTSYSTEM_PROMPT = msgreturn SYSTEM_PROMPTmsg.submit(update_prompt, [msg], [msg])6 unmodified lines789101112131419 unmodified lines343536373839404142434445464748495051525354555657586 unmodified linesopenai.api_key = OPENAI_API_KEYdef audio_response(audio, chat_history):if audio is None:return None, chat_historywith open(audio, "rb") as f:text = transcribe(f)history = [dict(content=content, role=role) for messages in chat_history for role, content in zip(("user", "assistant"), messages)]19 unmodified linesclear = gr.ClearButton([msg, chatbot, audio_in])with gr.Accordion("Settings", open=False):prompt = gr.Textbox(SYSTEM_PROMPT, label="System Prompt")token = gr.Textbox(OPENAI_API_KEY, type="password", label="OpenAI API Key")def update_prompt(msg):global SYSTEM_PROMPTSYSTEM_PROMPT = msgreturn SYSTEM_PROMPTdef set_token(token):global OPENAI_API_KEYOPENAI_API_KEY = tokenopenai.api_key = OPENAI_API_KEYreturn tokenprompt.submit(update_prompt, [prompt], [prompt])token.submit(set_token, [token], [token])
.gitignoreAdded+3
app.py+14-9