-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ttl_to_building_description function
- Loading branch information
Showing
10 changed files
with
100 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import List, Tuple, Union | ||
|
||
from langchain.chat_models.base import BaseChatModel | ||
from langchain_community.llms import Ollama | ||
from langchain_core.messages import HumanMessage, SystemMessage | ||
|
||
from ..helpers import ttl_to_user_prompt | ||
from ..schemas import TTLToBuildingPromptSchema | ||
|
||
|
||
def ttl_to_building_prompt( | ||
ttl_file: str, llm: Union[Ollama, BaseChatModel] | ||
) -> Tuple[str, List[str]]: | ||
|
||
# Enforce structured output | ||
structured_llm = llm.with_structured_output(TTLToBuildingPromptSchema) | ||
|
||
# System message | ||
system_message = ttl_to_user_prompt.format(ttl_script=ttl_file) | ||
|
||
# Generate question | ||
answer = structured_llm.invoke( | ||
[SystemMessage(content=system_message)] | ||
+ [HumanMessage(content="Generate the TTL.")] | ||
) | ||
|
||
return answer.building_description, answer.key_elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters