Spaces:
Running
Running
MVPilgrim
commited on
Commit
·
ecf6d51
1
Parent(s):
787884c
debug
Browse files
app.py
CHANGED
@@ -377,17 +377,22 @@ try:
|
|
377 |
# Initial the the sentence transformer and encode the query prompt.
|
378 |
logger.debug(f"#### Encode text query prompt to create vectors. {promptText}")
|
379 |
model = SentenceTransformer('/app/multi-qa-MiniLM-L6-cos-v1')
|
380 |
-
|
381 |
vector = model.encode(promptText)
|
382 |
-
|
383 |
-
logger.
|
384 |
-
|
|
|
|
|
385 |
|
386 |
-
|
|
|
387 |
for vec in vector:
|
388 |
vectorList.append(vec)
|
389 |
-
|
390 |
-
|
|
|
|
|
|
|
391 |
|
392 |
# Fetch chunks and print chunks.
|
393 |
logger.debug("#### Retrieve semchunks from db using vectors from prompt.")
|
@@ -397,8 +402,10 @@ try:
|
|
397 |
distance=0.7,
|
398 |
limit=3
|
399 |
)
|
400 |
-
|
401 |
-
|
|
|
|
|
402 |
|
403 |
# Print chunks, corresponding document and document title.
|
404 |
ragData = ""
|
@@ -425,12 +432,11 @@ try:
|
|
425 |
|
426 |
chunksCollection = client.collections.get("Chunks")
|
427 |
response = chunksCollection.query.fetch_objects()
|
428 |
-
|
429 |
wstrObjs = str(response.objects)
|
430 |
logger.debug(f"### response.objects: {wstrObjs}")
|
431 |
for o in response.objects:
|
432 |
wstr = o.properties
|
433 |
-
logger.
|
434 |
logger.info("#### getAllRagData() exited.")
|
435 |
return wstrObjs
|
436 |
|
@@ -495,7 +501,7 @@ try:
|
|
495 |
#stop=stop,
|
496 |
)
|
497 |
result = modelOutput["choices"][0]["message"]["content"]
|
498 |
-
result = str(modelOutput)
|
499 |
logger.debug(f"### llmResult: {result}")
|
500 |
logger.info("### runLLM exited.")
|
501 |
return result
|
@@ -555,7 +561,7 @@ try:
|
|
555 |
logger.info("### prettyPrint exited.")
|
556 |
return prettyText
|
557 |
except Exception as e:
|
558 |
-
|
559 |
return None
|
560 |
|
561 |
|
@@ -569,14 +575,16 @@ try:
|
|
569 |
logger.debug(f"sysTAtext: {st.session_state.sysTAtext}")
|
570 |
|
571 |
#st.session_state.userpTAtext = st.session_state.userpTA
|
572 |
-
|
573 |
#wrkList = [ wrkList ]
|
574 |
-
st.session_state.userpTA = prettyPrint(wrkList)
|
|
|
575 |
logger.debug(f"userpTAtext: {st.session_state.userpTA}")
|
576 |
|
577 |
#st.session_state.rspTAtext = runLLM(st.session_state.userpTAtext)
|
578 |
-
rsp = runLLM(
|
579 |
-
st.session_state.rspTA = prettyPrint(rsp)
|
|
|
580 |
logger.debug(f"rspTAtext: {st.session_state.rspTA}")
|
581 |
|
582 |
logger.info("### on_runLLMButton_Clicked exited.")
|
|
|
377 |
# Initial the the sentence transformer and encode the query prompt.
|
378 |
logger.debug(f"#### Encode text query prompt to create vectors. {promptText}")
|
379 |
model = SentenceTransformer('/app/multi-qa-MiniLM-L6-cos-v1')
|
|
|
380 |
vector = model.encode(promptText)
|
381 |
+
|
382 |
+
logLevel = logger.getEffectiveLevel()
|
383 |
+
if logLevel >= logging.DEBUG:
|
384 |
+
wrks = str(vector)
|
385 |
+
logger.debug(f"### vector: {wrks}")
|
386 |
|
387 |
+
|
388 |
+
vectorList = []
|
389 |
for vec in vector:
|
390 |
vectorList.append(vec)
|
391 |
+
|
392 |
+
if logLevel >= logging.DEBUG:
|
393 |
+
logger.debug("#### Print vectors.")
|
394 |
+
wrks = str(vectorList)
|
395 |
+
logger.debug(f"vectorList: {wrks}")
|
396 |
|
397 |
# Fetch chunks and print chunks.
|
398 |
logger.debug("#### Retrieve semchunks from db using vectors from prompt.")
|
|
|
402 |
distance=0.7,
|
403 |
limit=3
|
404 |
)
|
405 |
+
|
406 |
+
if logLevel >= logging.DEBUG:
|
407 |
+
wrks = str(semChunks)
|
408 |
+
logger.debug(f"### semChunks[0]: {wrks}")
|
409 |
|
410 |
# Print chunks, corresponding document and document title.
|
411 |
ragData = ""
|
|
|
432 |
|
433 |
chunksCollection = client.collections.get("Chunks")
|
434 |
response = chunksCollection.query.fetch_objects()
|
|
|
435 |
wstrObjs = str(response.objects)
|
436 |
logger.debug(f"### response.objects: {wstrObjs}")
|
437 |
for o in response.objects:
|
438 |
wstr = o.properties
|
439 |
+
logger.debug(f"### o.properties: {wstr}")
|
440 |
logger.info("#### getAllRagData() exited.")
|
441 |
return wstrObjs
|
442 |
|
|
|
501 |
#stop=stop,
|
502 |
)
|
503 |
result = modelOutput["choices"][0]["message"]["content"]
|
504 |
+
#result = str(modelOutput)
|
505 |
logger.debug(f"### llmResult: {result}")
|
506 |
logger.info("### runLLM exited.")
|
507 |
return result
|
|
|
561 |
logger.info("### prettyPrint exited.")
|
562 |
return prettyText
|
563 |
except Exception as e:
|
564 |
+
logger.error(f"### prettyPrint() e: {e}")
|
565 |
return None
|
566 |
|
567 |
|
|
|
575 |
logger.debug(f"sysTAtext: {st.session_state.sysTAtext}")
|
576 |
|
577 |
#st.session_state.userpTAtext = st.session_state.userpTA
|
578 |
+
wrklist = setPrompt(st.session_state.userpTA,st.selectRag)
|
579 |
#wrkList = [ wrkList ]
|
580 |
+
#st.session_state.userpTA = prettyPrint(wrkList)
|
581 |
+
st.session_state.userpTA = wrklist[1]["content"]
|
582 |
logger.debug(f"userpTAtext: {st.session_state.userpTA}")
|
583 |
|
584 |
#st.session_state.rspTAtext = runLLM(st.session_state.userpTAtext)
|
585 |
+
rsp = runLLM(wrklist)
|
586 |
+
#st.session_state.rspTA = prettyPrint(rsp)
|
587 |
+
st.session_state.rspTA = rsp
|
588 |
logger.debug(f"rspTAtext: {st.session_state.rspTA}")
|
589 |
|
590 |
logger.info("### on_runLLMButton_Clicked exited.")
|