Spaces:
Build error
Build error
added langchain app for simplicity
Browse files- langchainapp.py +6 -5
langchainapp.py
CHANGED
@@ -78,7 +78,8 @@ class MyEmbeddingFunction(EmbeddingFunction):
|
|
78 |
embeddings_flattened = [emb for sublist in embeddings for emb in sublist]
|
79 |
metadata_flattened = [meta for sublist in metadata for meta in sublist]
|
80 |
return embeddings_flattened, metadata_flattened
|
81 |
-
|
|
|
82 |
def compute_embeddings(self, input_text: str):
|
83 |
escaped_input_text = escape_special_characters(input_text)
|
84 |
|
@@ -94,14 +95,14 @@ class MyEmbeddingFunction(EmbeddingFunction):
|
|
94 |
parsed_task = parse_and_route(intention_output)
|
95 |
selected_task = parsed_task if parsed_task in tasks else "DEFAULT"
|
96 |
task_description = tasks[selected_task]
|
97 |
-
|
98 |
# Construct the embed_instruction and query_instruction dynamically
|
99 |
-
embed_instruction = f"
|
100 |
-
query_instruction = f"
|
101 |
|
102 |
# Update the hf_embeddings object with the new instructions
|
103 |
self.hf_embeddings.embed_instruction = embed_instruction
|
104 |
-
self.hf_embeddings.query_instruction = query_instruction
|
105 |
|
106 |
# Get the metadata
|
107 |
metadata_completion = self.intention_client.chat.completions.create(
|
|
|
78 |
embeddings_flattened = [emb for sublist in embeddings for emb in sublist]
|
79 |
metadata_flattened = [meta for sublist in metadata for meta in sublist]
|
80 |
return embeddings_flattened, metadata_flattened
|
81 |
+
|
82 |
+
@spaces.GPU
|
83 |
def compute_embeddings(self, input_text: str):
|
84 |
escaped_input_text = escape_special_characters(input_text)
|
85 |
|
|
|
95 |
parsed_task = parse_and_route(intention_output)
|
96 |
selected_task = parsed_task if parsed_task in tasks else "DEFAULT"
|
97 |
task_description = tasks[selected_task]
|
98 |
+
# query_prefix = "Instruct: " +tasks[selected_task] +"\nQuery: "
|
99 |
# Construct the embed_instruction and query_instruction dynamically
|
100 |
+
embed_instruction = f"Instruct: {task_description}" +"\nQuery:"
|
101 |
+
query_instruction = f""
|
102 |
|
103 |
# Update the hf_embeddings object with the new instructions
|
104 |
self.hf_embeddings.embed_instruction = embed_instruction
|
105 |
+
# self.hf_embeddings.query_instruction = query_instruction
|
106 |
|
107 |
# Get the metadata
|
108 |
metadata_completion = self.intention_client.chat.completions.create(
|