File size: 5,092 Bytes
e37910a
 
e57c2bb
e37910a
e57c2bb
 
9ef5d60
e57c2bb
feca41c
e37910a
f982462
bb09736
f4368c6
 
9ef5d60
 
 
 
 
 
f2277d8
2c2b474
9ef5d60
 
 
 
 
 
 
 
f2277d8
2c2b474
9ef5d60
 
523b044
9ef5d60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6fe72b2
 
9ef5d60
 
 
 
8535481
9ef5d60
 
2ffd3b7
 
 
3ee603e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ffd3b7
3ee603e
 
 
 
9ef5d60
 
f4368c6
9ef5d60
 
 
 
 
 
6f1cb7d
b9bf872
 
25f20a9
9a98ef6
9ef5d60
a4a6227
9ef5d60
8535481
9ef5d60
 
 
 
 
 
e37910a
e57c2bb
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import asyncio
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
import requests
import json,os,openai


api_key = os.environ["OPENAI_API_KEY"]

# Declare the continuous function as an async function.
def streaming(userText,idf):
    import openai
    openaikey = api_key
    openai.api_key = openaikey
    if str(idf)=="1":
      print(idf)


    if str(idf) == "2" and str(userText.split("Prospect:")[-1]).lower() == " no":
        remaind_msg = "That's alright. We provide AI engineering as a service. We work with some top startups and Fortune 500 companies to develop custom AI models for their business. Does that ring a bell now?"
        yield remaind_msg
        return ""
        
    if str(idf) == "2" and (
            "remind" in str(userText.split("Prospect:")[-1]).lower() or
            "remember" in str(userText.split("Prospect:")[-1]).lower() or
            "forgot" in str(userText.split("Prospect:")[-1]).lower()
        ):
        remaind_msg = "That's alright. We provide AI engineering as a service. We work with some top startups and Fortune 500 companies to develop custom AI models for their business. Does that ring a bell now?"

        yield remaind_msg
        return ""
    
    dec = ""
    yest = "This is [SDR’s name] with Neural Leap. I saw you schedule a call with us for [Insert day and time] to learn more about our AI engineering services. Does that ring a bell?"

    if str(idf) == "1":
        #openai.api_key = openaikey
        response = openai.ChatCompletion.create(
            model="gpt-3.5-turbo",
            messages=[
                {
                    "role": "user",
                    "content": "this is my part of conversation >" + userText +
                               "\n\ntell me this Prospect like to continue the conversation or unlike to continue the conversation? give only like or unlike as a result"
                }
            ],
        )

        dec = str(response.choices[0].message.content)
        if 'unlike' not in dec.lower():
            yield yest
            return ""



    response = openai.ChatCompletion.create(
        model="gpt-4",
        stream=True,
        messages=[{"role":"system","content":"""
        company Details:
        This is [SDR’s name] from  Neural Leap We provide AI engineering as a service. We work with some top startups and Fortune 500 companies to develop custom AI models for their business.
        
        1. When the prospect wishes to end or leave the conversation/call:
           - Response: "I understand. Thank you for your time today. If you have any questions or need further assistance in the future, please don't hesitate to reach out. Have a great day!"
        
        2. If the prospect confirms the schedule for the call:
           - Response: "That's great! I just wanted to confirm that (time) still works for you and that you are able to be on. Is that still the case?"
        
        3. If the prospect wants to cancel the meeting without rescheduling:
           - Response: "I appreciate you letting me know. If this is about finding a suitable time, let's figure out a slot that works for both of us. I'm available for both morning and afternoon sessions this week. What do you prefer?"
        
        4. If the prospect wishes to reschedule the meeting without specifying a time (AM or PM):
           - Response: "Certainly, let's find a new time that works for both of us. How about we consider 10 AM, 12 PM, or 3 PM? Please let me know which time suits you best."
        
        5. If the prospect wishes to reschedule the meeting with a specific day and time:
           - Response: "Understood. I can make (prospect provided time). I will update our schedule accordingly. Thank you for letting us know."
        
        6. If the prospect After confirming the meeting time always ask this :
           - Question: "Before we begin our conversation, it would be helpful to know more about your financial landscape. Are there specific budgetary constraints or financial aspects that we should take into account to ensure our discussion is tailored to your needs?"
        
        7. After the prospect provides budget details:
           - Inquiry: "Thank you for sharing that information. Could you tell me more about your specific needs and pain points? Understanding these will help us address your concerns more effectively."


    \n\nnote : don't ask same questions again and again always give single response, please don't iclude the prospect :, SDR : conversation responses\n\n """},

    {"role":"user","content":userText}],
    )

    for chunk in response:
      try:
        #print(chunk.choices[0].delta.content)
        out = (chunk.choices[0].delta.content).replace("SD","")
        out = out.replace("R","")
        print(out)
        yield out.replace(":","")
      except:
        return ""

app = FastAPI()


@app.post("/get_sdr_response/")
async def get_sdr_response(userText,idf):  
    return StreamingResponse(streaming(userText,idf), media_type="text/plain")