alphayomega commited on
Commit
d4aab4a
1 Parent(s): e7932d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -18
app.py CHANGED
@@ -12,25 +12,20 @@ class ConversationalAI:
12
  "content": "# I want you to act as a content marketing consultant. # I will provide you with a person who will give you the name of a product or service for you to generate content marketing publications in Spanish with attractive emojis that motivate the reader to learn more about [product] through tips, guides and useful suggestions. # You must use your knowledge of Content Marketing that must be inspiring, completely focused on bringing value to the reader without direct or indirect advertising. # Generate long content, at least 5 short relevant paragraphs. Check that the previous content is not repeated. # Generate content with paragraphs between 10 and 20 words. Check that previous content is not repeated. # Use attractive emojis and titles such as: \"The 5 best tricks for [action]\". \"The ultimate beginner\'s guide to [topic].\" \"Want [result]? I show you how to achieve it in 5 steps.\" # Use practical tips such as: \"With these 5 tips you\'ll get [result].\" \"Five innovative ways to use [product] in your daily life.\" # Educational content: \"The most common mistakes and how to avoid them.\" \"Myths and truths about [topic].\" \"The latest trends you need to know about.\" # Testimonials and examples that connect emotionally: \"Here's what I learned when I started using [product]\" \"Stories of real users who solved [problem]\" # Generate content focused on solving doubts and adding value, NOT direct sales. Surprise me with your best ideas! #IMPORTANT: Always answers in AMERICAN SPANISH. "
13
  }
14
 
15
- async def chat_groq(self, message, history):
16
  messages = [self.system_prompt]
17
-
18
  for msg in history:
19
  messages.append({"role": "user", "content": str(msg[0])})
20
  messages.append({"role": "assistant", "content": str(msg[1])})
21
-
22
  messages.append({"role": "user", "content": str(message)})
23
-
24
  response_content = ''
25
-
26
  stream = self.client.chat.completions.create(
27
- model="llama3-70b-8192",
28
- messages=messages,
29
- max_tokens=1024,
30
- temperature=1.3,
31
- stream=True
32
- )
33
-
34
  for chunk in stream:
35
  content = chunk.choices[0].delta.content
36
  if content:
@@ -39,15 +34,27 @@ class ConversationalAI:
39
 
40
  def create_chat_interface(self):
41
  with gr.Blocks(theme=gr.themes.Monochrome(), fill_height=True) as demo:
42
- gr.ChatInterface(self.chat_groq,
43
- clear_btn=None,
44
- undo_btn=None,
45
- retry_btn=None,
46
- )
 
 
 
 
 
 
 
 
47
  return demo
48
 
49
  if __name__ == "__main__":
50
  ai = ConversationalAI()
51
  demo = ai.create_chat_interface()
52
  demo.queue()
53
- demo.launch()
 
 
 
 
 
12
  "content": "# I want you to act as a content marketing consultant. # I will provide you with a person who will give you the name of a product or service for you to generate content marketing publications in Spanish with attractive emojis that motivate the reader to learn more about [product] through tips, guides and useful suggestions. # You must use your knowledge of Content Marketing that must be inspiring, completely focused on bringing value to the reader without direct or indirect advertising. # Generate long content, at least 5 short relevant paragraphs. Check that the previous content is not repeated. # Generate content with paragraphs between 10 and 20 words. Check that previous content is not repeated. # Use attractive emojis and titles such as: \"The 5 best tricks for [action]\". \"The ultimate beginner\'s guide to [topic].\" \"Want [result]? I show you how to achieve it in 5 steps.\" # Use practical tips such as: \"With these 5 tips you\'ll get [result].\" \"Five innovative ways to use [product] in your daily life.\" # Educational content: \"The most common mistakes and how to avoid them.\" \"Myths and truths about [topic].\" \"The latest trends you need to know about.\" # Testimonials and examples that connect emotionally: \"Here's what I learned when I started using [product]\" \"Stories of real users who solved [problem]\" # Generate content focused on solving doubts and adding value, NOT direct sales. Surprise me with your best ideas! #IMPORTANT: Always answers in AMERICAN SPANISH. "
13
  }
14
 
15
+ async def generate(self, message, history):
16
  messages = [self.system_prompt]
 
17
  for msg in history:
18
  messages.append({"role": "user", "content": str(msg[0])})
19
  messages.append({"role": "assistant", "content": str(msg[1])})
 
20
  messages.append({"role": "user", "content": str(message)})
 
21
  response_content = ''
 
22
  stream = self.client.chat.completions.create(
23
+ model="llama3-70b-8192",
24
+ messages=messages,
25
+ max_tokens=1024,
26
+ temperature=1.3,
27
+ stream=True
28
+ )
 
29
  for chunk in stream:
30
  content = chunk.choices[0].delta.content
31
  if content:
 
34
 
35
  def create_chat_interface(self):
36
  with gr.Blocks(theme=gr.themes.Monochrome(), fill_height=True) as demo:
37
+ gr.ChatInterface(fn=self.generate,
38
+ chatbot="Bot de Marketing de Contenidos",
39
+ title="Bot con I.A. para crear MARKETING DE CONTENIDOS de productos.</p>",
40
+ description="<p style='line-height: 0.5'>Herramienta de apoyo para crear MARKETING DE CONTENIDOS para medios Electronicos.</p><br>"+
41
+ "<p style='line-height: 1'>Si desea usar otro BOT de I.A. escoja:</p>"+
42
+ " <a href='https://alphayomega-bot-mc.hf.space'>Marketing de Contenidos |</a> "+
43
+ " <a href='https://alphayomega-bot-tit.hf.space'> Creacion de TITULOS |</a> "+
44
+ " <a href='https://alphayomega-bot-dp.hf.space'> Descripcion de Productos |</a>"+
45
+ " <a href='https://alphayomega-bot-cp.hf.space'> Caracteristicas de Productos |</a> "+
46
+ " <a href='https://wa.me/51927929109'> Desarrollado por MAGNET IMPACT - Agencia de Marketing Digital </a>",
47
+ retry_btn=None,
48
+ undo_btn=None
49
+ )
50
  return demo
51
 
52
  if __name__ == "__main__":
53
  ai = ConversationalAI()
54
  demo = ai.create_chat_interface()
55
  demo.queue()
56
+ demo.launch(show_api=False)
57
+
58
+ # Obtener y mostrar URL
59
+ url = demo.url
60
+ print("URL del chatbot: ", url)