Spaces:
Runtime error
Runtime error
added db analytics
Browse files- app.py +30 -0
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,9 +1,12 @@
|
|
|
|
1 |
import hmac
|
2 |
import os
|
|
|
3 |
|
4 |
import openai
|
5 |
import requests
|
6 |
import streamlit as st
|
|
|
7 |
from bs4 import BeautifulSoup, NavigableString
|
8 |
from dotenv import load_dotenv
|
9 |
from st_copy_to_clipboard import st_copy_to_clipboard
|
@@ -265,6 +268,13 @@ def on_click_handler_generate_article(**kwargs):
|
|
265 |
kwargs["webpage_option"],
|
266 |
)
|
267 |
headline = create_headline(created_article, kwargs["webpage_option"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
st.session_state["generated_article"] = created_article
|
269 |
st.session_state["generated_headline"] = headline
|
270 |
if st.session_state["process_step"] < 3:
|
@@ -281,6 +291,13 @@ def on_click_handler_generate_generate_article_keywords(**kwargs):
|
|
281 |
kwargs["webpage_option"],
|
282 |
)
|
283 |
headline = create_headline(created_article, kwargs["webpage_option"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
st.session_state["generated_article"] = created_article
|
285 |
st.session_state["generated_headline"] = headline
|
286 |
|
@@ -315,6 +332,19 @@ if "webpage_option" not in st.session_state:
|
|
315 |
st.session_state["webpage_option"] = "Boulevard"
|
316 |
if "studie_links" not in st.session_state:
|
317 |
st.session_state["studie_links"] = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
|
319 |
PROCESS_STEPS = [
|
320 |
"Artikel Extraktion",
|
|
|
1 |
+
import datetime
|
2 |
import hmac
|
3 |
import os
|
4 |
+
import uuid
|
5 |
|
6 |
import openai
|
7 |
import requests
|
8 |
import streamlit as st
|
9 |
+
from azure.cosmos import ContainerProxy, CosmosClient
|
10 |
from bs4 import BeautifulSoup, NavigableString
|
11 |
from dotenv import load_dotenv
|
12 |
from st_copy_to_clipboard import st_copy_to_clipboard
|
|
|
268 |
kwargs["webpage_option"],
|
269 |
)
|
270 |
headline = create_headline(created_article, kwargs["webpage_option"])
|
271 |
+
db_analytics_item = {
|
272 |
+
"id": str(uuid.uuid4()),
|
273 |
+
"oparation": "article_generation",
|
274 |
+
"timestamp": str(datetime.datetime.now()),
|
275 |
+
}
|
276 |
+
client: ContainerProxy = st.session_state["db_container"]
|
277 |
+
client.create_item(body=db_analytics_item)
|
278 |
st.session_state["generated_article"] = created_article
|
279 |
st.session_state["generated_headline"] = headline
|
280 |
if st.session_state["process_step"] < 3:
|
|
|
291 |
kwargs["webpage_option"],
|
292 |
)
|
293 |
headline = create_headline(created_article, kwargs["webpage_option"])
|
294 |
+
db_analytics_item = {
|
295 |
+
"id": str(uuid.uuid4()),
|
296 |
+
"oparation": "article_generation",
|
297 |
+
"timestamp": str(datetime.datetime.now()),
|
298 |
+
}
|
299 |
+
client: ContainerProxy = st.session_state["db_container"]
|
300 |
+
client.create_item(body=db_analytics_item)
|
301 |
st.session_state["generated_article"] = created_article
|
302 |
st.session_state["generated_headline"] = headline
|
303 |
|
|
|
332 |
st.session_state["webpage_option"] = "Boulevard"
|
333 |
if "studie_links" not in st.session_state:
|
334 |
st.session_state["studie_links"] = []
|
335 |
+
if "db_container" not in st.session_state:
|
336 |
+
client = (
|
337 |
+
CosmosClient(os.environ["DB_ENDPOINT"], os.environ["DB_KEY"])
|
338 |
+
.get_database_client(os.environ["DB_NAME"])
|
339 |
+
.get_container_client("tina-analytics")
|
340 |
+
)
|
341 |
+
db_analytics_item = {
|
342 |
+
"id": str(uuid.uuid4()),
|
343 |
+
"oparation": "page_load",
|
344 |
+
"timestamp": str(datetime.datetime.now()),
|
345 |
+
}
|
346 |
+
client.create_item(body=db_analytics_item)
|
347 |
+
st.session_state["db_container"] = client
|
348 |
|
349 |
PROCESS_STEPS = [
|
350 |
"Artikel Extraktion",
|
requirements.txt
CHANGED
@@ -3,4 +3,5 @@ openai==0.28.1
|
|
3 |
python-dotenv
|
4 |
requests
|
5 |
beautifulsoup4
|
6 |
-
st-copy-to-clipboard
|
|
|
|
3 |
python-dotenv
|
4 |
requests
|
5 |
beautifulsoup4
|
6 |
+
st-copy-to-clipboard
|
7 |
+
azure-cosmos
|