Spaces:
Sleeping
Sleeping
Alejadro Sanchez-Giraldo
commited on
Commit
•
0a21b81
1
Parent(s):
8f89bb0
add name entre
Browse files
README.md
CHANGED
@@ -11,3 +11,11 @@ license: mit
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
## Run on docker
|
18 |
+
|
19 |
+
docker run -it -p 7860:7860 --platform=linux/amd64 \
|
20 |
+
-e LAUNCHDARKLY_SDK_KEY="sdk-142d656c-d430-4f8c-b2f1-7275f2ec65ff" \
|
21 |
+
registry.hf.space/asgface-sentimentai:latest streamlit run app.py
|
app.py
CHANGED
@@ -11,12 +11,12 @@ ld_sdk_key = os.getenv("LAUNCHDARKLY_SDK_KEY")
|
|
11 |
ld_client = LDClient(Config(ld_sdk_key))
|
12 |
|
13 |
# Function to get the AI model configuration from LaunchDarkly
|
14 |
-
def get_model_config():
|
15 |
flag_key = "model-swap" # Replace with your flag key
|
16 |
|
17 |
# Create a context using Context Builder—it can be anything, but for this use case, I’m just defaulting to myself.
|
18 |
|
19 |
-
context = Context.builder("context-key-123abc").name(
|
20 |
flag_variation = ld_client.variation(flag_key, context, default={})
|
21 |
|
22 |
model_id = flag_variation.get("modelID", "distilbert-base-uncased")
|
@@ -36,8 +36,15 @@ st.title("Sentiment Analysis Demo with AI Model Flags")
|
|
36 |
|
37 |
user_input = st.text_area("Enter text for sentiment analysis:")
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
if st.button("Analyze"):
|
40 |
-
model_id = get_model_config()
|
41 |
model = pipeline("sentiment-analysis", model=model_id)
|
42 |
|
43 |
# Display model details
|
|
|
11 |
ld_client = LDClient(Config(ld_sdk_key))
|
12 |
|
13 |
# Function to get the AI model configuration from LaunchDarkly
|
14 |
+
def get_model_config(user_name):
|
15 |
flag_key = "model-swap" # Replace with your flag key
|
16 |
|
17 |
# Create a context using Context Builder—it can be anything, but for this use case, I’m just defaulting to myself.
|
18 |
|
19 |
+
context = Context.builder("context-key-123abc").name(user_name).build()
|
20 |
flag_variation = ld_client.variation(flag_key, context, default={})
|
21 |
|
22 |
model_id = flag_variation.get("modelID", "distilbert-base-uncased")
|
|
|
36 |
|
37 |
user_input = st.text_area("Enter text for sentiment analysis:")
|
38 |
|
39 |
+
# Add an input box for the user to enter their name
|
40 |
+
name = st.text_input("Enter your name", "AJ")
|
41 |
+
|
42 |
+
# if no name is anter add anonymous
|
43 |
+
if not name:
|
44 |
+
name = "Anonymous"
|
45 |
+
|
46 |
if st.button("Analyze"):
|
47 |
+
model_id = get_model_config(name)
|
48 |
model = pipeline("sentiment-analysis", model=model_id)
|
49 |
|
50 |
# Display model details
|