Spaces:
Sleeping
Sleeping
Commit
·
080b748
1
Parent(s):
69f8025
Huggingface set token for whole space, per session token is annoying for user
Browse files
app.py
CHANGED
@@ -29,10 +29,10 @@ from chainlit.input_widget import Select
|
|
29 |
@cl.on_settings_update
|
30 |
async def setup_agent(settings):
|
31 |
global interactive_key_done
|
32 |
-
if cl.user_session.get("openai_api_key") == os.environ["OPENAI_API_KEY"]:
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
|
38 |
@cl.on_chat_start
|
@@ -51,13 +51,13 @@ async def on_chat_start():
|
|
51 |
ag = create_agent(llm_model=model)
|
52 |
interactive_key_done= True
|
53 |
await cl.Message(author="Socccer-RAG", content="✅ Voila! ⚽ Socccer-RAG warmed up and ready to go! You can start a fresh chat session from New Chat").send()
|
54 |
-
await cl.Message("To remove/change you OpenAI API key, click on the settings icon on the left of the chat box.").send()
|
55 |
except Exception as e:
|
56 |
await cl.Message(
|
57 |
content=f"❌Error: {e}. \n 🤗 Please Start new chat to set correct key.",
|
58 |
).send()
|
59 |
return
|
60 |
-
await cl.ChatSettings([Select(id="Setting",label="Remove/change
|
61 |
|
62 |
# ag = create_agent(llm_model = "gpt-4-0125-preview")
|
63 |
|
|
|
29 |
@cl.on_settings_update
|
30 |
async def setup_agent(settings):
|
31 |
global interactive_key_done
|
32 |
+
# if cl.user_session.get("openai_api_key") == os.environ["OPENAI_API_KEY"]:
|
33 |
+
os.environ["OPENAI_API_KEY"]= ""
|
34 |
+
await cl.Message("OpenAI API Key cleared, start a new chat to set new key!").send()
|
35 |
+
interactive_key_done= False
|
36 |
|
37 |
|
38 |
@cl.on_chat_start
|
|
|
51 |
ag = create_agent(llm_model=model)
|
52 |
interactive_key_done= True
|
53 |
await cl.Message(author="Socccer-RAG", content="✅ Voila! ⚽ Socccer-RAG warmed up and ready to go! You can start a fresh chat session from New Chat").send()
|
54 |
+
await cl.Message("💡Remeber to clear your keys when you are done. To remove/change you OpenAI API key, click on the settings icon on the left of the chat box.").send()
|
55 |
except Exception as e:
|
56 |
await cl.Message(
|
57 |
content=f"❌Error: {e}. \n 🤗 Please Start new chat to set correct key.",
|
58 |
).send()
|
59 |
return
|
60 |
+
await cl.ChatSettings([Select(id="Setting",label="Remove/change current OpenAI API Key?",values=["Click Confirm:"],)]).send()
|
61 |
|
62 |
# ag = create_agent(llm_model = "gpt-4-0125-preview")
|
63 |
|