Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,6 @@ import openai
|
|
| 11 |
api = HfApi()
|
| 12 |
token = os.getenv("token")
|
| 13 |
tokenread = os.getenv("tokenread")
|
| 14 |
-
api_key = os.getenv("OPENAI_API_KEY")
|
| 15 |
localdir = "HeadlinePrediction"
|
| 16 |
|
| 17 |
repo = Repository(local_dir=localdir, clone_from="https://huggingface.co/spaces/Add1E/HeadlinePrediction", token=token)
|
|
@@ -45,13 +44,16 @@ def scrape_website(url):
|
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
-
def send_to_chatgpt(
|
| 49 |
try:
|
| 50 |
# Liest den Prompt aus der Datei
|
| 51 |
with open(prompt_file, 'r', encoding='utf-8') as file:
|
| 52 |
prompt = file.read().strip()
|
| 53 |
|
| 54 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
|
|
|
|
|
|
|
|
|
| 55 |
response = openai.ChatCompletion.create(
|
| 56 |
model="gpt-4-1106-preview",
|
| 57 |
messages=[
|
|
@@ -75,7 +77,7 @@ url = st.text_input("URL eingeben", "https://www.beispielwebsite.com")
|
|
| 75 |
if st.button("Scrape"):
|
| 76 |
if url:
|
| 77 |
scraped_html = scrape_website(url)
|
| 78 |
-
response = send_to_chatgpt(
|
| 79 |
st.write("Heute-Überschrift: ")
|
| 80 |
st.code(scraped_html['heute_überschrift'])
|
| 81 |
st.write("Heute-Kernaussage: ")
|
|
|
|
| 11 |
api = HfApi()
|
| 12 |
token = os.getenv("token")
|
| 13 |
tokenread = os.getenv("tokenread")
|
|
|
|
| 14 |
localdir = "HeadlinePrediction"
|
| 15 |
|
| 16 |
repo = Repository(local_dir=localdir, clone_from="https://huggingface.co/spaces/Add1E/HeadlinePrediction", token=token)
|
|
|
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
+
def send_to_chatgpt(prompt_file, transcript):
|
| 48 |
try:
|
| 49 |
# Liest den Prompt aus der Datei
|
| 50 |
with open(prompt_file, 'r', encoding='utf-8') as file:
|
| 51 |
prompt = file.read().strip()
|
| 52 |
|
| 53 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 54 |
+
openai.api_base = os.getenv("OPENAI_API_BASE")
|
| 55 |
+
openai.api_type = os.getenv("OPENAI_API_TYPE")
|
| 56 |
+
openai.api_version = os.getenv("OPENAI_API_VERSION")
|
| 57 |
response = openai.ChatCompletion.create(
|
| 58 |
model="gpt-4-1106-preview",
|
| 59 |
messages=[
|
|
|
|
| 77 |
if st.button("Scrape"):
|
| 78 |
if url:
|
| 79 |
scraped_html = scrape_website(url)
|
| 80 |
+
response = send_to_chatgpt(base_prompt, scraped_html['scraped_html'])
|
| 81 |
st.write("Heute-Überschrift: ")
|
| 82 |
st.code(scraped_html['heute_überschrift'])
|
| 83 |
st.write("Heute-Kernaussage: ")
|