codelion commited on
Commit
ab5adef
·
verified ·
1 Parent(s): aedc526

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +17 -5
main.py CHANGED
@@ -3,7 +3,8 @@ import os
3
  import streamlit as st
4
  import anthropic
5
 
6
- from langchain_community.embeddings import HuggingFaceInferenceAPIEmbeddings
 
7
  from langchain_community.vectorstores import SupabaseVectorStore
8
  from langchain_community.llms import HuggingFaceEndpoint
9
  from langchain_community.vectorstores import SupabaseVectorStore
@@ -25,12 +26,23 @@ username = st.secrets.username
25
  supabase: Client = create_client(supabase_url, supabase_key)
26
  logger = get_logger(__name__)
27
 
28
- embeddings = HuggingFaceInferenceAPIEmbeddings(
29
- api_key=hf_api_key,
30
- model_name="BAAI/bge-large-en-v1.5",
31
- api_url="https://router.huggingface.co/hf-inference/pipeline/feature-extraction/",
 
 
 
 
 
32
  )
33
 
 
 
 
 
 
 
34
  if 'chat_history' not in st.session_state:
35
  st.session_state['chat_history'] = []
36
 
 
3
  import streamlit as st
4
  import anthropic
5
 
6
+ # from langchain_community.embeddings import HuggingFaceInferenceAPIEmbeddings
7
+ from langchain_community.embeddings import HuggingFaceInstructEmbeddings
8
  from langchain_community.vectorstores import SupabaseVectorStore
9
  from langchain_community.llms import HuggingFaceEndpoint
10
  from langchain_community.vectorstores import SupabaseVectorStore
 
26
  supabase: Client = create_client(supabase_url, supabase_key)
27
  logger = get_logger(__name__)
28
 
29
+
30
+
31
+ model_name = "BAAI/bge-large-en-v1.5"
32
+ model_kwargs = {'device': 'cpu'}
33
+ encode_kwargs = {'normalize_embeddings': True}
34
+ embeddings = HuggingFaceInstructEmbeddings(
35
+ model_name=model_name,
36
+ model_kwargs=model_kwargs,
37
+ encode_kwargs=encode_kwargs
38
  )
39
 
40
+ # embeddings = HuggingFaceInferenceAPIEmbeddings(
41
+ # api_key=hf_api_key,
42
+ # model_name="BAAI/bge-large-en-v1.5",
43
+ # api_url="https://router.huggingface.co/hf-inference/pipeline/feature-extraction/",
44
+ # )
45
+
46
  if 'chat_history' not in st.session_state:
47
  st.session_state['chat_history'] = []
48