The Logs&Ann will lose some conservation. #457

Closed
opened 2026-02-21 17:27:14 -05:00 by yindo · 6 comments
Owner

Originally created by @jacksonwen001 on GitHub (Sep 1, 2023).

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

Originally created by @jacksonwen001 on GitHub (Sep 1, 2023). 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
yindo closed this issue 2026-02-21 17:27:14 -05:00
Author
Owner

@crazywoola commented on GitHub (Sep 1, 2023):

Can you provide your curl command? and please do not send app secret in it.

@crazywoola commented on GitHub (Sep 1, 2023): Can you provide your curl command? and please do not send app secret in it.
Author
Owner

@jacksonwen001 commented on GitHub (Sep 1, 2023):

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)
@jacksonwen001 commented on GitHub (Sep 1, 2023): Actually I write it by using fastapi. here is my code: ```python 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) ```
Author
Owner

@jacksonwen001 commented on GitHub (Sep 1, 2023):

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?

update

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.

@jacksonwen001 commented on GitHub (Sep 1, 2023): 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? # update 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.
Author
Owner

@takatost commented on GitHub (Sep 1, 2023):

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.

@takatost commented on GitHub (Sep 1, 2023): 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.
Author
Owner

@jacksonwen001 commented on GitHub (Sep 1, 2023):

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

@jacksonwen001 commented on GitHub (Sep 1, 2023): 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
Author
Owner

@crazywoola commented on GitHub (Sep 6, 2023):

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.

@crazywoola commented on GitHub (Sep 6, 2023): > 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#457