Spaces:
Sleeping
Sleeping
File size: 859 Bytes
92cf6e2 6b61df1 92cf6e2 6b61df1 92cf6e2 |
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 |
import requests
from langchain_core.messages import SystemMessage,HumanMessage
from ..utils.schemas import CompareBodyFormatter
from ..utils.prompts import compare_prompt
from ..utils.utils import process_query
def compare(state,llm_gpt,url):
messages = [SystemMessage(content=compare_prompt()),
HumanMessage(content=str(state['messages']))]
response=llm_gpt.with_structured_output(CompareBodyFormatter , method='function_calling').invoke(messages)
print('INF names response:', response)
payload = {
"usernames": list(map(process_query,response.names)),
"freq": response.frequency
}
print('The payload is:',payload)
headers = {
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print('Data from api:', response)
return response |