File size: 2,697 Bytes
7ad45a6
85ea247
71d5cad
 
85ea247
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71d5cad
 
 
 
 
 
 
 
 
 
 
 
 
 
85ea247
71d5cad
 
85ea247
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71d5cad
 
 
 
 
 
 
 
 
 
 
 
 
 
85ea247
 
71d5cad
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
import pytorch
from transformers import MllamaForConditionalGeneration, AutoProcessor

# Initialize Llama model
model_id = "meta-llama/Llama-3.2-11B-Vision-Instruct"
model = MllamaForConditionalGeneration.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
processor = AutoProcessor.from_pretrained(model_id)

def generate_text(prompt, max_new_tokens=200):
    messages = [
        {"role": "user", "content": [
            {"type": "text", "text": prompt}
        ]}
    ]
    input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
    inputs = processor(
        input_text,
        add_special_tokens=False,
        return_tensors="pt"
    ).to(model.device)
    
    output = model.generate(**inputs, max_new_tokens=max_new_tokens)
    return processor.decode(output[0], skip_special_tokens=True)

def generate_company_profile(user_data):
    prompt = f"""
    Generate a concise company profile based on the following information:
    
    Project Description: {user_data['project_description']}
    Industry: {user_data['industry']}
    Target Market: {user_data['market']}
    Location: {user_data['location']}
    Founders: {', '.join([f['name'] for f in user_data['founders_info']])}
    
    Company Profile:
    """
    
    return generate_text(prompt, max_new_tokens=200)

def calculate_fundraising_score(user_data):
    prompt = f"""
    Based on the following company information, provide a fundraising probability score between 0 and 100:
    
    Project Description: {user_data['project_description']}
    Industry: {user_data['industry']}
    Target Market: {user_data['market']}
    Location: {user_data['location']}
    Number of Founders: {len(user_data['founders_info'])}
    
    Fundraising Probability Score (0-100):
    """
    
    response = generate_text(prompt, max_new_tokens=10)
    try:
        score = int(response.strip())
        return max(0, min(100, score))  # Ensure the score is between 0 and 100
    except ValueError:
        return 50  # Default score if parsing fails

def generate_recommendations(user_data):
    prompt = f"""
    Based on the following company information, provide 3-5 recommendations to improve fundraising success:
    
    Project Description: {user_data['project_description']}
    Industry: {user_data['industry']}
    Target Market: {user_data['market']}
    Location: {user_data['location']}
    Number of Founders: {len(user_data['founders_info'])}
    
    Recommendations:
    """
    
    response = generate_text(prompt, max_new_tokens=300)
    recommendations = response.strip().split('\n')
    return [rec.strip() for rec in recommendations if rec.strip()]