emergingtrajectories.utils¶
Attributes¶
Classes¶
The UtilityHelper class is used to extract predictions from text messages. |
Functions¶
|
Checks whether the 'string' passed as an argument can be converted into a numeric value. |
|
Module Contents¶
- emergingtrajectories.utils._extract_prediction_prompt = Multiline-String¶
Show Value
"""You are helping a researcher with a data extraction exercise. You will be provided with a prediction statement and a broader piece of text. Your objective is to extract the specific numerical prediction and provide it as a response. DO NOT qualify your response in any way. For example, suppose you have the following... |||---||| PREDICTION STATEMENT: please predict the probability that the price of Bitcoin will exceed $100,000 by the end of 2024. TEXT: The probability that bitcoin will exceed $100,000 by the end of 2024 is 0.37. |||---||| In the case above, your response would simply be "0.37". The actual metrics (i.e., prediction) might be provided with formatting. For example... |||---||| PREDICTION STATEMENT: The probability that Boeing's (NYSE:BA) share price at the close of markets on or before March 1, 2024 will be $220.00 USD or higher is _____ (value between 0.00 and 1.00). TEXT: The probability that Boeing's (NYSE:BA) share price at the close of markets on or before March 1, 2024, will be $220.00 USD or higher is **0.65**. |||---||| In this case, ignore the asterisks or instructions ("value between 0.00 and 1.00") and provide the correct response, which is 0.65. The user will provide you with a PREDICTION STATEMENT and TEXT and you need to answer like the above. On the extremely rare occasion that the TEXT does not have a proper numerical prediction or you are unable to extract it, simply respond with "UNCLEAR". """
- emergingtrajectories.utils._extract_prediction_prompt_error = 'UNCLEAR'¶
- emergingtrajectories.utils.is_numeric(string: str) bool¶
Checks whether the ‘string’ passed as an argument can be converted into a numeric value.
- Parameters:
string – the string in question
- Returns:
Boolean value; True if the string can be converted into a numeric value, False otherwise.
- emergingtrajectories.utils.run_forecast(function_to_call, n, *args, **kwargs)¶
- class emergingtrajectories.utils.UtilityHelper(api_key, model='gpt-4-0125-preview')¶
Bases:
objectThe UtilityHelper class is used to extract predictions from text messages.
- Parameters:
api_key – the OpenAI API key
model – the OpenAI model to use for the extraction process
- api_key¶
- model = 'gpt-4-0125-preview'¶
- extract_prediction(response: str, statement_challenge: str) float¶
Extracts the prediction value from the response to a statement challenge.
- Parameters:
response – the response to the statement challenge (i.e., what was predicted by another LLM)
statement_challenge – the statement challenge – what is being predicted
- Returns:
The extracted prediction value as a float. Raises an exception if the prediction cannot be extracted.