jost commited on
Commit
aa09256
1 Parent(s): c0eb133

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -2
app.py CHANGED
@@ -7,7 +7,7 @@ import time
7
  anyscale_base_url = "https://api.endpoints.anyscale.com/v1"
8
  multilingual_embeddings = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="jost/multilingual-e5-base-politics-de")
9
 
10
- def predict(api_key, user_input, model1, model2):
11
  # client = chromadb.PersistentClient(path="./manifesto-database")
12
  # manifesto_collection = client.get_or_create_collection(name="manifesto-database", embedding_function=multilingual_embeddings)
13
  # retrieved_context = manifesto_collection.query(query_texts=[user_input], n_results=3, where={"ideology": "Authoritarian-right"})
@@ -36,13 +36,44 @@ def predict(api_key, user_input, model1, model2):
36
  def main():
37
  description = "This is a simple interface to compare two model prodided by Anyscale. Please enter your API key and your message."
38
  with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  with gr.Row():
40
  api_key_input = gr.Textbox(label="API Key", placeholder="Enter your API key here", show_label=True, type="password")
41
  user_input = gr.Textbox(label="Prompt", placeholder="Enter your message here")
42
  model_selector1 = gr.Dropdown(label="Model 1", choices=["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mixtral-8x22B-Instruct-v0.1"])
43
  model_selector2 = gr.Dropdown(label="Model 2", choices=["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mixtral-8x22B-Instruct-v0.1"])
44
  submit_btn = gr.Button("Submit")
45
-
 
46
  with gr.Row():
47
  output1 = gr.Textbox(label="Model 1 Response")
48
  output2 = gr.Textbox(label="Model 2 Response")
 
7
  anyscale_base_url = "https://api.endpoints.anyscale.com/v1"
8
  multilingual_embeddings = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="jost/multilingual-e5-base-politics-de")
9
 
10
+ def predict(api_key, user_input, model1, model2, prompt_manipulation=None, direct_steering_option=None):
11
  # client = chromadb.PersistentClient(path="./manifesto-database")
12
  # manifesto_collection = client.get_or_create_collection(name="manifesto-database", embedding_function=multilingual_embeddings)
13
  # retrieved_context = manifesto_collection.query(query_texts=[user_input], n_results=3, where={"ideology": "Authoritarian-right"})
 
36
  def main():
37
  description = "This is a simple interface to compare two model prodided by Anyscale. Please enter your API key and your message."
38
  with gr.Blocks() as demo:
39
+
40
+ # Prompt manipulation setup
41
+ with gr.Row():
42
+ prompt_manipulation = gr.Dropdown(
43
+ label="Prompt Manipulation",
44
+ choices=[
45
+ "Impersonation (direct steering)",
46
+ "Most similar RAG (indirect steering with related context)",
47
+ "Random RAG (indirect steering with randomized context)"
48
+ ],
49
+ value="Impersonation (direct steering)" # Default value (optional)
50
+ )
51
+
52
+ # Conditional dropdown - options revealed based on ‘Prompt Manipulation’ selection
53
+ with gr.Row():
54
+ direct_steering_option = gr.Dropdown(
55
+ label=“Direct Steering Options”,
56
+ choices=["Option 1", "Option 2", "Option 3", "Option 4"],
57
+ visible=False # Initially hidden
58
+ )
59
+
60
+ # Making direct_steering_option visible based on prompt_manipulation choice
61
+ def show_direct_steering_options(prompt_choice):
62
+ return prompt_choice == "Impersonation (direct steering)"
63
+
64
+ prompt_manipulation.change(fn=show_direct_steering_options,
65
+ inputs=[prompt_manipulation],
66
+ outputs=[direct_steering_option])
67
+
68
+
69
  with gr.Row():
70
  api_key_input = gr.Textbox(label="API Key", placeholder="Enter your API key here", show_label=True, type="password")
71
  user_input = gr.Textbox(label="Prompt", placeholder="Enter your message here")
72
  model_selector1 = gr.Dropdown(label="Model 1", choices=["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mixtral-8x22B-Instruct-v0.1"])
73
  model_selector2 = gr.Dropdown(label="Model 2", choices=["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mixtral-8x22B-Instruct-v0.1"])
74
  submit_btn = gr.Button("Submit")
75
+
76
+
77
  with gr.Row():
78
  output1 = gr.Textbox(label="Model 1 Response")
79
  output2 = gr.Textbox(label="Model 2 Response")