Spaces:
Sleeping
Sleeping
update app.py
Browse files
app.py
CHANGED
|
@@ -176,18 +176,32 @@ def run_gpt_model(prompt: str, api_key: str) -> str:
|
|
| 176 |
"You are an expert stock analyst with a high degree of familiarity with TradeSmith and InvestorPlace products and services. "
|
| 177 |
"You help subscribers of these businesses analyze stocks. "
|
| 178 |
"You speak concisely and your output should use line breaks after each sentence to keep the text within a readable width. "
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
prompt=prompt,
|
|
|
|
| 184 |
max_tokens=1500,
|
| 185 |
temperature=0.7,
|
| 186 |
-
stream=
|
| 187 |
stop=None
|
| 188 |
)
|
| 189 |
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
def analyze_stock(ticker: str) -> str:
|
| 193 |
fmp_api_key = os.getenv('FMP_API_KEY')
|
|
|
|
| 176 |
"You are an expert stock analyst with a high degree of familiarity with TradeSmith and InvestorPlace products and services. "
|
| 177 |
"You help subscribers of these businesses analyze stocks. "
|
| 178 |
"You speak concisely and your output should use line breaks after each sentence to keep the text within a readable width. "
|
| 179 |
+
"Your answer format should be as follows:\n\n[Short Company Description]\n\n[Positive Signals]:\n1. ...\n\n[Potential Concerns]:\n1. ...\n\n[Prediction & Analysis]:\n...\n")
|
| 180 |
+
|
| 181 |
+
system = {
|
| 182 |
+
"role":"system",
|
| 183 |
+
"content": (system_prompt)
|
| 184 |
+
}
|
| 185 |
|
| 186 |
+
user = {
|
| 187 |
+
"role":"user",
|
| 188 |
+
"content":prompt
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
response = openai_client.chat.completions.create(
|
| 192 |
+
model="gpt-4o", # or another model
|
| 193 |
prompt=prompt,
|
| 194 |
+
messages = [system,user]
|
| 195 |
max_tokens=1500,
|
| 196 |
temperature=0.7,
|
| 197 |
+
stream=True,
|
| 198 |
stop=None
|
| 199 |
)
|
| 200 |
|
| 201 |
+
|
| 202 |
+
for chunk in response:
|
| 203 |
+
collected_chunks += chunk.choices[0].delta.content or ""
|
| 204 |
+
print(chunk.choices[0].delta.content or "",end="")
|
| 205 |
|
| 206 |
def analyze_stock(ticker: str) -> str:
|
| 207 |
fmp_api_key = os.getenv('FMP_API_KEY')
|