aklai commited on
Commit
2302aa3
·
1 Parent(s): 100bb07

Update space

Browse files
Files changed (2) hide show
  1. app.py +3 -5
  2. requirements.txt +4 -1
app.py CHANGED
@@ -1,8 +1,8 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
- from langchain.embeddings import HuggingFaceEmbeddings
5
- from langchain.vectorstores import Chroma
6
 
7
  from langchain_community.llms import Ollama
8
 
@@ -21,9 +21,6 @@ embedding_model = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
21
  # Load the existing ChromaDB database
22
  vector_store = Chroma(persist_directory="./chroma_db", embedding_function=embedding_model)
23
 
24
- # Now you can use `vector_store` as your retriever
25
- retriever = vector_store.as_retriever()
26
-
27
  # Function to call a RAG LLM query
28
  def rag_query(query, history):
29
  # Invoke the chain
@@ -36,6 +33,7 @@ def rag_query(query, history):
36
  output = f"Answer: {answer}\n\nSources:\n" + "\n".join(unique_sources)
37
  return output
38
 
 
39
  # See full prompt at https://smith.langchain.com/hub/rlm/rag-prompt
40
  # Basically a solid prompt for RAG
41
  prompt = hub.pull("rlm/rag-prompt")
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
+ from langchain_huggingface import HuggingFaceEmbeddings
5
+ from langchain_ollama import Ollama
6
 
7
  from langchain_community.llms import Ollama
8
 
 
21
  # Load the existing ChromaDB database
22
  vector_store = Chroma(persist_directory="./chroma_db", embedding_function=embedding_model)
23
 
 
 
 
24
  # Function to call a RAG LLM query
25
  def rag_query(query, history):
26
  # Invoke the chain
 
33
  output = f"Answer: {answer}\n\nSources:\n" + "\n".join(unique_sources)
34
  return output
35
 
36
+
37
  # See full prompt at https://smith.langchain.com/hub/rlm/rag-prompt
38
  # Basically a solid prompt for RAG
39
  prompt = hub.pull("rlm/rag-prompt")
requirements.txt CHANGED
@@ -4,4 +4,7 @@ langchain
4
  langchain-community
5
  langchain-core
6
  chromadb
7
- ollama
 
 
 
 
4
  langchain-community
5
  langchain-core
6
  chromadb
7
+ ollama
8
+ sentence-transformers
9
+ langchain-huggingface
10
+ langchain-ollama