Spaces:
Sleeping
Sleeping
Commit
•
816350a
1
Parent(s):
a60cfb9
Update utils.py
Browse files
utils.py
CHANGED
@@ -11,15 +11,30 @@ from transformers import pipeline
|
|
11 |
from openai import OpenAI
|
12 |
from groq import Groq
|
13 |
import time
|
|
|
14 |
|
15 |
#openai_key = "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"
|
16 |
#client = OpenAI(api_key = openai_key)
|
17 |
desc = pd.read_excel('Descriptor.xlsx',header = None)
|
18 |
desc_list = desc.iloc[:,0].to_list()
|
19 |
-
|
20 |
-
model = "llama3-70b-8192"
|
21 |
-
pipe = pipeline("text-classification", model="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis")
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
def call(prompt, text):
|
24 |
client = Groq(api_key=os.getenv("key"),)
|
25 |
|
@@ -85,15 +100,15 @@ def summary(input_json):
|
|
85 |
|
86 |
output["Stock Ticker"] = input_json['symbol']
|
87 |
|
88 |
-
output['Short Summary'] =
|
89 |
|
90 |
-
output['Long summary'] =
|
91 |
|
92 |
prompt = "1 word Financial SEO tag for this news article"
|
93 |
-
output['Tag'] =
|
94 |
|
95 |
prompt = "Give a single headline for this News Article"
|
96 |
-
output['Headline'] =
|
97 |
|
98 |
utc_now = datetime.datetime.utcnow()
|
99 |
ist_now = utc_now.astimezone(datetime.timezone(datetime.timedelta(hours=5, minutes=30)))
|
@@ -103,9 +118,9 @@ def summary(input_json):
|
|
103 |
output['Date and time of data delivery from Skylark'] = Date+"T"+time+"Z"
|
104 |
|
105 |
prompt = "Answer in one word the sentiment of this News out of Positive, Negative or Neutral {}"
|
106 |
-
output['Sentiment'] =
|
107 |
|
108 |
-
time.sleep(60)
|
109 |
# response = client.images.generate(
|
110 |
# model="dall-e-3",
|
111 |
# prompt=headline.text,
|
|
|
11 |
from openai import OpenAI
|
12 |
from groq import Groq
|
13 |
import time
|
14 |
+
from openai import OpenAI
|
15 |
|
16 |
#openai_key = "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"
|
17 |
#client = OpenAI(api_key = openai_key)
|
18 |
desc = pd.read_excel('Descriptor.xlsx',header = None)
|
19 |
desc_list = desc.iloc[:,0].to_list()
|
|
|
|
|
|
|
20 |
|
21 |
+
def callAzure(prompt,text):
|
22 |
+
|
23 |
+
url = "https://Meta-Llama-3-70B-Instruct-fkqip-serverless.eastus2.inference.ai.azure.com"
|
24 |
+
api_key = "o5yaLhTIvg0s5zuYVInBpyneEZO8oonY"
|
25 |
+
client = OpenAI(base_url=url, api_key=api_key)
|
26 |
+
response = client.chat.completions.create(
|
27 |
+
messages=[
|
28 |
+
{
|
29 |
+
"role": "user",
|
30 |
+
"content": "{} {}".format(prompt, text),
|
31 |
+
}
|
32 |
+
],
|
33 |
+
model="azureai",
|
34 |
+
)
|
35 |
+
|
36 |
+
return response.choices[0].message.content
|
37 |
+
|
38 |
def call(prompt, text):
|
39 |
client = Groq(api_key=os.getenv("key"),)
|
40 |
|
|
|
100 |
|
101 |
output["Stock Ticker"] = input_json['symbol']
|
102 |
|
103 |
+
output['Short Summary'] = callAzure(promptShort[id], long_text)
|
104 |
|
105 |
+
output['Long summary'] = callAzure(promptLong[id], long_text)
|
106 |
|
107 |
prompt = "1 word Financial SEO tag for this news article"
|
108 |
+
output['Tag'] = callAzure(prompt, output['Short Summary'])
|
109 |
|
110 |
prompt = "Give a single headline for this News Article"
|
111 |
+
output['Headline'] = callAzure(prompt, output['Short Summary'])
|
112 |
|
113 |
utc_now = datetime.datetime.utcnow()
|
114 |
ist_now = utc_now.astimezone(datetime.timezone(datetime.timedelta(hours=5, minutes=30)))
|
|
|
118 |
output['Date and time of data delivery from Skylark'] = Date+"T"+time+"Z"
|
119 |
|
120 |
prompt = "Answer in one word the sentiment of this News out of Positive, Negative or Neutral {}"
|
121 |
+
output['Sentiment'] = callAzure(prompt, output['Short Summary'])
|
122 |
|
123 |
+
#time.sleep(60)
|
124 |
# response = client.images.generate(
|
125 |
# model="dall-e-3",
|
126 |
# prompt=headline.text,
|