MCPcopy Create free account
hub / github.com/CL-lau/SQL-GPT / __init__

Method __init__

embedding/embeddingHelper.py:578–602  ·  view source on GitHub ↗
(self, embedding_function: Optional[str] = None)

Source from the content-addressed store, hash-verified

576 openaiAccessRate = 0
577
578 def __init__(self, embedding_function: Optional[str] = None):
579 import chromadb
580 import streamlit as st
581
582 self.client = chromadb.PersistentClient(path="./embedding")
583
584 self.generated_ids = set()
585
586 # Map{collectionId, collection}
587 self.collectionMap = {}
588
589 # Map{collectionID, idIndex}
590 self.idIndexMap = {}
591
592 self.api_key = st.session_state["openai_api_key"]
593 self.chatModel = ChatOpenAI(openai_api_key=self.api_key)
594
595 if embedding_function is None:
596 self.embedding_model = embedding_functions.DefaultEmbeddingFunction()
597 elif embedding_function == "openai":
598 self.embedding_model = embedding_functions.OpenAIEmbeddingFunction(api_key=self.api_key)
599
600 self.summaryPromptChinese = "请你对下面的段落进行总结,使用中文进行总结,具体的段落内容如下: {}"
601 self.summaryPromptEnglish = "Please summarize the following paragraph in English, the specific content of the " \
602 "paragraph is as follows: {}"
603
604 def from_documents(self, documents: list[Document], collectionId: Optional[str], embedding: Optional = OpenAIEmbeddings(),
605 persist_directory: Optional[str] = None) -> str:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected