Spaces:
Sleeping
Sleeping
| from ask_llm_final_prompt import ask_socrates | |
| from Retrieve import retrieve_all_chunks | |
| from Prompt_building import TOPIC_TO_DBS | |
| from config import HF_EMBEDDING_MODEL | |
| from langchain.embeddings import HuggingFaceEmbeddings | |
| from stories_from_supabase import pick_story_with_fallback, build_story_txt, log_story_usage | |
| embeddings = HuggingFaceEmbeddings( | |
| model_name=HF_EMBEDDING_MODEL, encode_kwargs={"normalize_embeddings": True} | |
| ) | |
| user_id = "6d58b9dd-4c1a-4ef6-8610-ed80ef067b90" | |
| username = "user_lollo632" | |
| topic_for_story = "fortune" | |
| chunks = retrieve_all_chunks( | |
| query="what do you think about fortune?", | |
| model=embeddings, | |
| user_id=user_id, | |
| username=username, | |
| k=10, | |
| topic="philosophical", | |
| topic_to_dbs=TOPIC_TO_DBS, | |
| ) | |
| socratic_story_dic = pick_story_with_fallback(user_id, topic_for_story) | |
| socratic_story_formatted = build_story_txt(user_id=user_id, topic_for_story=topic_for_story) | |
| final_reply_en = ask_socrates( | |
| user_input="what do you think about fortune?", | |
| retrieved_chunks=chunks, | |
| relevant_missing=None, | |
| topic="philosophical", | |
| socratic_story=socratic_story_dic, #3 | |
| response_mode="dialogic", | |
| user_id="6d58b9dd-4c1a-4ef6-8610-ed80ef067b90", | |
| ) | |
| print(final_reply_en) | |
| story_id = (socratic_story_dic or {}).get("id") | |
| if socratic_story_formatted and story_id: | |
| log_story_usage(user_id=user_id, story_id=story_id, assistant_message=final_reply_en) |