mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Update automations to call new POST chat API endpoint
This commit is contained in:
parent
055ead550c
commit
de60ad7da6
1 changed files with 3 additions and 4 deletions
|
@ -1201,11 +1201,10 @@ def scheduled_chat(
|
|||
query_dict["conversation_id"] = [conversation_id]
|
||||
|
||||
# Construct the URL to call the chat API with the scheduled query string
|
||||
encoded_query = urlencode(query_dict, doseq=True)
|
||||
url = f"{scheme}://{calling_url.netloc}/api/chat?{encoded_query}"
|
||||
url = f"{scheme}://{calling_url.netloc}/api/chat?client=khoj"
|
||||
|
||||
# Construct the Headers for the chat API
|
||||
headers = {"User-Agent": "Khoj"}
|
||||
headers = {"User-Agent": "Khoj", "Content-Type": "application/json"}
|
||||
if not state.anonymous_mode:
|
||||
# Add authorization request header in non-anonymous mode
|
||||
token = get_khoj_tokens(user)
|
||||
|
@ -1216,7 +1215,7 @@ def scheduled_chat(
|
|||
headers["Authorization"] = f"Bearer {token}"
|
||||
|
||||
# Call the chat API endpoint with authenticated user token and query
|
||||
raw_response = requests.get(url, headers=headers)
|
||||
raw_response = requests.post(url, headers=headers, json=query_dict)
|
||||
|
||||
# Stop if the chat API call was not successful
|
||||
if raw_response.status_code != 200:
|
||||
|
|
Loading…
Reference in a new issue