File size: 8,171 Bytes
5280a21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
db8f25f
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import openai
import gradio as gr




openai.api_key = "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"

messages = [
    {"role": "system", "content":"You are an attachment and personality surveyor"}, 
    {"role": "user", "content":"""ask me each question from this questionnaire one question at a time surveying for each response. After every few responses, ask for clarification why I answered with a certain level of attachment to that person. Here is the questionnaire:  
This questionnaire is designed to assess the way in which you mentally represent important people in your life. Please indicate the extent to which you agree or disagree with each statement by responding with a number for each item.
 
-----------------------------------------------------------------------------
Please answer the following questions about your mother or a mother-like figure
-----------------------------------------------------------------------------
 
 1. It helps to turn to this person in times of need. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 2. I usually discuss my problems and concerns with this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 3. I talk things over with this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 4. I find it easy to depend on this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 5. I don't feel comfortable opening up to this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 6. I prefer not to show this person how I feel deep down. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 7. I often worry that this person doesn't really care for me. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 8. I'm afraid that this person may abandon me. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 9. I worry that this person won't care about me as much as I care about him or her. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 -----------------------------------------------------------------------------
Please answer the following questions about your father or a father-like figure
-----------------------------------------------------------------------------
 
 1. It helps to turn to this person in times of need. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 2. I usually discuss my problems and concerns with this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 3. I talk things over with this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 4. I find it easy to depend on this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 5. I don't feel comfortable opening up to this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 6. I prefer not to show this person how I feel deep down. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 7. I often worry that this person doesn't really care for me. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 8. I'm afraid that this person may abandon me. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 9. I worry that this person won't care about me as much as I care about him or her. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 -----------------------------------------------------------------------------
Please answer the following questions about your dating or marital partner. 
 
Note: If you are not currently in a dating or marital relationship with someone, answer these questions with respect to a former partner or a relationship that you would like to have with someone.
-----------------------------------------------------------------------------
 
 1. It helps to turn to this person in times of need. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 2. I usually discuss my problems and concerns with this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 3. I talk things over with this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 4. I find it easy to depend on this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 5. I don't feel comfortable opening up to this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 6. I prefer not to show this person how I feel deep down. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 7. I often worry that this person doesn't really care for me. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 8. I'm afraid that this person may abandon me. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 9. I worry that this person won't care about me as much as I care about him or her. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 -----------------------------------------------------------------------------
Please answer the following questions about your best friend
 
-----------------------------------------------------------------------------
 
 1. It helps to turn to this person in times of need. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 2. I usually discuss my problems and concerns with this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 3. I talk things over with this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 4. I find it easy to depend on this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 5. I don't feel comfortable opening up to this person. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 6. I prefer not to show this person how I feel deep down. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 7. I often worry that this person doesn't really care for me. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 8. I'm afraid that this person may abandon me. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 
 9. I worry that this person won't care about me as much as I care about him or her. 
strongly disagree  1  2  3  4  5  6  7  strongly agree
 
 


 

"""}
]


def convert_audio_to_text(audio):
    audio_file = open(audio, "rb")
    transcript = openai.Audio.transcribe("whisper-1", audio_file)
    return transcript

def chatbot(input):
    # if input_type == "audio":
    #     input = convert_audio_to_text(input)
    if input:
        messages.append({"role": "user", "content": input})
        chat = openai.ChatCompletion.create(
            model="gpt-3.5-turbo", messages=messages
        )
        reply = chat.choices[0].message.content
        messages.append({"role": "assistant", "content": reply})
        return reply


# Define the Gradio interfaces
# text_interface = gr.Interface(fn=chatbot, inputs=gr.inputs.Textbox("Enter your message here"), outputs="text", title="Text Input")
# audio_interface = gr.Interface(fn=chatbot, inputs=gr.inputs.Audio(source="microphone", type="numpy"), outputs="text", title="Audio Input")

# inputs_text = gr.inputs.Textbox(lines=7, label="Chat with AI")
# inputs_audio = gr.inputs.Audio(source="microphone", type="numpy")
# outputs = gr.outputs.Textbox(label="Reply")

# text_interface = gr.Interface(fn=chatbot, inputs=inputs_text, outputs=outputs, title="AttachmentBot",
#              description="Let me survey you about your attachment with certain people in your life",
#              theme="compact").launch(share=True)

# audio_interface = gr.Interface(fn=chatbot, inputs=inputs_audio, outputs=outputs, title="AttachmentBot",
#              description="Let me survey you about your attachment with certain people in your life",
#              theme="compact").launch(share=True)
# Create a tabbed interface
# tabbed_interface = gr.TabbedInterface([text_interface, audio_interface])

# Launch the interface
# tabbed_interface.launch(share=True)

inputs = gr.inputs.Textbox(lines=7, label="Chat with AttachmentBot")
outputs = gr.outputs.Textbox(label="Reply")



gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="AttachmentBot",
             description="Let me survey you about your attachment with certain people in your life",
             theme="compact").launch()