Skip to content

Commit

Permalink
🚧 fix(wip): invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
mxchinegod committed Dec 20, 2023
1 parent 9198c5a commit a08759f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions magnet/ron/milvus.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ def embed_and_store(self, payload, verbose=False):
])
except Exception as e:
_f('fatal',e)
def search(self, payload, cb=None):
def search(self, payload, limit=100, cb=None):
payload = {'text':payload}
payload['embedding'] = self.model.encode(payload['text'], normalize_embeddings=True)
self.db.collection.load()
_results = self.db.collection.search(
data=[payload['embedding']], # Embeded search value
anns_field="embedding", # Search across embeddings
param={},
limit = 100, # Limit to top_k results per search
limit = limit, # Limit to top_k results per search
output_fields=['text', 'document']
)
results = []
Expand All @@ -52,7 +53,7 @@ def search(self, payload, cb=None):
, 'distance': hit.distance
})
if cb:
cb(results)
return cb(payload['text'], results)
else:
return results
def delete(self, name=None):
Expand Down
2 changes: 1 addition & 1 deletion magnet/ron/utils/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Prompts:
def __init__(self):
return
def qa_ref(self, docs: list = [], q: str = None):
docs = '\n'.join([f"Document: {d}\nText: {t}" for (d, t) in [tuple(x.values()) for x in docs]])
docs = '\n'.join([f"Document: {d}\nText: {t}" for (t, d, c) in [tuple(x.values()) for x in docs]])
return """Create a concise and informative answer (no more than 50 words) for a given question based solely on the given documents. You must only use information from the given documents. Use an unbiased and journalistic tone. Do not repeat text. Cite the documents using Document[name] notation. If multiple documents contain the answer, cite those documents like ‘as stated in Document[name], Document[name], etc.’. If the documents do not contain the answer to the question, say that ‘answering is not possible given the available information.’
[DOCUMENTS]
Question: [QUERY]; Answer: """ \
Expand Down

0 comments on commit a08759f

Please sign in to comment.