Spaces:
Running
Running
File size: 786 Bytes
e04dd70 705e0de e04dd70 c5a0a6e 705e0de e04dd70 c5a0a6e e04dd70 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import chromadb
from chromadb.config import Settings
import chromadb.utils.embedding_functions as embedding_functions
from dotenv import load_dotenv
import streamlit as st
load_dotenv()
# openai_key = os.getenv("OPENAI_API_KEY")
openai_key = st.secrets["OPENAI_API_KEY"]
def get_chroma_client(
host: str = "chroma.brianknows.org",
port: int = 443,
) -> chromadb.HttpClient:
chroma_client = chromadb.HttpClient(
host=host,
port=443,
ssl=port,
settings=Settings(
allow_reset=True,
),
)
return chroma_client
def get_embedding_function(model_name="text-embedding-ada-002"):
openai_ef = embedding_functions.OpenAIEmbeddingFunction(
api_key=openai_key, model_name=model_name
)
return openai_ef
|