mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-14 07:59:00 +03:00
parent
35f5fe0958
commit
de3ab00f3d
@ -35,13 +35,6 @@ Quivr, your second brain, utilizes the power of GenerativeAI to store and retrie
|
||||
|
||||
https://github.com/StanGirard/quivr/assets/19614572/a6463b73-76c7-4bc0-978d-70562dca71f5
|
||||
|
||||
## Disclaimer ⚠️
|
||||
|
||||
For a little while, Quivr will be only compatible with OpenAI API.
|
||||
|
||||
If you want to use a Local LLM please refer to [v0.0.46](https://github.com/StanGirard/quivr/releases/tag/v0.0.46).
|
||||
|
||||
This is due to us preparing a big feature and needing to clean the code a bit.
|
||||
|
||||
## Getting Started 🚀
|
||||
|
||||
@ -112,8 +105,6 @@ Additionally, you'll need a [Supabase](https://supabase.com/) account for:
|
||||
|
||||
> _The `NEXT_PUBLIC_BACKEND_URL` is set to localhost:5050 for the docker. Update it if you are running the backend on a different machine._
|
||||
|
||||
> _To activate vertexAI with PaLM from GCP follow the instructions [here](https://python.langchain.com/en/latest/modules/models/llms/integrations/google_vertex_ai_palm.html) and update `backend/.env`- It is an advanced feature, please be expert in GCP before trying to use it_
|
||||
|
||||
- Change variables in `backend/.env`
|
||||
- Change variables in `frontend/.env`
|
||||
|
||||
|
5
connectors/telegram_bot/.env.example
Normal file
5
connectors/telegram_bot/.env.example
Normal file
@ -0,0 +1,5 @@
|
||||
TELEGRAM_BOT_TOKEN=XXXX
|
||||
QUIVR_TOKEN=XXXX
|
||||
QUIVR_CHAT_ID=1XXXX
|
||||
QUIVR_BRAIN_ID=XXXX
|
||||
QUIVR_URL=XXXX
|
73
connectors/telegram_bot/main.py
Normal file
73
connectors/telegram_bot/main.py
Normal file
@ -0,0 +1,73 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
import requests
|
||||
from dotenv import load_dotenv
|
||||
from telegram import Update
|
||||
from telegram.ext import (
|
||||
ApplicationBuilder,
|
||||
CommandHandler,
|
||||
ContextTypes,
|
||||
MessageHandler,
|
||||
filters,
|
||||
)
|
||||
|
||||
load_dotenv() # Load variables from .env file
|
||||
|
||||
logging.basicConfig(
|
||||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
|
||||
)
|
||||
|
||||
telegram_bot_token = os.getenv("TELEGRAM_BOT_TOKEN", "")
|
||||
quivr_token = os.getenv("QUIVR_TOKEN", "")
|
||||
quivr_chat_id = os.getenv("QUIVR_CHAT_ID", "")
|
||||
quivr_brain_id = os.getenv("QUIVR_BRAIN_ID", "")
|
||||
quivr_url = (
|
||||
os.getenv("QUIVR_URL", "https://api.quivr.app")
|
||||
+ f"/chat/{quivr_chat_id}/question?brain_id={quivr_brain_id}"
|
||||
)
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer " + quivr_token,
|
||||
}
|
||||
|
||||
|
||||
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
await context.bot.send_message(
|
||||
chat_id=update.effective_chat.id,
|
||||
text="I'm Quiv's bot and can answer any question. Please ask your question.",
|
||||
)
|
||||
|
||||
|
||||
async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
user_message = update.message.text
|
||||
response = requests.post(
|
||||
quivr_url, headers=headers, json={"question": user_message}
|
||||
)
|
||||
if response.status_code == 200:
|
||||
quivr_response = response.json().get(
|
||||
"assistant", "Sorry, I couldn't understand that."
|
||||
)
|
||||
await context.bot.send_message(
|
||||
chat_id=update.effective_chat.id, text=quivr_response
|
||||
)
|
||||
else:
|
||||
# Log or print the response for debugging
|
||||
print(f"Error: {response.status_code}, {response.text}")
|
||||
await context.bot.send_message(
|
||||
chat_id=update.effective_chat.id,
|
||||
text=f"Sorry, there was an error processing your request. {response.text}",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
application = ApplicationBuilder().token(telegram_bot_token).build()
|
||||
|
||||
start_handler = CommandHandler("start", start)
|
||||
message_handler = MessageHandler(filters.TEXT & (~filters.COMMAND), handle_message)
|
||||
|
||||
application.add_handler(start_handler)
|
||||
application.add_handler(message_handler)
|
||||
|
||||
application.run_polling()
|
8
docs/docs/Developers/connectors/_category_.json
Normal file
8
docs/docs/Developers/connectors/_category_.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"label": "📲 Connect Quivr to ...",
|
||||
"position": 3,
|
||||
"link": {
|
||||
"type": "generated-index",
|
||||
"description": "Connect Quivr to anything"
|
||||
}
|
||||
}
|
34
docs/docs/Developers/connectors/telegram.md
Normal file
34
docs/docs/Developers/connectors/telegram.md
Normal file
@ -0,0 +1,34 @@
|
||||
---
|
||||
title: Telegram
|
||||
---
|
||||
|
||||
## Load a Telegram chat
|
||||
|
||||
- You can export your Telegram chat history using the [Telegram Desktop](https://desktop.telegram.org/) app.
|
||||
- Go to Settings > Advanced > Export Telegram data
|
||||
- Select the chat you want to export
|
||||
- Select the format `Machine-readable JSON`
|
||||
- Click `Export`
|
||||
- Rename the `json` to `<yourname>.telegram`
|
||||
- Go to [Quivr.app](https://quivr.app/) and upload the file to a brain
|
||||
- You can now search your Telegram chat history!
|
||||
|
||||
## Create a telegram bot
|
||||
|
||||
- Go to [BotFather](https://t.me/botfather) and create a new bot
|
||||
- Copy the token
|
||||
- Go to `/connectors/telegram` and copy-paste the .env.example file
|
||||
- `TELEGRAM_BOT_TOKEN` The token you copied from BotFather
|
||||
- `QUIVR_TOKEN` The API Key of Quivr you can find in your profile
|
||||
- `QUIVR_CHAT_ID` Create a new chat in Quivr and copy the ID from the URL
|
||||
- `QUIVR_BRAIN_ID` Copy the id of the brain on which you want to ask question to
|
||||
- `QUIVR_URL` The URL of the **API** of the Quivr instance you want to use
|
||||
|
||||
Enjoy ! 🎉
|
||||
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<video width="640" height="480" controls>
|
||||
<source src="https://quivr-cms.s3.eu-west-3.amazonaws.com/quivr_telegram_bot_283a935f26.mp4" type="video/mp4"/>
|
||||
Your browser does not support the video tag.
|
||||
</video>
|
||||
</div>
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
sidebar_position: 4
|
||||
title: 📍 Run Quivr fully locally
|
||||
---
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user