127 lines
2.5 KiB
Markdown
127 lines
2.5 KiB
Markdown
# RAG-Chat
|
|
|
|
Chat with your Documents/Knowledgebase
|
|
|
|
|
|
## Usage
|
|
|
|
Clone the repo, enter it and run:
|
|
|
|
```
|
|
podman-compose -f docker-compose.yaml up
|
|
```
|
|
|
|
## Structure
|
|
|
|
### Object Storage
|
|
* Minio (http://localhost:9001/)
|
|
|
|
### Vector Storage
|
|
* OpenSearch (Dashboard under: http://localhost:5601/)
|
|
|
|
### RAG-Backend
|
|
* API-Docs http://localhost:8000/docs
|
|
|
|
|
|
## Development
|
|
|
|
```
|
|
nodemon --ext '*' --exec "podman stop rag-chat-backend; podman rm rag-chat-backend; podman-compose -f docker-compose.yaml up --build"
|
|
```
|
|
|
|
### Ollama (CLI)
|
|
|
|
<details>
|
|
<summary><b>Show Models from Ollama</b></summary>
|
|
|
|
curl http://localhost:11434/api/tags | jq
|
|
|
|
</details>
|
|
|
|
|
|
<details>
|
|
<summary><b>Run Chat Completion</b></summary>
|
|
|
|
curl http://localhost:11434/v1/chat/completions \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"model": "phi3:latest",
|
|
"messages": [
|
|
{
|
|
"role": "system",
|
|
"content": "You are a helpful assistant."
|
|
},
|
|
{
|
|
"role": "user",
|
|
"content": "Hello!"
|
|
}
|
|
]
|
|
}'
|
|
|
|
</details>
|
|
|
|
|
|
### VectorDB (CLI)
|
|
|
|
<details>
|
|
<summary><b>Quere Verctoriezed content</b></summary>
|
|
|
|
curl -X 'POST' \
|
|
'http://localhost:8000/api/search-engine?query=HTML%20of%20your%20question' \
|
|
-H 'accept: application/json' | jq
|
|
|
|
</details>
|
|
|
|
|
|
### VectorDB (Opensearch Dashboard)
|
|
|
|
Run these at http://localhost:5601/app/dev_tools#/console
|
|
|
|
<details>
|
|
<summary><b>View Chunked Vectors</b></summary>
|
|
|
|
GET /my-project-name/_search
|
|
{
|
|
"query": {
|
|
"match_all": {}
|
|
}
|
|
}
|
|
|
|
|
|
</details>
|
|
|
|
|
|
<details>
|
|
<summary><b>Get the three best documents with theire embeddings</b></summary>
|
|
|
|
GET /my-project-name/_search
|
|
{
|
|
"size": 0,
|
|
"query": {
|
|
"bool": {"must": [{"match": {"content": "Enter your Question here..."}}]}
|
|
},
|
|
"aggs": {
|
|
"group_by_source": {
|
|
"terms": {
|
|
"field": "metadata.source.keyword",
|
|
"size": 100000
|
|
|
|
},
|
|
"aggs": {
|
|
"top_entries": {
|
|
"top_hits": {
|
|
"size": 3,
|
|
"sort": [{"_score": {"order": "desc"}}],
|
|
"_source": {"excludes": ["embedding_vector"]}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
</details>
|
|
|
|
|
|
## TODO
|
|
|