Spaces:
Running
Running
arslan-ahmed
commited on
Commit
·
4fc4d89
1
Parent(s):
ea4834d
add auth
Browse files- app.py +2 -1
- ttyd_functions.py +8 -2
app.py
CHANGED
@@ -299,4 +299,5 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue='orange', secondary_hue='gray
|
|
299 |
msg.submit(**chat_btn_args)
|
300 |
|
301 |
demo.queue(default_concurrency_limit=10)
|
302 |
-
|
|
|
|
299 |
msg.submit(**chat_btn_args)
|
300 |
|
301 |
demo.queue(default_concurrency_limit=10)
|
302 |
+
gradio_auth=None # comment this if you want to use Authentication
|
303 |
+
demo.launch(show_error=True, auth=gradio_auth)
|
ttyd_functions.py
CHANGED
@@ -52,7 +52,7 @@ def getOaiCreds(key):
|
|
52 |
def getBamCreds(key):
|
53 |
key = key if key else 'Null'
|
54 |
return {'service': 'bam',
|
55 |
-
'bam_creds' : Credentials(key, api_endpoint='https://bam-api.res.ibm.com/v1')
|
56 |
}
|
57 |
|
58 |
|
@@ -373,4 +373,10 @@ def changeModel(oldModel, newModel):
|
|
373 |
return newModel
|
374 |
|
375 |
def getModelChoices(openAi_models, wml_models, bam_models):
|
376 |
-
return [model +' (openai)' for model in openAi_models] + [model.value +' (watsonx)' for model in wml_models] + [model + ' (bam)' for model in bam_models]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
def getBamCreds(key):
|
53 |
key = key if key else 'Null'
|
54 |
return {'service': 'bam',
|
55 |
+
'bam_creds' : Credentials(key, api_endpoint=os.getenv("BAM_ENDPOINT",'https://bam-api.res.ibm.com/v1'))
|
56 |
}
|
57 |
|
58 |
|
|
|
373 |
return newModel
|
374 |
|
375 |
def getModelChoices(openAi_models, wml_models, bam_models):
|
376 |
+
return [model +' (openai)' for model in openAi_models] + [model.value +' (watsonx)' for model in wml_models] + [model + ' (bam)' for model in bam_models]
|
377 |
+
|
378 |
+
def gradio_auth(userInput, passInput):
|
379 |
+
if userInput == os.getenv("USERNAME",'') and passInput == os.getenv("PASSWORD",''):
|
380 |
+
return True
|
381 |
+
else:
|
382 |
+
return False
|