Alwrity - WIP - main_config
This commit is contained in:
@@ -1,12 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv(Path('../.env'))
|
||||
|
||||
from ..gpt_providers.openai_text_gen import openai_chatgpt
|
||||
from ..gpt_providers.gemini_pro_text import gemini_text_response
|
||||
|
||||
from loguru import logger
|
||||
logger.remove()
|
||||
@@ -15,41 +9,34 @@ logger.add(sys.stdout,
|
||||
format="<level>{level}</level>|<green>{file}:{line}:{function}</green>| {message}"
|
||||
)
|
||||
|
||||
from ..gpt_providers.text_generation.main_text_generation import llm_text_gen
|
||||
|
||||
|
||||
# FIXME: Provide num_blogs, num_faqs as inputs.
|
||||
def write_blog_google_serp(search_keyword, search_results):
|
||||
"""Combine the given online research and gpt blog content"""
|
||||
gpt_providers = os.environ["GPT_PROVIDER"]
|
||||
prompt = f"""
|
||||
As a SEO expert and content writer, I will provide you with my 'web research keywords' and its 'google search result'.
|
||||
Your task is to write an original, conversational, SEO optimized blog and also 5 FAQs.
|
||||
Your goal is to create SEO-optimized content and also include 5 FAQs.
|
||||
|
||||
Follow below guidelines:
|
||||
1). Your blog content should compete against all blogs from search results.
|
||||
2). Your FAQ should be based on 'People also ask' and 'Related Queries' from given search result.
|
||||
Always include answers for each FAQ, use your knowledge and confirm with snippets given in search result.
|
||||
3). Your blog should be highly detailed, unique and written in human-like personality & tone.
|
||||
4). Act as subject matter expert for given research keywords and include statistics and facts.
|
||||
5). Do not explain, describe your response.
|
||||
6). Important: Please read the entire prompt before writing anything, and do not do anything extra.
|
||||
Follow the prompt exactly as I instructed.
|
||||
4). Adopt an engaging, helpful voice, providing actionable and concrete insights, and avoiding buzzwords.
|
||||
5). Act as subject matter expert for given research keywords and include statistics and facts.
|
||||
6). Do not explain, describe your response.
|
||||
7). Your blog should be highly formatted in markdown style and highly readable.
|
||||
8). Important: Please read the entire prompt before writing anything. Follow the prompt exactly as I instructed.
|
||||
|
||||
\n\nWeb Research Keyword: "{search_keyword}"
|
||||
Google search Result: "{search_results}"
|
||||
"""
|
||||
logger.info("Generating blog and FAQs from Google web search results.")
|
||||
if 'google' in gpt_providers.lower():
|
||||
try:
|
||||
response = gemini_text_response(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
logger.error(f"Failed to get response from gemini: {err}")
|
||||
raise err
|
||||
elif 'openai' in gpt_providers.lower():
|
||||
try:
|
||||
logger.info("Calling OpenAI LLM.")
|
||||
response = openai_chatgpt(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
logger.error(f"Failed to get response from Openai: {err}")
|
||||
raise err
|
||||
try:
|
||||
response = llm_text_gen(prompt)
|
||||
return response
|
||||
except Exception as err:
|
||||
logger.error(f"Exit: Failed to get response from LLM: {err}")
|
||||
exit(1)
|
||||
|
||||
Reference in New Issue
Block a user