Closed jacksonwen001 closed 1 year ago
Can you provide your curl command? and please do not send app secret in it.
Actually I write it by using fastapi. here is my code:
def replyByDify(self, customer_name: str, question: str) -> str:
conversation_id = redis_client.get_value(customer_name)
body = {
"inputs": {},
"query": question,
"response_mode": "streaming",
"conversation_id": conversation_id if conversation_id is not None else "",
"user": customer_name,
}
try:
print(body)
answers = []
url = "https://api.dify.ai/v1/chat-messages"
headers = {
'Authorization': 'Bearer <apikey>',
'Content-Type': 'application/json'
}
with requests.post(url=url, headers=headers, data=json.dumps(body), stream=True) as response: # noqa
for chunk in response.iter_lines():
if chunk:
try:
task = json.loads(chunk.decode().replace("data: ", ""))
answers.append(task['answer']) # noqa
conversation_id = task['conversation_id']
except Exception as e:
print(e)
redis_client.set_value(customer_name, conversation_id) # noqa
return ''.join(answers)
except Exception as e:
print(e)
Maybe I got the point. since I use the same conservation_id. so I cannot see the logs in Logs&Ann since it archived to the old conservation_id. it will not add new item in list. but what problems with "pre-promo"? the "pre promo" no effect if I use the old conservation_id?
I did the testing. the answer is yes. if you always using the same conservation_id, it will no effect for pre-promo setting until you use the new one
It should be do some improve, right? image that if i have the customer using the channel to chat with me, and some day, I upgrade the backend(such as apply some promo). and it must renew the conservation_id and lost the memory otherwise it cannot apply the upgrade. it is strange.
So, here's the thing: every conversation follows the app's prompt engineering configuration version that was set when it was created. When you make changes to the prompt engineering configuration, it actually creates a new version. From then on, any new conversations will use the new configuration, while existing conversations will continue to use the old one.
can we add the function, such like 'apply to all conservation' or "apply to new conservation"? there are many scenarios like that we want to upgrade bot and we don't want to lose the context with customer
can we add the function, such like 'apply to all conservation' or "apply to new conservation"? there are many scenarios like that we want to upgrade bot and we don't want to lose the context with customer
Not for now, but we will consider this in the future.
Hi All, I integrated the official api in myself app. But I noticed it will lose some conservation in "Logs && Ann." and I already set the "Pre promo" in the web page(I definitely click the publish button). But it seems doesn't work. Did I miss something?
Below is the tech details:
Dify version: Cloud API: https://api.dify.ai/v1