Spaces:
Running
Running
Commit ·
d68c41a
1
Parent(s): 4055f3a
settings to remove key
Browse files
app.py
CHANGED
|
@@ -24,6 +24,21 @@ else:
|
|
| 24 |
ex= None
|
| 25 |
ag = None
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
@cl.on_chat_start
|
| 28 |
async def on_chat_start():
|
| 29 |
global ex, ag, interactive_key_done
|
|
@@ -39,7 +54,9 @@ async def on_chat_start():
|
|
| 39 |
ex = create_extractor()
|
| 40 |
ag = create_agent(llm_model=model)
|
| 41 |
interactive_key_done= True
|
|
|
|
| 42 |
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()
|
|
|
|
| 43 |
except Exception as e:
|
| 44 |
await cl.Message(
|
| 45 |
content=f"Error: {e}. Start new chat with correct key.",
|
|
|
|
| 24 |
ex= None
|
| 25 |
ag = None
|
| 26 |
|
| 27 |
+
from chainlit.input_widget import Select
|
| 28 |
+
|
| 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 new chat now!").send()
|
| 35 |
+
interactive_key_done= False
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
@cl.on_chat_start
|
| 39 |
+
async def start():
|
| 40 |
+
settings = await cl.ChatSettings([Select(id="Setting",label="Clear GPT Token?",values=["Click Confirm:"],)]).send()
|
| 41 |
+
|
| 42 |
@cl.on_chat_start
|
| 43 |
async def on_chat_start():
|
| 44 |
global ex, ag, interactive_key_done
|
|
|
|
| 54 |
ex = create_extractor()
|
| 55 |
ag = create_agent(llm_model=model)
|
| 56 |
interactive_key_done= True
|
| 57 |
+
await cl.ChatSettings([Select(id="Setting",label="Clear GPT Token?",values=["Click Confirm:"],)]).send()
|
| 58 |
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()
|
| 59 |
+
await cl.Message("To remove/change you OpenAI API key, click on the settings icon on the left of the chat box.").send()
|
| 60 |
except Exception as e:
|
| 61 |
await cl.Message(
|
| 62 |
content=f"Error: {e}. Start new chat with correct key.",
|