Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,38 +7,20 @@ headers = {
|
|
| 7 |
"User -Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
|
| 8 |
}
|
| 9 |
|
| 10 |
-
|
| 11 |
-
if not user_message:
|
| 12 |
-
return "User message is required"
|
| 13 |
|
| 14 |
-
|
| 15 |
-
url = f"https://you.com/api/streamingSearch?page=1&count=10&safeSearch=Moderate&enable_worklow_generation_ux=true&domain=youchat&use_personalization_extraction=false&traceId=&selectedChatMode={ID}&q=CHAT:{chat_history} user:{user_message}"
|
| 16 |
|
| 17 |
-
|
| 18 |
-
response = requests.get(url, headers=headers, stream=True)
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
for line in response.iter_lines():
|
| 23 |
-
if line:
|
| 24 |
-
decoded_line = line.decode('utf-8')
|
| 25 |
-
if 'youChatToken' in decoded_line and 'data: ' in decoded_line:
|
| 26 |
-
data = json.loads(decoded_line.split('data: ')[1])
|
| 27 |
-
model_response += data["youChatToken"]
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
"#### You've hit your free quota for the Custom Agent. For more usage of the Custom Agent, learn more at: https://you.com/plans.\n\nAnswering your question without the Custom Agent:\n",
|
| 32 |
-
""
|
| 33 |
-
).replace("AI CORVO: ", "").replace("Ana: ", "").strip()
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
-
user_message = "HI"
|
| 38 |
|
| 39 |
-
chat_history = "user: Hey there"
|
| 40 |
|
| 41 |
-
ID = "user_mode_e06ed9c3-ad9c-4e22-8e3a-9f5775bdd6db"
|
| 42 |
-
response = get_ai_response(user_message, chat_history, ID)
|
| 43 |
-
print("AI Response:", response)
|
| 44 |
|
|
|
|
| 7 |
"User -Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
|
| 8 |
}
|
| 9 |
|
| 10 |
+
user_message = "HI"
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
chat_history = "user: Hey there"
|
|
|
|
| 13 |
|
| 14 |
+
ID = "user_mode_e06ed9c3-ad9c-4e22-8e3a-9f5775bdd6db"
|
|
|
|
| 15 |
|
| 16 |
+
# Construct the URL for you.com API request
|
| 17 |
+
url = f"https://you.com/api/streamingSearch?page=1&count=10&safeSearch=Moderate&enable_worklow_generation_ux=true&domain=youchat&use_personalization_extraction=false&traceId=&selectedChatMode={ID}&q=CHAT:{chat_history} user:{user_message}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
# Send the request to you.com
|
| 20 |
+
response = requests.get(url, headers=headers, stream=True)
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
print(response.text)
|
| 23 |
|
|
|
|
| 24 |
|
|
|
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
|