Skip to content

Commit

Permalink
fix: imports in __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nsantacruz committed Feb 22, 2024
1 parent eb79047 commit 6c0de0d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions sefaria/helper/llm/topic_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from sefaria.client.wrapper import get_links
from sefaria.datatype.jagged_array import JaggedTextArray
from sefaria_llm_interface.topic_prompt import TopicPromptGenerationOutput
from sefaria_llm_interface import Topic as LLMTopic
from sefaria_ll
from sefaria.utils.util import deep_update


Expand Down Expand Up @@ -73,18 +75,18 @@ def _get_surrounding_text(oref: Ref) -> Optional[Dict[str, str]]:
return _lang_dict_by_func(lambda lang: context_ref.text(lang).as_string())


def _make_topic_prompt_topic(sefaria_topic: Topic) -> dict:
def _make_llm_topic(sefaria_topic: Topic) -> LLMTopic:
"""
Return a dict that can be instantiated as `sefaria_interface.Topic` in the LLM repo.
This represents the basic metadata of a topic for the LLM repo to process.
:param sefaria_topic:
:return:
"""
return {
"slug": sefaria_topic.slug,
"description": getattr(sefaria_topic, 'description', {}),
"title": _lang_dict_by_func(sefaria_topic.get_primary_title),
}
return LLMTopic(
slug=sefaria_topic.slug,
description=getattr(sefaria_topic, 'description', {}),
title=_lang_dict_by_func(sefaria_topic.get_primary_title)
)


def _make_topic_prompt_source(oref: Ref, context: str) -> dict:
Expand Down Expand Up @@ -135,9 +137,10 @@ def make_topic_prompt_input(lang: str, sefaria_topic: Topic, orefs: List[Ref], c
:param contexts:
:return:
"""
# TODO use llm interface class
return {
"lang": lang,
"topic": _make_topic_prompt_topic(sefaria_topic),
"topic": _make_llm_topic(sefaria_topic),
"sources": [_make_topic_prompt_source(oref, context) for oref, context in zip(orefs, contexts)]
}

Expand Down

0 comments on commit 6c0de0d

Please sign in to comment.