Skip to content

Commit

Permalink
Update prepare_data.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
pschofield2 authored Nov 27, 2023
1 parent e71eef1 commit 8c0a47d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fingpt/FinGPT_Forecaster/prepare_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"import math\n",
"import time\n",
"import json\n",
"import openai\n",
"import random\n",
"import finnhub\n",
"import datasets\n",
"import pandas as pd\n",
"import yfinance as yf\n",
"from datetime import datetime\n",
"from collections import defaultdict\n",
"from datasets import Dataset"
"from datasets import Dataset\n",
"from openai import OpenAI"
]
},
{
Expand All @@ -39,7 +39,7 @@
"\n",
"finnhub_client = finnhub.Client(api_key=\"your finnhub key\")\n",
"\n",
"openai.api_key = 'your openai key'"
"client = OpenAI(api_key = 'your openai key')"
]
},
{
Expand Down Expand Up @@ -1073,7 +1073,7 @@
" cnt = 0\n",
" while cnt < 5:\n",
" try:\n",
" completion = openai.ChatCompletion.create(\n",
" completion = client.chat.completions.create(\n",
" model=\"gpt-4\",\n",
" messages=[\n",
" {\"role\": \"system\", \"content\": SYSTEM_PROMPT},\n",
Expand All @@ -1085,7 +1085,7 @@
" cnt += 1\n",
" print(f'retry cnt {cnt}')\n",
" \n",
" answer = completion['choices'][0]['message']['content'] if cnt < 5 else \"\"\n",
" answer = completion.choices[0].message.content if cnt < 5 else \"\"\n",
" append_to_csv(csv_file, prompt, answer)\n",
" "
]
Expand Down

0 comments on commit 8c0a47d

Please sign in to comment.