Skip to content

Commit

Permalink
Updating files based on reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
german-grandas committed Aug 20, 2024
1 parent e9beeef commit eb9ab02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,18 @@


def get_chat_history(session_id: str) -> PostgresChatMessageHistory:
history = PostgresChatMessageHistory.create_sync(
engine, session_id=session_id, table_name=CHAT_HISTORY_TABLE_NAME
)

logging.info(
f"Retrieving history for session {session_id} with {len(history.messages)}"
)
return history
try:
history = PostgresChatMessageHistory.create_sync(
engine, session_id=session_id, table_name=CHAT_HISTORY_TABLE_NAME
)

logging.info(
f"Retrieving history for session {session_id} with {len(history.messages)}"
)
return history
except Exception as e:
logging.error(e)
return None

def clear_chat_history(session_id: str):
history = PostgresChatMessageHistory.create_sync(
Expand Down Expand Up @@ -104,7 +107,7 @@ def create_chain() -> RunnableWithMessageHistory:
)
return chain_with_history
except Exception as e:
logging.info(e)
logging.error(e)
raise e

def take_chat_turn(
Expand All @@ -115,5 +118,5 @@ def take_chat_turn(
result = chain.invoke({"input": query_text}, config=config)
return result
except Exception as e:
logging.info(e)
logging.error(e)
raise e
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,12 @@ def add_texts(
raise Exception(f"Error adding texts: {err}")

def similarity_search(
self, query_input: dict, k: int = 4, **kwargs: Any
self, query: dict, k: int = 4, **kwargs: Any
) -> List[Document]:
try:
query_input = query.get("input")
query_vector = self.embeddings_service.embed_query(query_input)
<<<<<<< HEAD
docs = self.vector_store.similarity_search_by_vector(query_vector, k=k)
=======
docs = self.vector_store.similarity_search_by_vector(query_vector, k=4)
>>>>>>> 2d652e30 (Rag langchain chat history (#755))
return docs

except Exception as err:
Expand Down

0 comments on commit eb9ab02

Please sign in to comment.