Create ai_generator.py
Browse files- ai_generator.py +17 -0
ai_generator.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
|
3 |
+
# Load the Hugging Face pipeline for text generation
|
4 |
+
|
5 |
+
pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-1B")
|
6 |
+
|
7 |
+
|
8 |
+
|
9 |
+
def generate_content(topic: str):
|
10 |
+
"""Generate AI content using Hugging Face pipeline."""
|
11 |
+
prompt = f"Create a detailed and engaging YouTube script about: {topic}"
|
12 |
+
|
13 |
+
# Generate content
|
14 |
+
generated_text = generator(prompt, max_length=500, num_return_sequences=1, temperature=0.7, top_p=0.9)
|
15 |
+
|
16 |
+
# Extract the generated text (it's a list of dicts)
|
17 |
+
return generated_text[0]['generated_text']
|