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