Spaces:
Runtime error
Runtime error
Moritz Stephan
commited on
Commit
·
1f7ec24
1
Parent(s):
dd27d00
adding disable adapter checkbox
Browse files
app.py
CHANGED
|
@@ -20,10 +20,10 @@ def get_feedback_options() -> List[Tuple[str, str]]:
|
|
| 20 |
for adapter in data]
|
| 21 |
|
| 22 |
|
| 23 |
-
def get_completion(prompt: str, adapter: Optional[str]
|
| 24 |
args = {
|
| 25 |
"C3PO_API_KEY": os.environ.get("C3PO_API_KEY"),
|
| 26 |
-
"prompt": prompt,
|
| 27 |
"adapter": adapter,
|
| 28 |
}
|
| 29 |
response = requests.post(f"{ENDPOINT_URL}/completion", json=args)
|
|
@@ -43,11 +43,23 @@ dropdown_options = get_feedback_options()
|
|
| 43 |
demo = gr.Interface(
|
| 44 |
get_completion,
|
| 45 |
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
gr.Textbox(
|
| 47 |
placeholder="Enter a prompt...", label="Prompt"
|
| 48 |
),
|
| 49 |
gr.Dropdown(
|
| 50 |
choices=dropdown_options, label="Feedback", info="Will add the adapter for the respective feedback to the model."
|
|
|
|
|
|
|
|
|
|
| 51 |
)
|
| 52 |
],
|
| 53 |
"text",
|
|
|
|
| 20 |
for adapter in data]
|
| 21 |
|
| 22 |
|
| 23 |
+
def get_completion(prompt: str, adapter: Optional[str], enable_feedback: bool) -> str:
|
| 24 |
args = {
|
| 25 |
"C3PO_API_KEY": os.environ.get("C3PO_API_KEY"),
|
| 26 |
+
"prompt": prompt if enable_feedback else None,
|
| 27 |
"adapter": adapter,
|
| 28 |
}
|
| 29 |
response = requests.post(f"{ENDPOINT_URL}/completion", json=args)
|
|
|
|
| 43 |
demo = gr.Interface(
|
| 44 |
get_completion,
|
| 45 |
[
|
| 46 |
+
gr.Markdown(
|
| 47 |
+
"""
|
| 48 |
+
# C3PO Demo
|
| 49 |
+
|
| 50 |
+
This is a demo of Contextualized Critiques with Constrained Preference Optimization (C3PO). See the project website [here](<insert link>), repo [here](<insert link>), and the paper [here](<insert link>).
|
| 51 |
+
|
| 52 |
+
Selecting a feedback in the dropdown and enabling the "Use Feedback Adapter" checkbox will add the respective adapter to the model. The model will then use the feedback to generate the completion.
|
| 53 |
+
"""
|
| 54 |
+
),
|
| 55 |
gr.Textbox(
|
| 56 |
placeholder="Enter a prompt...", label="Prompt"
|
| 57 |
),
|
| 58 |
gr.Dropdown(
|
| 59 |
choices=dropdown_options, label="Feedback", info="Will add the adapter for the respective feedback to the model."
|
| 60 |
+
),
|
| 61 |
+
gr.Checkbox(
|
| 62 |
+
label="Use Feedback Adapter", default=True, info="Enables the feedback adapter."
|
| 63 |
)
|
| 64 |
],
|
| 65 |
"text",
|