File size: 826 Bytes
4ed95aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
import openai
from typing import Dict, List
from pydantic import BaseModel, Field
from utils.summarizer import get_analyze_result
from utils.extractor import get_html_text
from workcell.integrations.types import MarkdownMixin


class Input(BaseModel):
    url: str = Field(default="https://openai.com/blog/introducing-chatgpt-and-whisper-apis", description="An url string which you want to analyze automatically.")

def analyze_url(input: Input) -> MarkdownMixin:
    """Returns a thought provoking discussion questions from url provided, generated by OpenAI GPT3 API."""
    openai.api_key = os.getenv('SECRET_OPENAI_WORKCELL_WEBPAGE_QA')
    # return summarization
    text = get_html_text(input.url)
    markdown = get_analyze_result(text)
    output = MarkdownMixin(
        data=markdown
    )
    return output