Ronio Jerico Roque commited on
Commit ·
373aa66
1
Parent(s): 2ec2977
fix: removed unecessary lines
Browse files- .env +4 -1
- classes/Target_Market.py +55 -11
- classes/__pycache__/Target_Market.cpython-313.pyc +0 -0
- pages/agent_6.py +1 -1
.env
CHANGED
|
@@ -1,3 +1,6 @@
|
|
| 1 |
email=shore360
|
| 2 |
password=shoreai
|
| 3 |
-
apiKey=ae72168bf4064434bef650d038624373
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
email=shore360
|
| 2 |
password=shoreai
|
| 3 |
+
apiKey=ae72168bf4064434bef650d038624373
|
| 4 |
+
model=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=AIzaSyArNeCctdKaWhxprHTnHyISCd0CpKqB5dk
|
| 5 |
+
apiKey1=9dcdc9d26fc443e19d6458e519f069a7
|
| 6 |
+
GEMINI_API_KEY=AIzaSyArNeCctdKaWhxprHTnHyISCd0CpKqB5dk
|
classes/Target_Market.py
CHANGED
|
@@ -9,8 +9,9 @@ from helper.button_behaviour import hide_button
|
|
| 9 |
from helper.initialize_analyze_session import initialize_analyze_session
|
| 10 |
import json
|
| 11 |
from newsapi import NewsApiClient
|
| 12 |
-
import datetime
|
| 13 |
import requests
|
|
|
|
|
|
|
| 14 |
|
| 15 |
class TargetMarketAnalyst:
|
| 16 |
def __init__(self, model_url, analyst_name, data_src, analyst_description):
|
|
@@ -34,6 +35,9 @@ class TargetMarketAnalyst:
|
|
| 34 |
|
| 35 |
def request_model(self, payload_txt):
|
| 36 |
response = requests.post(self.model_url, json=payload_txt)
|
|
|
|
|
|
|
|
|
|
| 37 |
sources = self.newsapi.get_sources()
|
| 38 |
response.raise_for_status()
|
| 39 |
output = response.json()
|
|
@@ -56,6 +60,44 @@ class TargetMarketAnalyst:
|
|
| 56 |
def row1(self):
|
| 57 |
col1, col2 = st.columns(gap="medium", spec=[0.33, 0.66])
|
| 58 |
with col1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
self.topics = st.text_input("Topic of Interest: ", placeholder='Enter Topic of Interest:', key='topic')
|
| 60 |
#self.start_date = st.date_input('Start Date:', value="today", key='start_date')
|
| 61 |
#self.end_date = st.date_input('End Date:', value="today", key='end_date')
|
|
@@ -76,15 +118,18 @@ class TargetMarketAnalyst:
|
|
| 76 |
self.sort = 'popularity'
|
| 77 |
elif self.sort == 'Published At':
|
| 78 |
self.sort = 'publishedAt'
|
| 79 |
-
|
| 80 |
with col2:
|
| 81 |
-
st.write("") # FOR THE HIDE BUTTON
|
| 82 |
-
st.write("") # FOR THE HIDE BUTTON
|
| 83 |
-
st.write("
|
| 84 |
-
st.session_state['analyzing'] = False
|
| 85 |
-
st.write("") # FOR THE HIDE BUTTON
|
| 86 |
-
|
|
|
|
|
|
|
| 87 |
start_time = time.time()
|
|
|
|
| 88 |
if analyze_button:
|
| 89 |
hide_button()
|
| 90 |
if self.topics:
|
|
@@ -101,7 +146,6 @@ class TargetMarketAnalyst:
|
|
| 101 |
response = requests.get(f'{root}q={self.topics}&language={language}&sortBy={self.sort}&language="en"&apiKey={api}')
|
| 102 |
try:
|
| 103 |
response.raise_for_status()
|
| 104 |
-
|
| 105 |
output = response.json()
|
| 106 |
with st.expander("Output", expanded=True):
|
| 107 |
text = output['articles']
|
|
@@ -132,7 +176,7 @@ class TargetMarketAnalyst:
|
|
| 132 |
st.write("---")
|
| 133 |
|
| 134 |
|
| 135 |
-
st.write(
|
| 136 |
|
| 137 |
end_time = time.time()
|
| 138 |
time_lapsed = end_time - start_time
|
|
@@ -153,7 +197,7 @@ class TargetMarketAnalyst:
|
|
| 153 |
else:
|
| 154 |
st.info("Please provide a topic of interest")
|
| 155 |
hide_button()
|
| 156 |
-
|
| 157 |
if __name__ == "__main__":
|
| 158 |
st.set_page_config(layout="wide")
|
| 159 |
|
|
|
|
| 9 |
from helper.initialize_analyze_session import initialize_analyze_session
|
| 10 |
import json
|
| 11 |
from newsapi import NewsApiClient
|
|
|
|
| 12 |
import requests
|
| 13 |
+
from google import genai
|
| 14 |
+
from openai import OpenAI
|
| 15 |
|
| 16 |
class TargetMarketAnalyst:
|
| 17 |
def __init__(self, model_url, analyst_name, data_src, analyst_description):
|
|
|
|
| 35 |
|
| 36 |
def request_model(self, payload_txt):
|
| 37 |
response = requests.post(self.model_url, json=payload_txt)
|
| 38 |
+
response.raise_for_status()
|
| 39 |
+
output = response.json()
|
| 40 |
+
|
| 41 |
sources = self.newsapi.get_sources()
|
| 42 |
response.raise_for_status()
|
| 43 |
output = response.json()
|
|
|
|
| 60 |
def row1(self):
|
| 61 |
col1, col2 = st.columns(gap="medium", spec=[0.33, 0.66])
|
| 62 |
with col1:
|
| 63 |
+
prompt = st.chat_input("How can I help you today?")
|
| 64 |
+
#client = genai.Client(api_key="AIzaSyArNeCctdKaWhxprHTnHyISCd0CpKqB5dk")
|
| 65 |
+
|
| 66 |
+
payload_txt = {
|
| 67 |
+
"input_value": f"{prompt}",
|
| 68 |
+
"output_type": "chat",
|
| 69 |
+
"input_type": "chat",
|
| 70 |
+
"tweaks": {
|
| 71 |
+
"Agent-jDo0M": {},
|
| 72 |
+
"ChatInput-TcV5B": {},
|
| 73 |
+
"ChatOutput-woYKj": {},
|
| 74 |
+
"URL-iTqUH": {},
|
| 75 |
+
"CalculatorComponent-yPwgW": {},
|
| 76 |
+
"APIRequest-rDfwC": {},
|
| 77 |
+
"TextInput-sID7m": {},
|
| 78 |
+
"ParseData-ezi1L": {}
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
headers = {
|
| 83 |
+
'Content-Type': 'application/json',
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
url = "http://172.17.21.23:7860/api/v1/run/382ac239-3231-4f9b-89fe-f5ee26e4b1eb?stream=false"
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
if prompt:
|
| 91 |
+
response = requests.post(url, json=payload_txt, headers=headers, params={'stream': 'false'})
|
| 92 |
+
response.raise_for_status()
|
| 93 |
+
output = response.json()
|
| 94 |
+
text = output["outputs"][0]["outputs"][0]["results"]["message"]["text"]
|
| 95 |
+
|
| 96 |
+
def remove_escape_sequences(text):
|
| 97 |
+
return text.replace('\\n', '\n').replace('\\t', '\t').replace('\\r', '\r')
|
| 98 |
+
|
| 99 |
+
self.text = remove_escape_sequences(json.dumps(text, ensure_ascii=False).strip('"'))
|
| 100 |
+
'''
|
| 101 |
self.topics = st.text_input("Topic of Interest: ", placeholder='Enter Topic of Interest:', key='topic')
|
| 102 |
#self.start_date = st.date_input('Start Date:', value="today", key='start_date')
|
| 103 |
#self.end_date = st.date_input('End Date:', value="today", key='end_date')
|
|
|
|
| 118 |
self.sort = 'popularity'
|
| 119 |
elif self.sort == 'Published At':
|
| 120 |
self.sort = 'publishedAt'
|
| 121 |
+
'''
|
| 122 |
with col2:
|
| 123 |
+
#st.write("") # FOR THE HIDE BUTTON
|
| 124 |
+
#st.write("") # FOR THE HIDE BUTTON
|
| 125 |
+
st.write("Content: ")
|
| 126 |
+
#st.session_state['analyzing'] = False
|
| 127 |
+
#st.write("") # FOR THE HIDE BUTTON
|
| 128 |
+
if prompt:
|
| 129 |
+
st.write(self.text)
|
| 130 |
+
#analyze_button = st.button("", disabled=initialize_analyze_session())
|
| 131 |
start_time = time.time()
|
| 132 |
+
'''
|
| 133 |
if analyze_button:
|
| 134 |
hide_button()
|
| 135 |
if self.topics:
|
|
|
|
| 146 |
response = requests.get(f'{root}q={self.topics}&language={language}&sortBy={self.sort}&language="en"&apiKey={api}')
|
| 147 |
try:
|
| 148 |
response.raise_for_status()
|
|
|
|
| 149 |
output = response.json()
|
| 150 |
with st.expander("Output", expanded=True):
|
| 151 |
text = output['articles']
|
|
|
|
| 176 |
st.write("---")
|
| 177 |
|
| 178 |
|
| 179 |
+
st.write(article)
|
| 180 |
|
| 181 |
end_time = time.time()
|
| 182 |
time_lapsed = end_time - start_time
|
|
|
|
| 197 |
else:
|
| 198 |
st.info("Please provide a topic of interest")
|
| 199 |
hide_button()
|
| 200 |
+
'''
|
| 201 |
if __name__ == "__main__":
|
| 202 |
st.set_page_config(layout="wide")
|
| 203 |
|
classes/__pycache__/Target_Market.cpython-313.pyc
CHANGED
|
Binary files a/classes/__pycache__/Target_Market.cpython-313.pyc and b/classes/__pycache__/Target_Market.cpython-313.pyc differ
|
|
|
pages/agent_6.py
CHANGED
|
@@ -5,5 +5,5 @@ import streamlit as st
|
|
| 5 |
|
| 6 |
# SPECIFY API URL & ANALYST NAME
|
| 7 |
st.set_page_config(layout="wide")
|
| 8 |
-
start = TargetMarketAnalyst(os.getenv('
|
| 9 |
|
|
|
|
| 5 |
|
| 6 |
# SPECIFY API URL & ANALYST NAME
|
| 7 |
st.set_page_config(layout="wide")
|
| 8 |
+
start = TargetMarketAnalyst(os.getenv('model'), Analysts['Analyst 6'], Data_Source['Analyst_Src 6'],Analysts_Description['Analyst_Desc 6'])
|
| 9 |
|