Spaces:
Sleeping
Sleeping
File size: 802 Bytes
a6a0614 93a5bf9 ef9fa4b 7a3f093 a6a0614 ef9fa4b 5c271a3 ef9fa4b a6a0614 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 27 28 29 |
import os
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
from langsmith import traceable
class IntroductionNode:
def __init__(self):
self.llm = llm_gpt
@traceable(name="details collection")
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,
}
|