Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,22 +9,22 @@ def chat_with_pdf(content):
|
|
| 9 |
return "API key (CHATPDFKEY) not set in environment variables."
|
| 10 |
|
| 11 |
headers = {
|
| 12 |
-
|
| 13 |
"Content-Type": "application/json",
|
| 14 |
}
|
| 15 |
|
| 16 |
data = {
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
{
|
| 21 |
-
|
| 22 |
-
|
| 23 |
},
|
| 24 |
],
|
| 25 |
}
|
| 26 |
|
| 27 |
-
url =
|
| 28 |
|
| 29 |
try:
|
| 30 |
response = requests.post(url, json=data, headers=headers, stream=True)
|
|
|
|
| 9 |
return "API key (CHATPDFKEY) not set in environment variables."
|
| 10 |
|
| 11 |
headers = {
|
| 12 |
+
'x-api-key': api_key,
|
| 13 |
"Content-Type": "application/json",
|
| 14 |
}
|
| 15 |
|
| 16 |
data = {
|
| 17 |
+
'stream': True,
|
| 18 |
+
'sourceId': 'src_opPediV0GhSqCEGkOph7S', # Replace with your source ID
|
| 19 |
+
'messages'': [
|
| 20 |
{
|
| 21 |
+
'role': "user",
|
| 22 |
+
'content': content,
|
| 23 |
},
|
| 24 |
],
|
| 25 |
}
|
| 26 |
|
| 27 |
+
url = 'https://api.chatpdf.com/v1/chats/message'
|
| 28 |
|
| 29 |
try:
|
| 30 |
response = requests.post(url, json=data, headers=headers, stream=True)
|