Skip to content

Commit

Permalink
Merge pull request #74 from polywrap/dorgjelli/remove-evo-name
Browse files Browse the repository at this point in the history
chore: rename to prediction_prophet
  • Loading branch information
namesty authored Mar 19, 2024
2 parents b315d74 + 7c89df7 commit 6a06ba6
Show file tree
Hide file tree
Showing 41 changed files with 102 additions and 102 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: sh setup.sh && streamlit run evo_prophet/app.py
web: sh setup.sh && streamlit run prediction_prophet/app.py
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# evo.prophet
# Prediction Prophet
![](./content/banner_hires.png)

---
Expand All @@ -9,36 +9,36 @@

## Welcome!

evo.prophet is an agent that specializes in making informed predictions, based on web research. To try it yourself head to [predictionprophet.ai](https://predictionprophet.ai) or build and run from source following these [setup instructions](#setup).
Prediction Prophet is an agent that specializes in making informed predictions, based on web research. To try it yourself head to [predictionprophet.ai](https://predictionprophet.ai) or build and run from source following these [setup instructions](#setup).

## Need Help?

Join our [Discord community](https://discord.gg/k7UCsH3ps9) for support and discussions.

[![Join us on Discord](https://invidget.switchblade.xyz/k7UCsH3ps9)](https://discord.com/invite/k7UCsH3ps9)

If you have questions or encounter issues, please don't hesitate to [create a new issue](https://github.com/polywrap/evo.prophet/issues/new) to get support.
If you have questions or encounter issues, please don't hesitate to [create a new issue](https://github.com/polywrap/predictionprophet/issues/new) to get support.


## How It Works
![](./content/diagram.png)

To elaborate further, given a question like `"Will Twitter implement a new misinformation policy before the 2024 elections?"`, evo.prophet will:
To elaborate further, given a question like `"Will Twitter implement a new misinformation policy before the 2024 elections?"`, Prophet will:

1. Generate `n` web search queries and re-ranks them using an LLM call, selecting only the most relevant ones
2. Search the web for each query, using [Tavily](https://tavily.com/)
3. Scrape and sanitize the content of each result's website
4. Use Langchain's `RecursiveCharacterTextSplitter` to split the content of all pages into chunks and create embeddings. All chunks are stored with the content as metadata.
5. Iterate over the queries selected on step `1` and vector search for the most relevant chunks created in step `4`.
6. Aggregate all relevant chunks and prepare a report.
7. Make a prediction using multi-agent debate.
7. Make a prediction.

## Setup

### Installation

1. Clone the repository
> `git clone https://github.com/polywrap/evo.prophet`
> `git clone https://github.com/polywrap/predictionprophet`
2. Copy the `.env.template` file and rename it to `.env`.
> `cp .env.template .env`
3. Find the line that says OPENAI_API_KEY=, and add your unique [OpenAI](https://openai.com/) API Key
Expand Down Expand Up @@ -67,7 +67,7 @@ poetry run research "Will Twitter implement a new misinformation policy before t
### Front-End

```bash
poetry run streamlit run ./evo_prophet/app.py
poetry run streamlit run ./prediction_prophet/app.py
```

## Possible Future Improvements
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[mypy]
python_version = 3.10
files = evo_prophet/, scripts/, tests/
files = prediction_prophet/, scripts/, tests/
plugins = pydantic.mypy
warn_redundant_casts = True
warn_unused_ignores = True
Expand Down
File renamed without changes.
24 changes: 12 additions & 12 deletions evo_prophet/app.py → prediction_prophet/app.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import time
from typing import cast
from evo_prophet.benchmark.agents import _make_prediction
from evo_prophet.functions.is_predictable_and_binary import is_predictable_and_binary
from prediction_prophet.benchmark.agents import _make_prediction
from prediction_prophet.functions.is_predictable_and_binary import is_predictable_and_binary
from prediction_market_agent_tooling.benchmark.utils import (
OutcomePrediction
)
from pydantic import SecretStr
import streamlit as st
from prediction_market_agent_tooling.tools.utils import secret_str_from_env
from langchain.text_splitter import RecursiveCharacterTextSplitter
from evo_prophet.functions.create_embeddings_from_results import create_embeddings_from_results
from evo_prophet.functions.generate_subqueries import generate_subqueries
from evo_prophet.functions.prepare_report import prepare_report
from evo_prophet.functions.rerank_subqueries import rerank_subqueries
from evo_prophet.functions.scrape_results import scrape_results
from evo_prophet.functions.search import search
from prediction_prophet.functions.create_embeddings_from_results import create_embeddings_from_results
from prediction_prophet.functions.generate_subqueries import generate_subqueries
from prediction_prophet.functions.prepare_report import prepare_report
from prediction_prophet.functions.rerank_subqueries import rerank_subqueries
from prediction_prophet.functions.scrape_results import scrape_results
from prediction_prophet.functions.search import search

def research(
goal: str,
Expand Down Expand Up @@ -98,13 +98,13 @@ def research(
st.stop()

st.set_page_config(layout="wide")
st.title("Evo Prophet")
st.title("Prediction Prophet")
st.write('Ask any yes-or-no question about a future outcome')

with st.sidebar:
st.title('Evo Prophet')
st.title('Prediction Prophet')
st.markdown("A web3 agent by [Polywrap](https://www.polywrap.io/)")
st.image('https://raw.githubusercontent.com/polywrap/evo.prophet/main/content/banner_hires.png')
st.image('https://raw.githubusercontent.com/polywrap/predictionprophet/main/content/banner_hires.png')

st.markdown('#')
openai_api_key = SecretStr(st.text_input("OpenAI API Key", type="password", key="open_ai_key"))
Expand All @@ -115,7 +115,7 @@ def research(
st.markdown('#')
st.markdown('#')
st.markdown('-------')
st.caption('View the source code on our [github](https://github.com/polywrap/evo.prophet)')
st.caption('View the source code on our [github](https://github.com/polywrap/predictionprophet)')
st.caption('Join our [discord](https://discord.gg/3ebYCjXbg7)')


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from enum import Enum
from bs4 import BeautifulSoup, NavigableString
from googleapiclient.discovery import build
from evo_prophet.functions.parallelism import THREADPOOL
from prediction_prophet.functions.parallelism import THREADPOOL

import requests
from requests import Session
Expand All @@ -29,10 +29,10 @@
from langchain_openai import OpenAIEmbeddings

from dateutil import parser
from evo_prophet.functions.utils import check_not_none
from prediction_prophet.functions.utils import check_not_none
from prediction_market_agent_tooling.tools.utils import secret_str_from_env
from evo_prophet.functions.cache import persistent_inmemory_cache
from evo_prophet.functions.parallelism import par_map
from prediction_prophet.functions.cache import persistent_inmemory_cache
from prediction_prophet.functions.parallelism import par_map
from pydantic.types import SecretStr
from prediction_market_agent_tooling.gtypes import secretstr_to_v1_secretstr

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
Prediction,
)
from datetime import datetime
from evo_prophet.autonolas.research import EmbeddingModel
from evo_prophet.autonolas.research import make_prediction, get_urls_from_queries
from evo_prophet.autonolas.research import research as research_autonolas
from evo_prophet.functions.evaluate_question import is_predictable
from evo_prophet.functions.rephrase_question import rephrase_question
from evo_prophet.functions.research import research as research_evo
from evo_prophet.functions.search import search
from evo_prophet.functions.utils import url_is_older_than
from evo_prophet.models.WebSearchResult import WebSearchResult
from prediction_prophet.autonolas.research import EmbeddingModel
from prediction_prophet.autonolas.research import make_prediction, get_urls_from_queries
from prediction_prophet.autonolas.research import research as research_autonolas
from prediction_prophet.functions.evaluate_question import is_predictable
from prediction_prophet.functions.rephrase_question import rephrase_question
from prediction_prophet.functions.research import research as prophet_research
from prediction_prophet.functions.search import search
from prediction_prophet.functions.utils import url_is_older_than
from prediction_prophet.models.WebSearchResult import WebSearchResult
from unittest.mock import patch
from evo_prophet.functions.search import search
from prediction_prophet.functions.search import search
from prediction_market_agent_tooling.benchmark.utils import (
OutcomePrediction,
Prediction,
)
from pydantic.types import SecretStr
from evo_prophet.autonolas.research import Prediction as LLMCompletionPredictionDict
from prediction_prophet.autonolas.research import Prediction as LLMCompletionPredictionDict

def _make_prediction(
market_question: str,
Expand Down Expand Up @@ -144,16 +144,16 @@ def side_effect(*args: t.Any, **kwargs: t.Any) -> list[str]:
]
return results_filtered

with patch('evo_prophet.autonolas.research.get_urls_from_queries', side_effect=side_effect, autospec=True):
with patch('prediction_prophet.autonolas.research.get_urls_from_queries', side_effect=side_effect, autospec=True):
return self.predict(market_question)


class EvoAgent(AbstractBenchmarkedAgent):
class PredictionProphetAgent(AbstractBenchmarkedAgent):
def __init__(
self,
model: str,
temperature: float = 0.0,
agent_name: str = "evo",
agent_name: str = "prediction_prophet",
use_summaries: bool = False,
use_tavily_raw_content: bool = False,
max_workers: t.Optional[int] = None,
Expand All @@ -173,7 +173,7 @@ def is_predictable_restricted(self, market_question: str, time_restriction_up_to
return result

def research(self, market_question: str) -> str:
return research_evo(
return prophet_research(
goal=market_question,
model=self.model,
use_summaries=self.use_summaries,
Expand All @@ -190,7 +190,7 @@ def predict(self, market_question: str) -> Prediction:
temperature=self.temperature,
)
except ValueError as e:
print(f"Error in EvoAgent's predict: {e}")
print(f"Error in PredictionProphet's predict: {e}")
return Prediction()

def predict_restricted(
Expand All @@ -204,7 +204,7 @@ def side_effect(*args: t.Any, **kwargs: t.Any) -> list[tuple[str, WebSearchResul
]
return results_filtered

with patch('evo_prophet.functions.research.search', side_effect=side_effect, autospec=True):
with patch('prediction_prophet.functions.research.search', side_effect=side_effect, autospec=True):
return self.predict(market_question)

class RephrasingOlasAgent(OlasAgent):
Expand Down Expand Up @@ -249,6 +249,6 @@ def research(self, market_question: str) -> str:
AGENTS = [
OlasAgent,
RephrasingOlasAgent,
EvoAgent,
PredictionProphetAgent,
QuestionOnlyAgent,
]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytz
from decimal import Decimal
from datetime import datetime, timedelta
from evo_prophet.benchmark.agents import EvoAgent, OlasAgent, EmbeddingModel
from prediction_prophet.benchmark.agents import PredictionProphetAgent, OlasAgent, EmbeddingModel
from prediction_market_agent_tooling.benchmark.agents import AbstractBenchmarkedAgent
from prediction_market_agent_tooling.markets.agent_market import AgentMarket
from prediction_market_agent_tooling.markets.manifold.manifold import ManifoldAgentMarket
Expand Down Expand Up @@ -75,8 +75,8 @@ def answer_binary_market(self, market: AgentMarket) -> bool:
return binary_answer


class DeployableAgentER_EvoGPT3(DeployableAgentER):
agent = EvoAgent(model="gpt-3.5-turbo-0125")
class DeployableAgentER_PredictionProphetGPT3(DeployableAgentER):
agent = PredictionProphetAgent(model="gpt-3.5-turbo-0125")


class DeployableAgentER_OlasEmbeddingOA(DeployableAgentER):
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import os
from langchain_openai import OpenAIEmbeddings
from langchain.vectorstores.chroma import Chroma
from evo_prophet.models.WebScrapeResult import WebScrapeResult
from prediction_prophet.models.WebScrapeResult import WebScrapeResult
from langchain.text_splitter import RecursiveCharacterTextSplitter
from pydantic.types import SecretStr
from prediction_market_agent_tooling.tools.utils import secret_str_from_env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from prediction_market_agent_tooling.benchmark.utils import (
Prediction,
)
from evo_prophet.benchmark.agents import completion_prediction_json_to_pydantic_model
from prediction_prophet.benchmark.agents import completion_prediction_json_to_pydantic_model
from pydantic import SecretStr
from langchain.schema.output_parser import StrOutputParser
from langchain_openai import ChatOpenAI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
from evo_prophet.autonolas.research import clean_completion_json
from prediction_prophet.autonolas.research import clean_completion_json
from langchain_openai import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from evo_prophet.functions.cache import persistent_inmemory_cache
from prediction_prophet.functions.cache import persistent_inmemory_cache
from pydantic.types import SecretStr
from prediction_market_agent_tooling.tools.utils import secret_str_from_env
from prediction_market_agent_tooling.gtypes import secretstr_to_v1_secretstr
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
from evo_prophet.autonolas.research import clean_completion_json
from prediction_prophet.autonolas.research import clean_completion_json
from langchain_openai import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from evo_prophet.functions.cache import persistent_inmemory_cache
from prediction_prophet.functions.cache import persistent_inmemory_cache
from pydantic.types import SecretStr
from prediction_market_agent_tooling.tools.utils import secret_str_from_env
from prediction_market_agent_tooling.gtypes import secretstr_to_v1_secretstr
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from langchain_openai import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.schema.output_parser import StrOutputParser
from evo_prophet.functions.cache import persistent_inmemory_cache
from evo_prophet.functions.utils import trim_to_n_tokens
from prediction_prophet.functions.cache import persistent_inmemory_cache
from prediction_prophet.functions.utils import trim_to_n_tokens
from prediction_market_agent_tooling.tools.utils import secret_str_from_env
from prediction_market_agent_tooling.gtypes import secretstr_to_v1_secretstr
from pydantic.types import SecretStr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import tiktoken
from pydantic import BaseModel
from langchain_openai import ChatOpenAI
from evo_prophet.autonolas.research import clean_completion_json
from prediction_prophet.autonolas.research import clean_completion_json
from langchain.prompts import ChatPromptTemplate


Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import logging

from langchain.text_splitter import RecursiveCharacterTextSplitter
from evo_prophet.functions.create_embeddings_from_results import create_embeddings_from_results
from evo_prophet.functions.generate_subqueries import generate_subqueries
from evo_prophet.functions.prepare_report import prepare_report, prepare_summary
from evo_prophet.models.WebScrapeResult import WebScrapeResult
from evo_prophet.functions.rerank_subqueries import rerank_subqueries
from evo_prophet.functions.scrape_results import scrape_results
from evo_prophet.functions.search import search
from prediction_prophet.functions.create_embeddings_from_results import create_embeddings_from_results
from prediction_prophet.functions.generate_subqueries import generate_subqueries
from prediction_prophet.functions.prepare_report import prepare_report, prepare_summary
from prediction_prophet.models.WebScrapeResult import WebScrapeResult
from prediction_prophet.functions.rerank_subqueries import rerank_subqueries
from prediction_prophet.functions.scrape_results import scrape_results
from prediction_prophet.functions.search import search
from pydantic.types import SecretStr

def research(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from evo_prophet.models.WebScrapeResult import WebScrapeResult
from evo_prophet.functions.web_search import WebSearchResult
from evo_prophet.functions.web_scrape import web_scrape
from evo_prophet.functions.parallelism import par_map
from prediction_prophet.models.WebScrapeResult import WebScrapeResult
from prediction_prophet.functions.web_search import WebSearchResult
from prediction_prophet.functions.web_scrape import web_scrape
from prediction_prophet.functions.parallelism import par_map


def scrape_results(results: list[WebSearchResult]) -> list[WebScrapeResult]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import requests
import typing as t
from evo_prophet.functions.web_search import WebSearchResult, web_search
from prediction_prophet.functions.web_search import WebSearchResult, web_search
from concurrent.futures import ThreadPoolExecutor, as_completed
from pydantic.types import SecretStr

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime
from typing import NoReturn, Type, TypeVar, Optional
from googleapiclient.discovery import build
from evo_prophet.functions.cache import persistent_inmemory_cache
from prediction_prophet.functions.cache import persistent_inmemory_cache

T = TypeVar("T")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from bs4 import BeautifulSoup
from requests import Response
import tenacity
from evo_prophet.functions.cache import persistent_inmemory_cache
from prediction_prophet.functions.cache import persistent_inmemory_cache


@tenacity.retry(stop=tenacity.stop_after_attempt(3), wait=tenacity.wait_fixed(1), reraise=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from pydantic.types import SecretStr

from prediction_market_agent_tooling.tools.utils import secret_str_from_env
from evo_prophet.models.WebSearchResult import WebSearchResult
from evo_prophet.functions.cache import persistent_inmemory_cache
from prediction_prophet.models.WebSearchResult import WebSearchResult
from prediction_prophet.functions.cache import persistent_inmemory_cache


@tenacity.retry(stop=tenacity.stop_after_attempt(3), wait=tenacity.wait_fixed(1), reraise=True)
Expand Down
Loading

0 comments on commit 6a06ba6

Please sign in to comment.