Skip to content

Commit

Permalink
upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-bertelli committed Mar 21, 2024
1 parent a4cd468 commit a0a578c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
5 changes: 3 additions & 2 deletions apis/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

from middlewares.auth_middleware import user_token_required
from utils.chat_history_parser import retrieve_chat_history
from llama_index.chat_engine import ContextChatEngine
from llama_index.memory import ChatMemoryBuffer
from llama_index.core.chat_engine import ContextChatEngine
from llama_index.core.memory import ChatMemoryBuffer
from index_manager import initialize_index, get_service_context
from bson.objectid import ObjectId
from flask import request, jsonify, Response
Expand Down Expand Up @@ -95,6 +95,7 @@ def query_index(chatId):
chat_engine = ContextChatEngine.from_defaults(
retriever=query_engine,
service_context=service_context,
memory=memory,
system_prompt=(
"""\
You are a chatbot. You MUST NOT provide any information unless it is in the Context or previous messages or general conversation. If the user ask something you don't know, say that you cannot answer. \
Expand Down
9 changes: 4 additions & 5 deletions index_manager.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from llama_index import (
from llama_index.core import (
VectorStoreIndex,
StorageContext,
ServiceContext,
LLMPredictor,
SimpleDirectoryReader
)

from llama_index.indices.loading import load_index_from_storage
from llama_index.core.indices.loading import load_index_from_storage
from utils.vector_database import build_pinecone_vector_store, build_mongo_index
from mongodb.index import getExistingLlamaIndexes
from llama_index import SimpleDirectoryReader

from llama_index.llms import Perplexity
from llama_index.llms.perplexity import Perplexity
import os

llm = Perplexity(
Expand Down
12 changes: 9 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ flask_limiter
flask-cors
python-dotenv
pymongo
llama_index==0.9.22
pinecone
pinecone-client
llmsherpa
pandas
pandas
llama-index-core
llama-index-vector-stores-pinecone
llama-index-storage-index-store-mongodb
llama-index-embeddings-huggingface
llama-index-llms-perplexity
transformers
torch==2.2
2 changes: 1 addition & 1 deletion utils/chat_history_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from llama_index.llms import ChatMessage, MessageRole
from llama_index.core.llms import ChatMessage, MessageRole
from mongodb.index import get_chat_history

def retrieve_chat_history(chatId):
Expand Down
2 changes: 1 addition & 1 deletion utils/parsers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from llama_index.schema import Document
from llama_index.core.schema import Document
from llmsherpa.readers import LayoutPDFReader

import pandas as pd
Expand Down
4 changes: 2 additions & 2 deletions utils/vector_database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from llama_index.storage.index_store import MongoIndexStore
from llama_index.vector_stores import PineconeVectorStore
from llama_index.storage.index_store.mongodb import MongoIndexStore
from llama_index.vector_stores.pinecone import PineconeVectorStore

from pinecone import Pinecone
import openai
Expand Down

0 comments on commit a0a578c

Please sign in to comment.