File size: 2,304 Bytes
807e9b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0b07648
 
 
 
 
 
 
 
 
 
 
 
 
 
807e9b3
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from openai import OpenAI
from dotenv import load_dotenv

from datetime import datetime
import json
import os
load_dotenv()

key=os.getenv("Langchain")
client = OpenAI(
  base_url="https://openrouter.ai/api/v1",
  api_key=key,
)

completion = client.chat.completions.create(
  model="z-ai/glm-4.5-air:free",
  messages=[
    {
      "role": "user",
      "content": "What is the meaning of life?"
    }
  ]
)

# print(completion.choices[0].message.content)
refine_prompt = lambda idea: f"""You are a startup advisor.
Refine this raw startup idea into a clearer concept.

Raw Idea: {idea}

Refined Idea:"""

market_prompt = lambda refined: f"""Analyze this startup idea:
{refined}

Give:
1. Problem it solves
2. Target audience
3. Estimated market size
(Short and concise)."""

slides_prompt = lambda refined: f"""Create a 5-slide pitch summary for this idea:
{refined}

Each slide should include:
- A title
- 2 bullet points
Keep it punchy and startup-pitch style."""

def ask_model(prompt, model="mistralai/mistral-7b-instruct"):
    completion = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": prompt}]
    )
    return completion.choices[0].message.content.strip()

def refine_startup_idea(raw_idea):
    refined = ask_model(refine_prompt(raw_idea))
    market_info = ask_model(market_prompt(refined))
    slides = ask_model(slides_prompt(refined))

    result = {
        "timestamp": datetime.now().isoformat(),
        "raw_idea": raw_idea,
        "refined_idea": refined,
        "market_info": market_info,
        "slide_summary": slides
    }

    return result
# def save_result(result, folder="refined_ideas"):
#     os.makedirs(folder, exist_ok=True)
#     filename = f"{folder}/idea_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
#     with open(filename, "w") as f:
#         json.dump(result, f, indent=2)
#     print(f"✅ Saved to {filename}")
# # idea = input("💡 Enter your startup idea: ")
# # result = refine_startup_idea(idea)

# # print("\n🧠 Refined Idea:\n", result["refined_idea"])
# # print("\n📊 Market Info:\n", result["market_info"])
# # print("\n📽️ Slide Summary:\n", result["slide_summary"])

# # save_result(result)

def run_refiner(raw_idea):
    result = refine_startup_idea(raw_idea)
    return result