Spaces:
Sleeping
Sleeping
File size: 714 Bytes
93a5bf9 ef9fa4b 7a3f093 ef9fa4b 5c271a3 ef9fa4b 7a3f093 ef9fa4b 7a3f093 93a5bf9 3c1150c |
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 26 |
from langchain_core.messages import SystemMessage
from src.genai.utils.models_loader import llm_gpt
from .prompts import introduction_prompt
from .state import ConversationFormatter, State
class IntroductionNode:
def __init__(self):
self.llm = llm_gpt
def run(self, state:State):
template = introduction_prompt
messages = [SystemMessage(content=template)] + state["messages"]
result = self.llm.with_structured_output(ConversationFormatter).invoke(messages)
print('Response:', result)
return {
"messages": [{"role": "assistant", "content": result.response}],
"response": result.response,
"completion": result.completion,
}
|