Skip to content

Commit

Permalink
Resolve with main
Browse files Browse the repository at this point in the history
  • Loading branch information
sabaimran committed Nov 9, 2024
2 parents 0a6d067 + 1c41ed3 commit 5fbe583
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center"><img src="assets/khoj-logo-sideways-200.png" width="230" alt="Khoj Logo"></p>
<p align="center"><img src="assets/khoj-logo-sideways-500.png" width="250" alt="Khoj Logo"></p>

<div align="center">
<b>An AI assistant that learns with you as you grow.</b>
<b>An open, personal AI that grows with you.</b>
</div>

<br />
Expand All @@ -20,16 +20,16 @@

***

flint is an open source, AI personal assistant.<br />
You can converse with it anytime over Whatsapp via Twilio.<br />
Flint makes Khoj, your personal AI, accessible over Whatsapp.<br />
So you can converse with it easily, on your phone or computer.<br />

***

</div>

## ⭐️ Chat with Khoj on WhatsApp

If you want to start chatting with our cloud-instance of Khoj right away, you have two options:
If you want to start chatting with our hosted Khoj right away, you have two options:

1. 🪧 Use the QR code
- Scan the QR code below using your phone's camera.
Expand Down
Binary file removed assets/khoj-logo-sideways-200.png
Binary file not shown.
Binary file added assets/khoj-logo-sideways-500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 10 additions & 9 deletions src/flint/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

logger = logging.getLogger(__name__)

KHOJ_CHAT_API_ENDPOINT = f"{KHOJ_API_URL}/api/chat?client_id={KHOJ_API_CLIENT_ID}"
KHOJ_CHAT_API_ENDPOINT = f"{KHOJ_API_URL}/api/chat?client_id={KHOJ_API_CLIENT_ID}&client=whatsapp"
KHOJ_INDEX_API_ENDPOINT = f"{KHOJ_API_URL}/api/v1/index/update?client_id={KHOJ_API_CLIENT_ID}&client=whatsapp"

KHOJ_CLOUD_API_SESSION = Session()
Expand Down Expand Up @@ -126,7 +126,6 @@ def send_message_to_khoj_chat(user_message: str, user_number: str) -> str:
Send the user message to the backend LLM service and return the response
"""
start_time = time.time()
encoded_phone_number = urllib.parse.quote(user_number)

if user_message.startswith(tuple(UNIMPLEMENTED_COMMANDS.keys())):
return {
Expand All @@ -142,13 +141,15 @@ def send_message_to_khoj_chat(user_message: str, user_number: str) -> str:
else:
user_message = f"/default {user_message}"

encoded_phone_number = urllib.parse.quote(user_number)
khoj_api = f"{KHOJ_CHAT_API_ENDPOINT}&phone_number={encoded_phone_number}&create_if_not_exists=true"

body_data = {
"q": user_message,
"stream": False,
}
response = KHOJ_CLOUD_API_SESSION.post(khoj_api, json=body_data)
response = KHOJ_CLOUD_API_SESSION.post(
khoj_api,
json={
"q": user_message,
"stream": False,
},
)

end_time = time.time()
response_time = end_time - start_time
Expand Down Expand Up @@ -176,7 +177,7 @@ def send_message_to_khoj_chat(user_message: str, user_number: str) -> str:
)
return {"response": "Sorry, I'm having trouble understanding you. Could you please try again?"}
except Exception as e:
logger.exception("An unexpected error occurred while processing the response from Khoj.")
logger.exception(f"An unexpected error occurred while processing the response from Khoj.\nError: {e}")
return {"response": "I encountered an unexpected issue. Could you please try again?"}


Expand Down

0 comments on commit 5fbe583

Please sign in to comment.