Spaces:
Build error
Build error
add chroma in memory client
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ from langchain_community.document_loaders import UnstructuredFileLoader
|
|
9 |
from langchain_chroma import Chroma
|
10 |
from chromadb import Documents, EmbeddingFunction, Embeddings
|
11 |
from chromadb.config import Settings
|
12 |
-
|
13 |
import os
|
14 |
import re
|
15 |
import uuid
|
@@ -19,8 +19,8 @@ import torch.nn.functional as F
|
|
19 |
from dotenv import load_dotenv
|
20 |
from utils import load_env_variables, parse_and_route , escape_special_characters
|
21 |
from globalvars import API_BASE, intention_prompt, tasks, system_message, model_name , metadata_prompt
|
22 |
-
import time
|
23 |
-
import httpx
|
24 |
|
25 |
|
26 |
|
@@ -39,7 +39,10 @@ def clear_cuda_cache():
|
|
39 |
torch.cuda.empty_cache()
|
40 |
|
41 |
client = OpenAI(api_key=yi_token, base_url=API_BASE)
|
42 |
-
|
|
|
|
|
|
|
43 |
chroma_collection = chroma_client.create_collection("all-my-documents")
|
44 |
|
45 |
class EmbeddingGenerator:
|
@@ -154,7 +157,7 @@ def query_chroma(query_text: str, embedding_function: MyEmbeddingFunction):
|
|
154 |
intention_client = OpenAI(api_key=yi_token, base_url=API_BASE)
|
155 |
embedding_generator = EmbeddingGenerator(model_name=model_name, token=hf_token, intention_client=intention_client)
|
156 |
embedding_function = MyEmbeddingFunction(embedding_generator=embedding_generator)
|
157 |
-
chroma_client, chroma_collection = initialize_chroma(collection_name="Tonic-instruct", embedding_function=embedding_function)
|
158 |
|
159 |
def respond(
|
160 |
message,
|
|
|
9 |
from langchain_chroma import Chroma
|
10 |
from chromadb import Documents, EmbeddingFunction, Embeddings
|
11 |
from chromadb.config import Settings
|
12 |
+
import chromadb #import HttpClient
|
13 |
import os
|
14 |
import re
|
15 |
import uuid
|
|
|
19 |
from dotenv import load_dotenv
|
20 |
from utils import load_env_variables, parse_and_route , escape_special_characters
|
21 |
from globalvars import API_BASE, intention_prompt, tasks, system_message, model_name , metadata_prompt
|
22 |
+
# import time
|
23 |
+
# import httpx
|
24 |
|
25 |
|
26 |
|
|
|
39 |
torch.cuda.empty_cache()
|
40 |
|
41 |
client = OpenAI(api_key=yi_token, base_url=API_BASE)
|
42 |
+
|
43 |
+
chroma_client = chromadb.Client(Settings())
|
44 |
+
|
45 |
+
# Create a collection
|
46 |
chroma_collection = chroma_client.create_collection("all-my-documents")
|
47 |
|
48 |
class EmbeddingGenerator:
|
|
|
157 |
intention_client = OpenAI(api_key=yi_token, base_url=API_BASE)
|
158 |
embedding_generator = EmbeddingGenerator(model_name=model_name, token=hf_token, intention_client=intention_client)
|
159 |
embedding_function = MyEmbeddingFunction(embedding_generator=embedding_generator)
|
160 |
+
chroma_client, chroma_collection = initialize_chroma(collection_name="Tonic-instruct", embedding_function=embedding_function)
|
161 |
|
162 |
def respond(
|
163 |
message,
|