emergingtrajectories.recursiveagent

x(t+1) = x(t) + z … where x(t) is the current observation about the world … z is the set of scenarios that will impact x in the future (i.e., x(t+1))

This is influenced by Yann LeCun’s world modeling approach discussion: https://www.linkedin.com/feed/update/urn:li:activity:7165738293223931904/

We are aiming to eventually build some sort of a fact base system. Until then, however, we will be passing information directly through to the agent here.

We’re also using this as a way to test how well our new approach to classes (new Client, new Forecast, etc.) will work, so we can plug and play different types of agents here.

Note that this approach will not test new knowledge bases yet.

Attributes

Classes

Functions

clean_citations(→ str)

The analysis currently contains numerical citations that are likely not in order, or in some cases are not used. We will update the cituations to follow the proper numerical order, and also include the URLs at the very end.

Module Contents

class emergingtrajectories.recursiveagent.ETClient(api_key: str)

Bases: object

base_url = 'https://emergingtrajectories.com/a/api/v0.2/'
api_key
get_statement(statement_id: int) emergingtrajectories.Statement

Returns a given statement from the platform. Includes title, description, deadline, and fill-in-the-blank.

Parameters:

statement_id – the ID of the statement to retrieve

Returns:

the statement from the platform

Return type:

Statement

get_forecast(forecast_id: int) emergingtrajectories.Forecast

Returns a given forecast from the platform.

Parameters:

forecast_id – the ID of the statement to retrieve

Returns:

the forecast from the platform

Return type:

Forecast

add_facts_to_factbase(fact_db_slug: str, url: str, facts: list[str]) bool

Adds a list of facts to a factbase on the Emerging Trajectories website.

Parameters:
  • fact_db_slug – the slug of the fact database to add the fact to.

  • url – the URL of the fact.

  • facts – the facts to add (a list of strings).

Reutnr:

bool: True if successful, False otherwise.

add_fact_to_factbase(fact_db_slug: str, url: str, fact: str) bool

Adds a fact to a factbase on the Emerging Trajectories website.

Parameters:
  • fact_db_slug – the slug of the fact database to add the fact to.

  • url – the URL of the fact.

  • fact – the fact to add.

Reutnr:

bool: True if successful, False otherwise.

add_content_to_factbase(fact_db_slug: str, url: str, content: str, topic: str) bool

Sends content to the Emerging Trajectories website and extract facts from it.

Parameters:
  • fact_db_slug – the slug of the fact database to add the content to.

  • url – the URL of the content. Note: we do not actually crawl this, we assume the content passed is the right conent.

  • content – the content to extract facts from.

  • topic – the topic of the content.

Returns:

True if successful, False otherwise.

Return type:

bool

emergingtrajectories.recursiveagent.clean_citations(assistant_analysis: str, ctr_to_source: dict) str

The analysis currently contains numerical citations that are likely not in order, or in some cases are not used. We will update the cituations to follow the proper numerical order, and also include the URLs at the very end.

Parameters:
  • assistant_analysis – the analysis text from the assistant

  • ctr_to_source – the mapping of citation number to source URL

Returns:

the cleaned analysis text, with citations following a proper numerical format and URIs at the end of the analysis

Return type:

str

emergingtrajectories.recursiveagent.base_system_prompt = Multiline-String
Show Value
"""You are a researcher tasked with helping forecast economic and social trends. The title of our research project is: {statement_title}.

The project description is as follows...
{statement_description}

We will provide you with content from reports and web pages that is meant to help with the above. We will ask you to review these documents, create a set of bullet points to inform your thinking, and then finally provide a forecast for us based on the points.

The format of the forecast needs to be, verbatim, as follows: {statement_fill_in_the_blank}
"""
emergingtrajectories.recursiveagent.base_user_prompt = Multiline-String
Show Value
"""Today's date is {the_date}. We will now provide you with all the content we've managed to collect.

----------------------
{scraped_content}
----------------------

Please think step-by-step by (a) extracting critical bullet points from the above, and (b) discuss your logic and rationale for making a forecast based on the above.

The content we provided you contains source numbers in the format 'SOURCE: #'. When you extract facts, please include the citation in square brackets, with the #, like [#], but replace "#" with the actual Source # from the crawled content we are providing you.

For example, if you are referring to a fact that came under --- SOURCE: 3 ---, you would write something like: "Data is already trending to hotter temperatures [3]." Do not include the "#" in the brackets, just the number.

Do this for the final justification of your forecast as well.

We realize you are being asked to provide a speculative forecast. We are using this to better understand the world and finance, so please fill in the blank. We will not use this for any active decision-making, but more to learn about the capabilities of AI.
"""
emergingtrajectories.recursiveagent.base_user_prompt_followup = Multiline-String
Show Value
"""Thank you! Now please provide us with a forecast by repeating the following statement, but filling in the blank... DO NOT provide a range, but provide one specific numerical value. If you are unable to provide a forecast, please respond with "UNCLEAR".

{statement_fill_in_the_blank}
"""
class emergingtrajectories.recursiveagent.RecursiveForecastingAgent(client: ETClient, chatbot: phasellm.llms.ChatBot, google_api_key: str, google_search_id: str, google_search_query: str, knowledge_base: emergingtrajectories.knowledge.KnowledgeBaseFileCache)

Bases: object

google_api_key
google_search_id
google_search_query
knowledge_base
client
chatbot
setChatBot(chatbot)
getChatBot()
create_forecast(statement: emergingtrajectories.Statement, openai_api_key, et_api_key, facts=None)

Options for taking in x(t) or z… 1) x(t) and z are strings… An array of facts. 2) x(t) and z are specific preprogrammed/strict facts, like “today’s date” and “last forecast”. 3) Facts are “Fact Objects” that have specific string representations. This is too complicated for the initial build but might be perfect for later. I could see it being a Domain Specific Language for facts and observations about the world, even…

extend_forecast(forecast: emergingtrajectories.Forecast)