Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,14 +49,19 @@ def search_reviews(df_original, product_description, without_newlines=False, n=1
|
|
| 49 |
def generate_response(text, model, temperature, top_p):
|
| 50 |
reference = search_reviews(data, text, without_newlines=True)["Content"][0]
|
| 51 |
|
| 52 |
-
completion = client.completions.create(
|
| 53 |
-
|
| 54 |
-
prompt=f"Rewrite the following text while ensuring logical composition and avoiding over-exaggeration or imaginative elements: {reference}\n\n{text}",
|
| 55 |
temperature=temperature,
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
)
|
| 59 |
-
result = completion.choices[0].
|
| 60 |
return result
|
| 61 |
|
| 62 |
# Создаём интерфейс Gradio
|
|
|
|
| 49 |
def generate_response(text, model, temperature, top_p):
|
| 50 |
reference = search_reviews(data, text, without_newlines=True)["Content"][0]
|
| 51 |
|
| 52 |
+
completion = client.chat.completions.create(
|
| 53 |
+
model=model,
|
|
|
|
| 54 |
temperature=temperature,
|
| 55 |
+
top_p=top_p,
|
| 56 |
+
messages=[
|
| 57 |
+
{
|
| 58 |
+
"role": "system",
|
| 59 |
+
"content": f"Generate high-quality rewritten articles, ensuring logical composition, avoiding over-exaggeration, and refraining from any imaginative elements. Use the provided sample text as a reference for the desired writing style:{reference}",
|
| 60 |
+
},
|
| 61 |
+
{"role": "user", "content": f"{text}"},
|
| 62 |
+
],
|
| 63 |
)
|
| 64 |
+
result = completion.choices[0].message.content
|
| 65 |
return result
|
| 66 |
|
| 67 |
# Создаём интерфейс Gradio
|