Spaces:
Sleeping
Sleeping
File size: 746 Bytes
93a5bf9 ef9fa4b 9f72bcf ef9fa4b 5c271a3 ef9fa4b 9f72bcf 93a5bf9 3c1150c 93a5bf9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from langchain_core.messages import SystemMessage
from src.genai.utils.models_loader import llm_gpt
from .prompts import introduction_prompt
from .state import ConversationFormatter
class IntroductionNode:
def __init__(self):
self.llm = llm_gpt
def run(self, state, llm):
template = introduction_prompt
messages = [SystemMessage(content=template)] + state["messages"]
response = llm.with_structured_output(ConversationFormatter).invoke(messages)
print('The response:', response)
print('Type of response:', type(response))
if 'True' in response.complete:
return {'messages':['completed']}
else:
return {"messages": [response.response]}
|