Update content_generation.py
Browse files- content_generation.py +7 -5
content_generation.py
CHANGED
|
@@ -113,8 +113,9 @@ def extract_key_contents(script, num_contents=30):
|
|
| 113 |
Trích xuất các ý chính từ script.
|
| 114 |
"""
|
| 115 |
try:
|
| 116 |
-
|
| 117 |
-
|
|
|
|
| 118 |
messages=[
|
| 119 |
{"role": "system", "content": f"Bạn là một chuyên gia phân tích nội dung. Hãy trích xuất chính xác {num_contents} ý chính quan trọng nhất từ đoạn văn sau, mỗi ý không quá 20 từ."},
|
| 120 |
{"role": "user", "content": script}
|
|
@@ -122,7 +123,7 @@ def extract_key_contents(script, num_contents=30):
|
|
| 122 |
)
|
| 123 |
|
| 124 |
# In response để kiểm tra
|
| 125 |
-
print("Response
|
| 126 |
|
| 127 |
key_contents = response.choices[0].message.content.split('\n')
|
| 128 |
return key_contents[:num_contents]
|
|
@@ -135,8 +136,9 @@ def generate_image_prompt(content):
|
|
| 135 |
Tạo prompt cho hình ảnh từ nội dung.
|
| 136 |
"""
|
| 137 |
try:
|
| 138 |
-
|
| 139 |
-
|
|
|
|
| 140 |
messages=[
|
| 141 |
{"role": "system", "content": "You are an expert at creating prompts for AI image generation. Create a short, concise prompt in English to visually describe the following content. The content may be in Vietnamese, but your prompt should always be in English."},
|
| 142 |
{"role": "user", "content": content}
|
|
|
|
| 113 |
Trích xuất các ý chính từ script.
|
| 114 |
"""
|
| 115 |
try:
|
| 116 |
+
client = Groq(api_key=GROQ_API_KEY)
|
| 117 |
+
chat_completion = client.chat.completions.create(
|
| 118 |
+
model="mixtral-8x7b-32768",
|
| 119 |
messages=[
|
| 120 |
{"role": "system", "content": f"Bạn là một chuyên gia phân tích nội dung. Hãy trích xuất chính xác {num_contents} ý chính quan trọng nhất từ đoạn văn sau, mỗi ý không quá 20 từ."},
|
| 121 |
{"role": "user", "content": script}
|
|
|
|
| 123 |
)
|
| 124 |
|
| 125 |
# In response để kiểm tra
|
| 126 |
+
print("Response:", response)
|
| 127 |
|
| 128 |
key_contents = response.choices[0].message.content.split('\n')
|
| 129 |
return key_contents[:num_contents]
|
|
|
|
| 136 |
Tạo prompt cho hình ảnh từ nội dung.
|
| 137 |
"""
|
| 138 |
try:
|
| 139 |
+
client = Groq(api_key=GROQ_API_KEY)
|
| 140 |
+
chat_completion = client.chat.completions.create(
|
| 141 |
+
model="mixtral-8x7b-32768",
|
| 142 |
messages=[
|
| 143 |
{"role": "system", "content": "You are an expert at creating prompts for AI image generation. Create a short, concise prompt in English to visually describe the following content. The content may be in Vietnamese, but your prompt should always be in English."},
|
| 144 |
{"role": "user", "content": content}
|