Spaces:
Sleeping
Sleeping
Update agents.py
Browse files
agents.py
CHANGED
|
@@ -2,7 +2,6 @@ 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/"
|
|
@@ -21,6 +20,11 @@ def web_summarizer_company(scraped_data):
|
|
| 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):
|
|
@@ -35,12 +39,17 @@ def web_summarizer_person(scraped_data):
|
|
| 35 |
# streaming=True,
|
| 36 |
)
|
| 37 |
|
| 38 |
-
summary = llm.invoke(
|
| 39 |
-
[
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
]
|
| 43 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
return summary
|
| 45 |
|
| 46 |
def person_linkedin_agent(topic, summary, mood):
|
|
@@ -55,12 +64,15 @@ def person_linkedin_agent(topic, summary, mood):
|
|
| 55 |
# streaming=True,
|
| 56 |
)
|
| 57 |
|
| 58 |
-
blog = llm.invoke(
|
| 59 |
-
[
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
]
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
| 64 |
return blog
|
| 65 |
|
| 66 |
def company_linkedin_agent(topic, summary, mood):
|
|
@@ -75,12 +87,15 @@ def company_linkedin_agent(topic, summary, mood):
|
|
| 75 |
# streaming=True,
|
| 76 |
)
|
| 77 |
|
| 78 |
-
blog = llm.invoke(
|
| 79 |
-
[
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
]
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
| 84 |
return blog
|
| 85 |
|
| 86 |
def image_prompt_agent(post):
|
|
@@ -96,11 +111,146 @@ def image_prompt_agent(post):
|
|
| 96 |
# # streaming=True,
|
| 97 |
# )
|
| 98 |
|
| 99 |
-
|
| 100 |
-
|
| 101 |
Prompt is 'What you wish to see in the output image'.
|
| 102 |
A descriptive prompt that clearly defines elements, colors, and subjects will lead to better results.
|
| 103 |
-
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. ,
|
| 104 |
-
Output only the prompt.
|
| 105 |
-
f**LinkedIn post**: {post}""")
|
| 106 |
return blog
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
from langchain.schema import HumanMessage, SystemMessage
|
| 3 |
from langchain_groq import ChatGroq
|
| 4 |
|
|
|
|
| 5 |
def web_summarizer_company(scraped_data):
|
| 6 |
|
| 7 |
AI71_BASE_URL = "https://api.ai71.ai/v1/"
|
|
|
|
| 20 |
HumanMessage(content=f"provide a neet summary of the company. Do not add up things. \n\n**Scraped Data:** \n\n{scraped_data}"),
|
| 21 |
]
|
| 22 |
)
|
| 23 |
+
|
| 24 |
+
# summary = llm.invoke("provide a neet summary of the company. "
|
| 25 |
+
# f"**Scraped Data from company web page: **{scraped_data} "
|
| 26 |
+
# "Do not add up things. ")
|
| 27 |
+
|
| 28 |
return summary
|
| 29 |
|
| 30 |
def web_summarizer_person(scraped_data):
|
|
|
|
| 39 |
# streaming=True,
|
| 40 |
)
|
| 41 |
|
| 42 |
+
# summary = llm.invoke(
|
| 43 |
+
# [
|
| 44 |
+
# SystemMessage(content="You are a Web Data Summarizer. you are skilled at summarizing complex webpages into short summaries. "),
|
| 45 |
+
# 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}"),
|
| 46 |
+
# ]
|
| 47 |
+
# )
|
| 48 |
+
|
| 49 |
+
summary = llm.invoke("Given scraped data from your personal website, provide a neet summary of the yourself. "
|
| 50 |
+
f"**Scraped Data: **{scraped_data} \n\n"
|
| 51 |
+
"The output should not contain sentences like 'i am not capable...', 'As an AI language model...', etc. "
|
| 52 |
+
"If unable to provide summary, then output 'summary not available.'")
|
| 53 |
return summary
|
| 54 |
|
| 55 |
def person_linkedin_agent(topic, summary, mood):
|
|
|
|
| 64 |
# streaming=True,
|
| 65 |
)
|
| 66 |
|
| 67 |
+
# blog = llm.invoke(
|
| 68 |
+
# [
|
| 69 |
+
# SystemMessage(content=f"Your details are given below: \n\n{summary}"),
|
| 70 |
+
# 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. "),
|
| 71 |
+
# ])
|
| 72 |
+
|
| 73 |
+
blog = llm.invoke(f"You are not AI Language Model, you are: {summary}\n "
|
| 74 |
+
f"Write a {mood} LinkedIn post for youself on the topic: {topic} "
|
| 75 |
+
"Add symbols and emojis to make the post attractive.")
|
| 76 |
return blog
|
| 77 |
|
| 78 |
def company_linkedin_agent(topic, summary, mood):
|
|
|
|
| 87 |
# streaming=True,
|
| 88 |
)
|
| 89 |
|
| 90 |
+
# blog = llm.invoke(
|
| 91 |
+
# [
|
| 92 |
+
# SystemMessage(content=f"You are a content Writer. You write content in {mood} way. You also add symbols, emojis to make the content attractive."),
|
| 93 |
+
# HumanMessage(content=f"Write a LinkedIn post on the topic: {topic}.\n\nThe post is for the company mentioned below.\n\n{summary}"),
|
| 94 |
+
# ])
|
| 95 |
+
blog = llm.invoke(f"You are not AI Language Model, you work for the company: {summary}\n "
|
| 96 |
+
f"Write a {mood} LinkedIn post on the topic: {topic}. for the company"
|
| 97 |
+
"Add symbols, emojis to make the post attractive.")
|
| 98 |
+
|
| 99 |
return blog
|
| 100 |
|
| 101 |
def image_prompt_agent(post):
|
|
|
|
| 111 |
# # streaming=True,
|
| 112 |
# )
|
| 113 |
|
| 114 |
+
blog = llm.invoke(f"""write image generation prompt for the below LinkedIn post.
|
| 115 |
+
**LinkedIn post**: \n{post} \n
|
| 116 |
Prompt is 'What you wish to see in the output image'.
|
| 117 |
A descriptive prompt that clearly defines elements, colors, and subjects will lead to better results.
|
| 118 |
+
For example: 'The (sky:0.5) 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. ,
|
| 119 |
+
Output only the prompt, no additional text.""")
|
|
|
|
| 120 |
return blog
|
| 121 |
+
|
| 122 |
+
def tweet_agent(topic, instructions, mood):
|
| 123 |
+
|
| 124 |
+
AI71_BASE_URL = "https://api.ai71.ai/v1/"
|
| 125 |
+
AI71_API_KEY = 'ai71-api-f65e97e6-af86-4de9-a667-dc61c1ef8c75'
|
| 126 |
+
|
| 127 |
+
llm = ChatOpenAI(
|
| 128 |
+
model="tiiuae/falcon-180b-chat",
|
| 129 |
+
api_key=AI71_API_KEY,
|
| 130 |
+
base_url=AI71_BASE_URL,
|
| 131 |
+
# streaming=True,
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
tweet = llm.invoke(f"""write a {mood} twitter tweet on the topic: {topic}.
|
| 135 |
+
Follow below instructions: \n\n{instructions}""")
|
| 136 |
+
return tweet
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
# from langchain_openai import ChatOpenAI
|
| 152 |
+
# from langchain.schema import HumanMessage, SystemMessage
|
| 153 |
+
# from langchain_groq import ChatGroq
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
# def web_summarizer_company(scraped_data):
|
| 157 |
+
|
| 158 |
+
# AI71_BASE_URL = "https://api.ai71.ai/v1/"
|
| 159 |
+
# AI71_API_KEY = 'ai71-api-f65e97e6-af86-4de9-a667-dc61c1ef8c75'
|
| 160 |
+
|
| 161 |
+
# llm = ChatOpenAI(
|
| 162 |
+
# model="tiiuae/falcon-180b-chat",
|
| 163 |
+
# api_key=AI71_API_KEY,
|
| 164 |
+
# base_url=AI71_BASE_URL,
|
| 165 |
+
# # streaming=True,
|
| 166 |
+
# )
|
| 167 |
+
|
| 168 |
+
# summary = llm.invoke(
|
| 169 |
+
# [
|
| 170 |
+
# SystemMessage(content="You are a Web Data Summarizer. you are skilled at summarizing company webpages into short summaries. "),
|
| 171 |
+
# HumanMessage(content=f"provide a neet summary of the company. Do not add up things. \n\n**Scraped Data:** \n\n{scraped_data}"),
|
| 172 |
+
# ]
|
| 173 |
+
# )
|
| 174 |
+
# return summary
|
| 175 |
+
|
| 176 |
+
# def web_summarizer_person(scraped_data):
|
| 177 |
+
|
| 178 |
+
# AI71_BASE_URL = "https://api.ai71.ai/v1/"
|
| 179 |
+
# AI71_API_KEY = 'ai71-api-f65e97e6-af86-4de9-a667-dc61c1ef8c75'
|
| 180 |
+
|
| 181 |
+
# llm = ChatOpenAI(
|
| 182 |
+
# model="tiiuae/falcon-180b-chat",
|
| 183 |
+
# api_key=AI71_API_KEY,
|
| 184 |
+
# base_url=AI71_BASE_URL,
|
| 185 |
+
# # streaming=True,
|
| 186 |
+
# )
|
| 187 |
+
|
| 188 |
+
# summary = llm.invoke(
|
| 189 |
+
# [
|
| 190 |
+
# SystemMessage(content="You are a Web Data Summarizer. you are skilled at summarizing complex webpages into short summaries. "),
|
| 191 |
+
# 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}"),
|
| 192 |
+
# ]
|
| 193 |
+
# )
|
| 194 |
+
# return summary
|
| 195 |
+
|
| 196 |
+
# def person_linkedin_agent(topic, summary, mood):
|
| 197 |
+
|
| 198 |
+
# AI71_BASE_URL = "https://api.ai71.ai/v1/"
|
| 199 |
+
# AI71_API_KEY = 'ai71-api-f65e97e6-af86-4de9-a667-dc61c1ef8c75'
|
| 200 |
+
|
| 201 |
+
# llm = ChatOpenAI(
|
| 202 |
+
# model="tiiuae/falcon-180b-chat",
|
| 203 |
+
# api_key=AI71_API_KEY,
|
| 204 |
+
# base_url=AI71_BASE_URL,
|
| 205 |
+
# # streaming=True,
|
| 206 |
+
# )
|
| 207 |
+
|
| 208 |
+
# blog = llm.invoke(
|
| 209 |
+
# [
|
| 210 |
+
# SystemMessage(content=f"Your details are given below: \n\n{summary}"),
|
| 211 |
+
# 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. "),
|
| 212 |
+
# ]
|
| 213 |
+
# )
|
| 214 |
+
# return blog
|
| 215 |
+
|
| 216 |
+
# def company_linkedin_agent(topic, summary, mood):
|
| 217 |
+
|
| 218 |
+
# AI71_BASE_URL = "https://api.ai71.ai/v1/"
|
| 219 |
+
# AI71_API_KEY = 'ai71-api-f65e97e6-af86-4de9-a667-dc61c1ef8c75'
|
| 220 |
+
|
| 221 |
+
# llm = ChatOpenAI(
|
| 222 |
+
# model="tiiuae/falcon-180b-chat",
|
| 223 |
+
# api_key=AI71_API_KEY,
|
| 224 |
+
# base_url=AI71_BASE_URL,
|
| 225 |
+
# # streaming=True,
|
| 226 |
+
# )
|
| 227 |
+
|
| 228 |
+
# blog = llm.invoke(
|
| 229 |
+
# [
|
| 230 |
+
# SystemMessage(content=f"You are a content Writer. You write content in {mood} way. You also add symbols, emojis to make the content attractive."),
|
| 231 |
+
# HumanMessage(content=f"Write a LinkedIn post on the topic: {topic}.\n\nThe post is for the company mentioned below.\n\n{summary}"),
|
| 232 |
+
# ]
|
| 233 |
+
# )
|
| 234 |
+
# return blog
|
| 235 |
+
|
| 236 |
+
# def image_prompt_agent(post):
|
| 237 |
+
|
| 238 |
+
# llm = ChatGroq(model="llama3-70b-8192", api_key='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')
|
| 239 |
+
# # AI71_BASE_URL = "https://api.ai71.ai/v1/"
|
| 240 |
+
# # AI71_API_KEY = 'ai71-api-f65e97e6-af86-4de9-a667-dc61c1ef8c75'
|
| 241 |
+
|
| 242 |
+
# # llm = ChatOpenAI(
|
| 243 |
+
# # model="tiiuae/falcon-180b-chat",
|
| 244 |
+
# # api_key=AI71_API_KEY,
|
| 245 |
+
# # base_url=AI71_BASE_URL,
|
| 246 |
+
# # # streaming=True,
|
| 247 |
+
# # )
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
# blog = llm.invoke(f"""write descriptive prompt for used in LinkedIn post.
|
| 251 |
+
# Prompt is 'What you wish to see in the output image'.
|
| 252 |
+
# A descriptive prompt that clearly defines elements, colors, and subjects will lead to better results.
|
| 253 |
+
# 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. ,
|
| 254 |
+
# Output only the prompt.
|
| 255 |
+
# f**LinkedIn post**: {post}""")
|
| 256 |
+
# return blog
|