0xmrwn / automated-news-breakdown

Formatted string passed to logging module PYL-W1203
Performance
Minor
a year agoa year old
Use lazy % formatting in logging functions
29    """
30    openai.api_key = os.environ["OPENAI_API_KEY"]
31    context_len = len(input_text.split())
32    logging.info(f"Generating image with {context_len} tokens in instructions")33    dimensions = config["image_size"]
34    response = openai.Image.create(prompt=input_text, n=1, size=dimensions)
35    image_url = response["data"][0]["url"]
Use lazy % formatting in logging functions
 29        logging.warning("Text contents not located with Newspaper3k")
 30        parsed_data = manual_scraping(url)
 31    content_len = len(str(parsed_data["text"]).split())
 32    logging.info(f"Extracted {content_len} tokens from URL") 33    return parsed_data
 34
 35
Use lazy % formatting in logging functions
22    completion. The function returns the generated completion as a string.
23    """
24    openai.api_key = os.environ["OPENAI_API_KEY"]
25    logging.info(f"Requesting OpenAI for {command}")26    model = config["completions_engine"]
27    template_prompt, max_t, temp = (
28        config["prompts"][command]["prompt"],
Use lazy % formatting in logging functions
43    logging.info("Completion status: Success")
44    logging.info(f"Usage: {usage['total_tokens']} tokens")
45    logging.info(f"Prompt: {usage['prompt_tokens']} tokens")
46    logging.info(f"Completion: {usage['completion_tokens']} tokens")47    return top_completion.text
Use lazy % formatting in logging functions
42    usage = completions["usage"]
43    logging.info("Completion status: Success")
44    logging.info(f"Usage: {usage['total_tokens']} tokens")
45    logging.info(f"Prompt: {usage['prompt_tokens']} tokens")46    logging.info(f"Completion: {usage['completion_tokens']} tokens")
47    return top_completion.text