File size: 1,448 Bytes
e7f02ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain_openai import ChatOpenAI
from utils.encrypt import decrypt_api_key
import os
from dotenv import load_dotenv
prompt_template = PromptTemplate.from_template("""

You're an expert startup evaluator.



Your task is to check whether the following input is a valid startup idea or not .

respond with "yes" if it is a valid startup idea, otherwise respond with "no" .

Input contains all these details:

Idea name:{name}

problem statement:{problem_statement}

solution:{solution}

target market:{target_market}

business model:{business_model}



only respond with "yes" or "no", nothing else.

""")
load_dotenv()
# validator_chain = prompt_template | llm


def validate_idea(api,idea):
    llm = ChatOpenAI(
        model=api["model_name"], 
        temperature=api["temperature"],
        openai_api_key=decrypt_api_key(api["apikey"]),
        openai_api_base=api["provider_url"],
    )
    validator_chain = prompt_template | llm
    return validator_chain.invoke({
        "name": idea.get("name", "not available"),
        "problem_statement": idea.get("problem_statement", "not available"),
        "solution": idea.get("solution", "not available"),
        "target_market": idea.get("target_market", "not available"),
        "business_model": idea.get("business_model", "not available")
    }).content.strip().lower()