update external LLM to turbo 3.5, instead of davinci; modify prompt

This commit is contained in:
raphaelzhou1
2023-10-08 05:57:59 -04:00
parent bfbd5d3697
commit 56232ecad6
2 changed files with 14 additions and 3 deletions

View File

@@ -25,7 +25,7 @@ def extract_classification(text, classification_prompt):
},
{
"role": "user",
"content": text + classification_prompt,
"content": "We have the following financial statement: \"" + text + "\"" + classification_prompt,
}
],
}
@@ -36,7 +36,18 @@ def extract_classification(text, classification_prompt):
response = requests.post(api_url, headers=headers, json=payload)
json_data = response.json()
print("json data", json_data)
classification_response = json_data[0]['text'].strip()
classification_response = json_data["choices"][0]['message']['content'].strip()
if "Twitter" in classification_response:
classification_response = "Twitter"
elif "Seeking Alpha" in classification_response:
classification_response = "Seeking Alpha"
elif "Reuters" in classification_response:
classification_response = "Reuters"
elif "WSJ" in classification_response:
classification_response = "WSJ"
else:
classification_response = "Unknown"
print("Classification response:", classification_response)
return classification_response
except requests.exceptions.RequestException as e:

View File

@@ -656,7 +656,7 @@ def select_column_and_classify():
raise ValueError("Invalid column selection")
df["classification"] = "" # Create a new column named "classification"
default_classification_prompt = ". For news above, determine its origin. Only print \"Twitter\" or \"Seeking Alpha\" or \"Reuters\" or \"WSJ\""
default_classification_prompt = ". For financial statement above, determine its origin (based on your existing knowledge). Your answer should be either \"Twitter\" or \"Seeking Alpha\" or \"Reuters\" or \"WSJ\""
classification_prompt = gui.enterbox("Modify the classification prompt:", "Custom Classification Prompt",
default_classification_prompt)