bugfixing
This commit is contained in:
parent
1127900d04
commit
0aa2367ee4
@ -49,19 +49,22 @@ async def get_analyst_insight(session, ticker):
|
|||||||
|
|
||||||
# Summarize insights using OpenAI
|
# Summarize insights using OpenAI
|
||||||
async def get_summary(data):
|
async def get_summary(data):
|
||||||
data_string = f"Insights: {data['insight']}"
|
try:
|
||||||
response = await client.chat.completions.create(
|
data_string = f"Insights: {data['insight']}"
|
||||||
model="gpt-4o-mini",
|
response = client.chat.completions.create(
|
||||||
messages=[
|
model="gpt-4o-mini",
|
||||||
{"role": "system", "content": "Summarize analyst insights clearly and concisely in under 400 characters. Ensure the summary is professional and easy to understand. Conclude with whether the report is bullish or bearish."},
|
messages=[
|
||||||
{"role": "user", "content": data_string}
|
{"role": "system", "content": "Summarize analyst insights clearly and concisely in under 400 characters. Ensure the summary is professional and easy to understand. Conclude with whether the report is bullish or bearish."},
|
||||||
],
|
{"role": "user", "content": data_string}
|
||||||
max_tokens=150,
|
],
|
||||||
temperature=0.7
|
max_tokens=150,
|
||||||
)
|
temperature=0.7
|
||||||
summary = response.choices[0].message.content
|
)
|
||||||
data['insight'] = summary
|
summary = response.choices[0].message.content
|
||||||
return data
|
data['insight'] = summary
|
||||||
|
return data
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
# Process individual symbol
|
# Process individual symbol
|
||||||
async def process_symbol(session, symbol):
|
async def process_symbol(session, symbol):
|
||||||
@ -74,9 +77,11 @@ async def process_symbol(session, symbol):
|
|||||||
old_report_id = ujson.loads(await file.read()).get('id', '')
|
old_report_id = ujson.loads(await file.read()).get('id', '')
|
||||||
except:
|
except:
|
||||||
old_report_id = ''
|
old_report_id = ''
|
||||||
|
|
||||||
if new_report_id != old_report_id and data['insight']:
|
if new_report_id != old_report_id and data['insight']:
|
||||||
res = await get_summary(data)
|
res = await get_summary(data)
|
||||||
await save_json(symbol, res)
|
if res:
|
||||||
|
await save_json(symbol, res)
|
||||||
else:
|
else:
|
||||||
print(f'Skipped: {symbol}')
|
print(f'Skipped: {symbol}')
|
||||||
except:
|
except:
|
||||||
@ -93,7 +98,7 @@ async def main():
|
|||||||
con = sqlite3.connect('stocks.db')
|
con = sqlite3.connect('stocks.db')
|
||||||
cursor = con.cursor()
|
cursor = con.cursor()
|
||||||
cursor.execute("SELECT DISTINCT symbol FROM stocks WHERE symbol NOT LIKE '%.%'")
|
cursor.execute("SELECT DISTINCT symbol FROM stocks WHERE symbol NOT LIKE '%.%'")
|
||||||
stock_symbols = [row[0] for row in cursor.fetchall()]
|
stock_symbols = ['CXT'] #[row[0] for row in cursor.fetchall()]
|
||||||
con.close()
|
con.close()
|
||||||
|
|
||||||
async with aiohttp.ClientSession(headers=headers) as session:
|
async with aiohttp.ClientSession(headers=headers) as session:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user