Spaces:
Sleeping
Sleeping
Update agents.py
Browse files
agents.py
CHANGED
|
@@ -1,82 +1,105 @@
|
|
| 1 |
-
from langchain_openai import ChatOpenAI
|
| 2 |
-
from langchain.schema import HumanMessage, SystemMessage
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from langchain_openai import ChatOpenAI
|
| 2 |
+
from langchain.schema import HumanMessage, SystemMessage
|
| 3 |
+
from langchain_groq import ChatGroq
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def web_summarizer_company(scraped_data):
|
| 7 |
+
|
| 8 |
+
AI71_BASE_URL = "https://api.ai71.ai/v1/"
|
| 9 |
+
AI71_API_KEY = 'ai71-api-f65e97e6-af86-4de9-a667-dc61c1ef8c75'
|
| 10 |
+
|
| 11 |
+
llm = ChatOpenAI(
|
| 12 |
+
model="tiiuae/falcon-180b-chat",
|
| 13 |
+
api_key=AI71_API_KEY,
|
| 14 |
+
base_url=AI71_BASE_URL,
|
| 15 |
+
# streaming=True,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
summary = llm.invoke(
|
| 19 |
+
[
|
| 20 |
+
SystemMessage(content="You are a Web Data Summarizer. you are skilled at summarizing company webpages into short summaries. "),
|
| 21 |
+
HumanMessage(content=f"provide a neet summary of the company. Do not add up things. \n\n**Scraped Data:** \n\n{scraped_data}"),
|
| 22 |
+
]
|
| 23 |
+
)
|
| 24 |
+
return summary
|
| 25 |
+
|
| 26 |
+
def web_summarizer_person(scraped_data):
|
| 27 |
+
|
| 28 |
+
AI71_BASE_URL = "https://api.ai71.ai/v1/"
|
| 29 |
+
AI71_API_KEY = 'ai71-api-f65e97e6-af86-4de9-a667-dc61c1ef8c75'
|
| 30 |
+
|
| 31 |
+
llm = ChatOpenAI(
|
| 32 |
+
model="tiiuae/falcon-180b-chat",
|
| 33 |
+
api_key=AI71_API_KEY,
|
| 34 |
+
base_url=AI71_BASE_URL,
|
| 35 |
+
# streaming=True,
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
summary = llm.invoke(
|
| 39 |
+
[
|
| 40 |
+
SystemMessage(content="You are a Web Data Summarizer. you are skilled at summarizing complex webpages into short summaries. "),
|
| 41 |
+
HumanMessage(content=f"provide a neet summary of the youself. Do not add up things. \n\n**Scraped Data from your portfolio:** \n\n{scraped_data}"),
|
| 42 |
+
]
|
| 43 |
+
)
|
| 44 |
+
return summary
|
| 45 |
+
|
| 46 |
+
def person_linkedin_agent(topic, summary, mood):
|
| 47 |
+
|
| 48 |
+
AI71_BASE_URL = "https://api.ai71.ai/v1/"
|
| 49 |
+
AI71_API_KEY = 'ai71-api-f65e97e6-af86-4de9-a667-dc61c1ef8c75'
|
| 50 |
+
|
| 51 |
+
llm = ChatOpenAI(
|
| 52 |
+
model="tiiuae/falcon-180b-chat",
|
| 53 |
+
api_key=AI71_API_KEY,
|
| 54 |
+
base_url=AI71_BASE_URL,
|
| 55 |
+
# streaming=True,
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
blog = llm.invoke(
|
| 59 |
+
[
|
| 60 |
+
SystemMessage(content=f"Your details are given below: \n\n{summary}"),
|
| 61 |
+
HumanMessage(content=f"Write a LinkedIn post on the topic: {topic}. Mention your details in the post. Add symbols and emojis to make the post attractive. "),
|
| 62 |
+
]
|
| 63 |
+
)
|
| 64 |
+
return blog
|
| 65 |
+
|
| 66 |
+
def company_linkedin_agent(topic, summary, mood):
|
| 67 |
+
|
| 68 |
+
AI71_BASE_URL = "https://api.ai71.ai/v1/"
|
| 69 |
+
AI71_API_KEY = 'ai71-api-f65e97e6-af86-4de9-a667-dc61c1ef8c75'
|
| 70 |
+
|
| 71 |
+
llm = ChatOpenAI(
|
| 72 |
+
model="tiiuae/falcon-180b-chat",
|
| 73 |
+
api_key=AI71_API_KEY,
|
| 74 |
+
base_url=AI71_BASE_URL,
|
| 75 |
+
# streaming=True,
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
blog = llm.invoke(
|
| 79 |
+
[
|
| 80 |
+
SystemMessage(content=f"You are a content Writer. You write content in {mood} way. You also add symbols, emojis to make the content attractive."),
|
| 81 |
+
HumanMessage(content=f"Write a LinkedIn post on the topic: {topic}.\n\nThe post is for the company mentioned below.\n\n{summary}"),
|
| 82 |
+
]
|
| 83 |
+
)
|
| 84 |
+
return blog
|
| 85 |
+
|
| 86 |
+
def image_prompt_agent(post):
|
| 87 |
+
|
| 88 |
+
llm = ChatGroq(model="llama3-70b-8192", api_key='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')
|
| 89 |
+
# AI71_BASE_URL = "https://api.ai71.ai/v1/"
|
| 90 |
+
# AI71_API_KEY = 'ai71-api-f65e97e6-af86-4de9-a667-dc61c1ef8c75'
|
| 91 |
+
|
| 92 |
+
# llm = ChatOpenAI(
|
| 93 |
+
# model="tiiuae/falcon-180b-chat",
|
| 94 |
+
# api_key=AI71_API_KEY,
|
| 95 |
+
# base_url=AI71_BASE_URL,
|
| 96 |
+
# # streaming=True,
|
| 97 |
+
# )
|
| 98 |
+
|
| 99 |
+
blog = llm.invoke("write descriptive prompt for used in LinkedIn post. "
|
| 100 |
+
"Prompt is 'What you wish to see in the output image'. "
|
| 101 |
+
"A descriptive prompt that clearly defines elements, colors, and subjects will lead to better results. "
|
| 102 |
+
"For example: The sky was a crisp (blue:0.3) and (green:0.8) would convey a sky that was blue and green, but more green than blue. The weight applies to all words in the prompt. ",
|
| 103 |
+
"Output only the prompt"
|
| 104 |
+
f"**LinkedIn post**: {post}")
|
| 105 |
+
return blog
|