Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -45,13 +45,22 @@ class PromptRefiner:
|
|
45 |
{"role": "system", "content": 'You are an expert at refining and extending prompts. Given a basic prompt, provide a more detailed.'},
|
46 |
{"role": "user", "content": selected_meta_prompt.replace("[Insert initial prompt here]", prompt_input.text)}
|
47 |
]
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
try:
|
56 |
json_match = re.search(r'<json>\s*(.*?)\s*</json>', response_content, re.DOTALL)
|
57 |
if json_match:
|
|
|
45 |
{"role": "system", "content": 'You are an expert at refining and extending prompts. Given a basic prompt, provide a more detailed.'},
|
46 |
{"role": "user", "content": selected_meta_prompt.replace("[Insert initial prompt here]", prompt_input.text)}
|
47 |
]
|
48 |
+
try:
|
49 |
+
response = self.client.chat_completion(
|
50 |
+
model=prompt_refiner_model,
|
51 |
+
messages=messages,
|
52 |
+
max_tokens=2000,
|
53 |
+
temperature=0.8
|
54 |
+
)
|
55 |
+
response_content = response.choices[0].message.content.strip()
|
56 |
+
except HfHubHTTPError as e:
|
57 |
+
return (
|
58 |
+
"Error: Model timeout. Please try a smaller model or try again later.",
|
59 |
+
"",
|
60 |
+
"The selected model is currently experiencing high traffic.",
|
61 |
+
{}
|
62 |
+
)
|
63 |
+
|
64 |
try:
|
65 |
json_match = re.search(r'<json>\s*(.*?)\s*</json>', response_content, re.DOTALL)
|
66 |
if json_match:
|