Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,11 +3,11 @@ import requests
|
|
| 3 |
import re
|
| 4 |
import time
|
| 5 |
|
| 6 |
-
#
|
| 7 |
TOGETHER_API_KEY = "tgp_v1_ZytvDbMu9PMwIlnBZEfYSq9nzJAYwS0MecjY9Kt7RxE"
|
| 8 |
SERPER_API_KEY = "75f06519187851ad63486c3012b34c5e0e6501f1"
|
| 9 |
|
| 10 |
-
#
|
| 11 |
def generate_startup_ideas(prompt, retries=3, delay=2):
|
| 12 |
url = "https://api.together.xyz/v1/completions"
|
| 13 |
headers = {
|
|
@@ -50,7 +50,7 @@ Each idea should be short, clear, and numbered like this:
|
|
| 50 |
|
| 51 |
return []
|
| 52 |
|
| 53 |
-
#
|
| 54 |
def market_research(query):
|
| 55 |
url = "https://google.serper.dev/search"
|
| 56 |
headers = {"X-API-KEY": SERPER_API_KEY}
|
|
@@ -63,7 +63,7 @@ def market_research(query):
|
|
| 63 |
print("Market research error:", e)
|
| 64 |
return ["β Market research failed."]
|
| 65 |
|
| 66 |
-
#
|
| 67 |
st.set_page_config(page_title="Startup Co-Founder Agent", layout="centered")
|
| 68 |
st.title("π Startup Co-Founder Agent")
|
| 69 |
st.write("Get startup ideas + instant market research. Free & AI-powered.")
|
|
@@ -74,7 +74,7 @@ if st.button("Generate Startup Ideas"):
|
|
| 74 |
if not TOGETHER_API_KEY or not SERPER_API_KEY:
|
| 75 |
st.error("API keys are missing. Set them in environment or Hugging Face Secrets.")
|
| 76 |
else:
|
| 77 |
-
with st.spinner("Brewing ideas with GPUs and coffee... βπ€"):
|
| 78 |
ideas = generate_startup_ideas(user_prompt)
|
| 79 |
|
| 80 |
if not ideas:
|
|
@@ -91,84 +91,3 @@ if st.button("Generate Startup Ideas"):
|
|
| 91 |
results = market_research(title)
|
| 92 |
for r in results:
|
| 93 |
st.markdown(f"- {r}")
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
# # Trying to explore new Agentic AI
|
| 101 |
-
|
| 102 |
-
# import streamlit as st
|
| 103 |
-
# import requests
|
| 104 |
-
# import re
|
| 105 |
-
# import os
|
| 106 |
-
|
| 107 |
-
# # APIs that i used
|
| 108 |
-
# TOGETHER_API_KEY = "tgp_v1_ZytvDbMu9PMwIlnBZEfYSq9nzJAYwS0MecjY9Kt7RxE"
|
| 109 |
-
# SERPER_API_KEY = "75f06519187851ad63486c3012b34c5e0e6501f1"
|
| 110 |
-
|
| 111 |
-
# # Prompting or we can say basix structure
|
| 112 |
-
# def generate_startup_ideas(prompt):
|
| 113 |
-
# url = "https://api.together.xyz/v1/completions"
|
| 114 |
-
# headers = {
|
| 115 |
-
# "Authorization": f"Bearer {TOGETHER_API_KEY}",
|
| 116 |
-
# "Content-Type": "application/json"
|
| 117 |
-
# }
|
| 118 |
-
# data = {
|
| 119 |
-
# "model": "mistralai/Mistral-7B-Instruct-v0.1",
|
| 120 |
-
# "prompt": f"""
|
| 121 |
-
# Suggest 3 unique startup ideas based on this interest: \"{prompt}\".
|
| 122 |
-
# Each idea should be short, clear, and numbered like this:
|
| 123 |
-
# 1. [Idea Title]: [One-sentence description]
|
| 124 |
-
# 2. ...
|
| 125 |
-
# """,
|
| 126 |
-
# "max_tokens": 300,
|
| 127 |
-
# "temperature": 0.7
|
| 128 |
-
# }
|
| 129 |
-
# response = requests.post(url, headers=headers, json=data)
|
| 130 |
-
# result = response.json()
|
| 131 |
-
|
| 132 |
-
# if "choices" not in result:
|
| 133 |
-
# return []
|
| 134 |
-
|
| 135 |
-
# raw_text = result["choices"][0].get("text", "").strip()
|
| 136 |
-
# ideas = re.findall(r"\d+\.\s*(.*?):\s*(.*)", raw_text)
|
| 137 |
-
# return [f"{i+1}. {title.strip()}: {desc.strip()}" for i, (title, desc) in enumerate(ideas)]
|
| 138 |
-
|
| 139 |
-
# # For the url
|
| 140 |
-
# def market_research(query):
|
| 141 |
-
# url = "https://google.serper.dev/search"
|
| 142 |
-
# headers = {"X-API-KEY": SERPER_API_KEY}
|
| 143 |
-
# data = {"q": query}
|
| 144 |
-
# res = requests.post(url, headers=headers, json=data)
|
| 145 |
-
# results = res.json()
|
| 146 |
-
# return [r["title"] + " - " + r["link"] for r in results.get("organic", [])[:5]]
|
| 147 |
-
|
| 148 |
-
# # For UI
|
| 149 |
-
# st.set_page_config(page_title="Startup Co-Founder Agent", layout="centered")
|
| 150 |
-
# st.title("π Startup Co-Founder Agent")
|
| 151 |
-
# st.write("Get startup ideas + instant market research with free AI tools!")
|
| 152 |
-
|
| 153 |
-
# user_prompt = st.text_input("What are you interested in building a startup around?", "AI for education")
|
| 154 |
-
|
| 155 |
-
# if st.button("Generate Startup Ideas"):
|
| 156 |
-
# if not TOGETHER_API_KEY or not SERPER_API_KEY:
|
| 157 |
-
# st.error("API keys are not set. Please configure them in your Hugging Face Space secrets.")
|
| 158 |
-
# else:
|
| 159 |
-
# with st.spinner("Generating ideas and researching..."):
|
| 160 |
-
# ideas = generate_startup_ideas(user_prompt)
|
| 161 |
-
# if not ideas:
|
| 162 |
-
# st.error("No startup ideas generated. Check API keys or try again.")
|
| 163 |
-
# else:
|
| 164 |
-
# st.subheader("π‘ Startup Ideas")
|
| 165 |
-
# for idea in ideas:
|
| 166 |
-
# st.markdown(f"- {idea}")
|
| 167 |
-
|
| 168 |
-
# st.subheader("π Market Research")
|
| 169 |
-
# for idea in ideas:
|
| 170 |
-
# title = idea.split(":")[0].strip()
|
| 171 |
-
# st.markdown(f"**π {title}**")
|
| 172 |
-
# results = market_research(title)
|
| 173 |
-
# for r in results:
|
| 174 |
-
# st.markdown(f"- {r}")
|
|
|
|
| 3 |
import re
|
| 4 |
import time
|
| 5 |
|
| 6 |
+
# APIs
|
| 7 |
TOGETHER_API_KEY = "tgp_v1_ZytvDbMu9PMwIlnBZEfYSq9nzJAYwS0MecjY9Kt7RxE"
|
| 8 |
SERPER_API_KEY = "75f06519187851ad63486c3012b34c5e0e6501f1"
|
| 9 |
|
| 10 |
+
# Genrate Ideas
|
| 11 |
def generate_startup_ideas(prompt, retries=3, delay=2):
|
| 12 |
url = "https://api.together.xyz/v1/completions"
|
| 13 |
headers = {
|
|
|
|
| 50 |
|
| 51 |
return []
|
| 52 |
|
| 53 |
+
# For working on URLs
|
| 54 |
def market_research(query):
|
| 55 |
url = "https://google.serper.dev/search"
|
| 56 |
headers = {"X-API-KEY": SERPER_API_KEY}
|
|
|
|
| 63 |
print("Market research error:", e)
|
| 64 |
return ["β Market research failed."]
|
| 65 |
|
| 66 |
+
# Streamlit UI
|
| 67 |
st.set_page_config(page_title="Startup Co-Founder Agent", layout="centered")
|
| 68 |
st.title("π Startup Co-Founder Agent")
|
| 69 |
st.write("Get startup ideas + instant market research. Free & AI-powered.")
|
|
|
|
| 74 |
if not TOGETHER_API_KEY or not SERPER_API_KEY:
|
| 75 |
st.error("API keys are missing. Set them in environment or Hugging Face Secrets.")
|
| 76 |
else:
|
| 77 |
+
with st.spinner("Brewing ideas with HuggingFace GPUs and coffee... βπ€"):
|
| 78 |
ideas = generate_startup_ideas(user_prompt)
|
| 79 |
|
| 80 |
if not ideas:
|
|
|
|
| 91 |
results = market_research(title)
|
| 92 |
for r in results:
|
| 93 |
st.markdown(f"- {r}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|