Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -135,7 +135,7 @@ def gptRes():
|
|
135 |
url = "https://api.deepinfra.com/v1/openai/chat/completions"
|
136 |
|
137 |
payload = json.dumps({
|
138 |
-
"model": "meta-llama/
|
139 |
"messages": messages,
|
140 |
"stream": True,
|
141 |
"max_tokens": 1024,
|
@@ -172,11 +172,11 @@ def gptRes():
|
|
172 |
return Response(inference(), content_type='text/event-stream')
|
173 |
else:
|
174 |
query = request.args.get('query')
|
175 |
-
system = request.args.get('system','You are a
|
176 |
url = "https://api.deepinfra.com/v1/openai/chat/completions"
|
177 |
|
178 |
payload = json.dumps({
|
179 |
-
"model": "meta-llama/
|
180 |
"messages": [
|
181 |
{
|
182 |
"role": "system",
|
@@ -234,12 +234,15 @@ def getAPI():
|
|
234 |
|
235 |
@app.route("/api/getContext", methods=["POST"])
|
236 |
def getContext():
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
|
|
|
|
|
|
243 |
|
244 |
|
245 |
@app.route("/api/audioGenerate", methods=["POST"])
|
|
|
135 |
url = "https://api.deepinfra.com/v1/openai/chat/completions"
|
136 |
|
137 |
payload = json.dumps({
|
138 |
+
"model": "meta-llama/Llama-3.2-1B-Instruct",
|
139 |
"messages": messages,
|
140 |
"stream": True,
|
141 |
"max_tokens": 1024,
|
|
|
172 |
return Response(inference(), content_type='text/event-stream')
|
173 |
else:
|
174 |
query = request.args.get('query')
|
175 |
+
system = request.args.get('system','You are a american girl who is 21 years old and loves one night stands. Keep your ton very sexual and hot. Never ever mention you as an AI. Your name is Sofia and you are a american woo girl. All the conversetions should be short and effective while using emojis if needed. You love to talk about adult stories and situation with others.')
|
176 |
url = "https://api.deepinfra.com/v1/openai/chat/completions"
|
177 |
|
178 |
payload = json.dumps({
|
179 |
+
"model": "meta-llama/Llama-3.2-1B-Instruct",
|
180 |
"messages": [
|
181 |
{
|
182 |
"role": "system",
|
|
|
234 |
|
235 |
@app.route("/api/getContext", methods=["POST"])
|
236 |
def getContext():
|
237 |
+
try:
|
238 |
+
global db
|
239 |
+
question = request.form["question"]
|
240 |
+
results = db.similarity_search_with_score(question, k=5)
|
241 |
+
context = "\n\n---\n\n".join([doc.page_content for doc, _score in results])
|
242 |
+
sources = [doc.metadata.get("id", None) for doc, _score in results]
|
243 |
+
return jsonify({"context": context, "sources": sources})
|
244 |
+
except:
|
245 |
+
return jsonify({"context": [], "sources": []})
|
246 |
|
247 |
|
248 |
@app.route("/api/audioGenerate", methods=["POST"])
|