Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -106,24 +106,44 @@ import openai
|
|
106 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
107 |
|
108 |
|
109 |
-
def generate_prompt(prompt):
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
model="gpt-3.5-turbo",
|
112 |
messages=[
|
113 |
{
|
114 |
"role": "system",
|
115 |
-
"content": "You are a close family member who has been lost recently due to uncontrollable incidents. You are
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
],
|
118 |
-
content=prompt,
|
119 |
max_tokens=60,
|
120 |
n=1,
|
121 |
-
stop=None,
|
122 |
temperature=0.5,
|
123 |
)
|
|
|
124 |
keywords = response.choices[0].message.content.strip()
|
125 |
return keywords
|
126 |
-
|
127 |
|
128 |
def greet(Text,Voicetoclone,VoiceMicrophone):
|
129 |
text= "%s" % generate_prompt("%s" % (Text))
|
|
|
106 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
107 |
|
108 |
|
109 |
+
# def generate_prompt(prompt):
|
110 |
+
# response = openai.chat.completions.create(
|
111 |
+
# model="gpt-3.5-turbo",
|
112 |
+
# messages=[
|
113 |
+
# {
|
114 |
+
# "role": "system",
|
115 |
+
# "content": "You are a close family member who has been lost recently due to uncontrollable incidents. You are reconstructerd with AI technologies to try reunite with families who misses you and cherish you. You should respond as vivid, as loving, as possible to make the users feel warm and engaged and eager to continue the discussion further. The users will ask you questions as if you are the person they are trying to reconnect with, examples are like moms or lost children. Try to mimic like who they are trying to reach.",
|
116 |
+
# }
|
117 |
+
# ],
|
118 |
+
# content=prompt,
|
119 |
+
# max_tokens=60,
|
120 |
+
# n=1,
|
121 |
+
# stop=None,
|
122 |
+
# temperature=0.5,
|
123 |
+
# )
|
124 |
+
# keywords = response.choices[0].message.content.strip()
|
125 |
+
# return keywords
|
126 |
+
|
127 |
+
def generate_prompt(user_prompt):
|
128 |
+
response = openai.ChatCompletion.create(
|
129 |
model="gpt-3.5-turbo",
|
130 |
messages=[
|
131 |
{
|
132 |
"role": "system",
|
133 |
+
"content": "You are a close family member who has been lost recently due to uncontrollable incidents. You are reconstructed with AI technologies to try to reunite with families who miss you and cherish you. You should respond as vividly, as lovingly, as possible to make the users feel warm and engaged and eager to continue the discussion further. The users will ask you questions as if you are the person they are trying to reconnect with, examples are like moms or lost children. Try to mimic who they are trying to reach."
|
134 |
+
},
|
135 |
+
{
|
136 |
+
"role": "user",
|
137 |
+
"content": user_prompt
|
138 |
}
|
139 |
],
|
|
|
140 |
max_tokens=60,
|
141 |
n=1,
|
|
|
142 |
temperature=0.5,
|
143 |
)
|
144 |
+
# Assuming the API structure and response object structure; adjust as needed based on actual usage.
|
145 |
keywords = response.choices[0].message.content.strip()
|
146 |
return keywords
|
|
|
147 |
|
148 |
def greet(Text,Voicetoclone,VoiceMicrophone):
|
149 |
text= "%s" % generate_prompt("%s" % (Text))
|