Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,7 +50,6 @@ def respond(
|
|
| 50 |
history: list[tuple[str, str]],
|
| 51 |
model_name,
|
| 52 |
prompt_strategy,
|
| 53 |
-
system_message,
|
| 54 |
override_params: bool,
|
| 55 |
max_tokens,
|
| 56 |
temperature,
|
|
@@ -58,11 +57,12 @@ def respond(
|
|
| 58 |
):
|
| 59 |
assistant = create_assistant(model_name)
|
| 60 |
|
| 61 |
-
# Get prompt template
|
| 62 |
prompt_template: PromptTemplate = prompts[PROMPT_STRATEGIES[prompt_strategy]]
|
|
|
|
| 63 |
|
| 64 |
-
#
|
| 65 |
-
formatted_system_message =
|
| 66 |
|
| 67 |
# Prepare messages
|
| 68 |
messages = [{"role": "system", "content": formatted_system_message}]
|
|
@@ -102,10 +102,6 @@ with gr.Blocks() as demo:
|
|
| 102 |
value=list(PROMPT_STRATEGIES.keys())[0],
|
| 103 |
label="Select Prompt Strategy"
|
| 104 |
)
|
| 105 |
-
system_message = gr.Textbox(
|
| 106 |
-
value="You are a friendly and helpful AI assistant.",
|
| 107 |
-
label="System Message"
|
| 108 |
-
)
|
| 109 |
|
| 110 |
with gr.Row():
|
| 111 |
override_params = gr.Checkbox(
|
|
@@ -142,7 +138,6 @@ with gr.Blocks() as demo:
|
|
| 142 |
additional_inputs=[
|
| 143 |
model_dropdown,
|
| 144 |
prompt_strategy_dropdown,
|
| 145 |
-
system_message,
|
| 146 |
override_params,
|
| 147 |
max_tokens,
|
| 148 |
temperature,
|
|
|
|
| 50 |
history: list[tuple[str, str]],
|
| 51 |
model_name,
|
| 52 |
prompt_strategy,
|
|
|
|
| 53 |
override_params: bool,
|
| 54 |
max_tokens,
|
| 55 |
temperature,
|
|
|
|
| 57 |
):
|
| 58 |
assistant = create_assistant(model_name)
|
| 59 |
|
| 60 |
+
# Get selected prompt template and system context
|
| 61 |
prompt_template: PromptTemplate = prompts[PROMPT_STRATEGIES[prompt_strategy]]
|
| 62 |
+
system_context: PromptTemplate = prompts["system_context"]
|
| 63 |
|
| 64 |
+
# Format system context with the selected prompt strategy
|
| 65 |
+
formatted_system_message = system_context.format(prompt_strategy=prompt_template.template)
|
| 66 |
|
| 67 |
# Prepare messages
|
| 68 |
messages = [{"role": "system", "content": formatted_system_message}]
|
|
|
|
| 102 |
value=list(PROMPT_STRATEGIES.keys())[0],
|
| 103 |
label="Select Prompt Strategy"
|
| 104 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
with gr.Row():
|
| 107 |
override_params = gr.Checkbox(
|
|
|
|
| 138 |
additional_inputs=[
|
| 139 |
model_dropdown,
|
| 140 |
prompt_strategy_dropdown,
|
|
|
|
| 141 |
override_params,
|
| 142 |
max_tokens,
|
| 143 |
temperature,
|