[Bug Report] Bugs of JinaAPI and HTTP error
Self Checks
- [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
- [X] I have searched for existing issues search for existing issues, including closed ones.
- [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
- [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
- [X] Please do not modify this template :) and fill in all the required fields.
Dify version
0.10.0
Cloud or Self Hosted
Cloud
Steps to reproduce
Bug1: Jina error. I found that Dify can not update the Jina api properly. When my Jina API is out of tokens, I bought some tokens and update the API key. However, I find Dify still remembers the old API key so that Jina can not run and just give bugs:
Bug2: HTTP request. I am using imgrender api which is implemented using HTTP Request node in Dify. This API is properly tested on local device using python to get http results. Today, I just find that the returned img urls can not be open. (Also, it worked fine yesterday on dify.) I am sure that this bug has no relation with imgrender.
Bug3: I have both image and text in the output file. However, there is only text being shown. The images are now properly shown. For example, the figure below is have image link but it can not properly shown in the output.
✔️ Expected Behavior
Bug 1: After the Jina API is set, it can operate properly.
Bug 2: Please resolve the HTTPS error. As it can run locally, it should also function well on dify.
Bug 3: I wish to ensure that the image is displayed properly.
❌ Actual Behavior
No response
@pprp 你好! 我是Dosu,一个可以帮助你解决 bug、回答问题并成为贡献者的机器人。我会帮你等待人类维护者的过程中。
For the issues you're experiencing with Dify, here are some relevant insights and potential solutions:
-
Jina API Token Management:
- There is a known issue with Dify not updating the Jina API key properly, which can lead to errors like "InsufficientBalanceError" if the old API key is still being used. Ensure that the new API key is correctly updated in Dify's configuration. This might involve checking if the key is cached or stored in a way that needs manual updating [1].
-
HTTP Request Issues:
- When HTTP requests work locally but not in the cloud, it is important to verify the API endpoint configuration, including the URL and API key. Additionally, using tools like Ngrok can help expose local services to the cloud for testing. Ensure that the API response format is correct and that there are no network restrictions or misconfigurations in the cloud environment [2][3].
-
Image Display in Outputs:
- If images are not displaying properly in the output, ensure that the workflow is configured to handle multimedia content correctly. This might involve checking the configuration settings related to file uploads and ensuring that the image URLs are accessible and correctly formatted. There have been similar issues where images were not displayed due to configuration problems [4][5][6].
These steps should help address the issues you're facing with Dify. If the problems persist, further investigation into the specific configurations and logs might be necessary.
To continue talking to Dosu, mention @dosu.
Bug 1: After the Jina API is set, it can operate properly.
If the key is changed, you need to remove the credentials in jina reader tool and add it again.
Bug 2: Please resolve the HTTPS error. As it can run locally, it should also function well on dify.
Bug 3: I wish to ensure that the image is displayed properly.
Please provide the DSL.
@crazywoola how to remove the credential?
I have updated the key in these two places.
Here
Hi, I'm Jina AI's engineer. After some checking with @pprp
We found the place that made the confusion: the credentials of DataSource, Model(Provider), Tools are managed separately. And Jina have all of them, unfortunately. Wondering if you have some advice or plan to solve this kind of problem.🤔
@crazywoola for the 3rd bug, here is the dsl file:
app:
description: 对某个话题进行消化
icon: grinning
icon_background: '#D5D9EB'
mode: workflow
name: 图文混排测试
use_icon_as_answer_icon: false
kind: app
version: 0.1.2
workflow:
conversation_variables: []
environment_variables: []
features:
file_upload:
allowed_file_extensions:
- .JPG
- .JPEG
- .PNG
- .GIF
- .WEBP
- .SVG
allowed_file_types:
- image
allowed_file_upload_methods:
- local_file
- remote_url
enabled: false
image:
enabled: false
number_limits: 3
transfer_methods:
- local_file
- remote_url
number_limits: 3
opening_statement: ''
retriever_resource:
enabled: false
sensitive_word_avoidance:
enabled: false
speech_to_text:
enabled: false
suggested_questions: []
suggested_questions_after_answer:
enabled: false
text_to_speech:
enabled: false
language: ''
voice: ''
graph:
edges:
- data:
isInIteration: false
sourceType: llm
targetType: code
id: 1725590604530-source-1725599428552-target
source: '1725590604530'
sourceHandle: source
target: '1725599428552'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: code
targetType: iteration
id: 1725599428552-source-1725600094234-target
source: '1725599428552'
sourceHandle: source
target: '1725600094234'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: true
iteration_id: '1725600094234'
sourceType: iteration-start
targetType: tool
id: 1725600094234start0-source-1725600107123-target
source: 1725600094234start0
sourceHandle: source
target: '1725600107123'
targetHandle: target
type: custom
zIndex: 1002
- data:
isInIteration: false
sourceType: start
targetType: tool
id: start-source-1729433574725-target
source: start
sourceHandle: source
target: '1729433574725'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: llm
targetType: end
id: 1725602633045-source-end-target
source: '1725602633045'
sourceHandle: source
target: end
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: tool
targetType: llm
id: 1729433574725-source-1725590604530-target
source: '1729433574725'
sourceHandle: source
target: '1725590604530'
targetHandle: target
type: custom
zIndex: 0
- data:
isInIteration: false
sourceType: iteration
targetType: llm
id: 1725600094234-source-1725602633045-target
source: '1725600094234'
sourceHandle: source
target: '1725602633045'
targetHandle: target
type: custom
zIndex: 0
nodes:
- data:
selected: false
title: START
type: start
variables:
- label: 网页链接
max_length: 256
options: []
required: true
type: text-input
variable: URL
height: 90
id: start
position:
x: 30
y: 349
positionAbsolute:
x: 30
y: 349
selected: false
type: custom
width: 244
- data:
outputs:
- value_selector:
- '1725602633045'
- text
variable: output
selected: false
title: END
type: end
height: 90
id: end
position:
x: 2595
y: 349
positionAbsolute:
x: 2595
y: 349
selected: false
type: custom
width: 244
- data:
context:
enabled: false
variable_selector: []
desc: ''
model:
completion_params:
frequency_penalty: 0.1
presence_penalty: 0.1
temperature: 0.8
top_p: 0.9
mode: chat
name: deepseek-ai/DeepSeek-V2.5
provider: siliconflow
prompt_template:
- id: af8ee5d9-ae1e-4610-9675-8db26e3f48ec
role: system
text: "## 工作描述:根据提供的文章撰写一系列prompt用于文生图 \n\n## 工作流程 \n\n第一步,根据提供的文章,均匀地划分4个模块;\n\
第二步,对不同模块内容进行抽取核心概念,并且正确地编写2个prompt用于文生图;\n\n返回文生图所用的一系列Prompt\n\n###\
\ 输出 ###\n1. 注意,接收你输出的程序,只能接受JSON格式\n2. 格式模版为 `{\"outline\":\" [{{第一个prompt}}\"\
,\"{{第二个prompt}}\", \"{{第三个prompt}}\", {{第四个prompt}}]`\n3. 不要添加markdown标记。\n\
4. Prompt本身应该使用英文来尽可能详细的描述。\n5. Prompt内容尽量不要涉及文字,比如图片中写着xxx字。\n\n### 输出例子\
\ ### \n\n{\n \"outline\": [\n \"Describe a future cityscape, with\
\ neon lights and flying cars filling the night scene\",\n \"Describe\
\ a scene of elderly people and children living harmoniously together,\
\ in a realistic style\",\n ]\n}\n\n\n### 输入内容为:\n\n{{#1729433574725.text#}}"
selected: false
title: PromptGenerate
type: llm
variables: []
vision:
enabled: false
height: 98
id: '1725590604530'
position:
x: 724.8571428571429
y: 336.1428571428571
positionAbsolute:
x: 724.8571428571429
y: 336.1428571428571
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
- data:
code: "function main({ text }) {\n const json = JSON.parse(text);\n \
\ return {\n prompts: json.outline\n };\n}"
code_language: javascript
desc: ''
outputs:
prompts:
children: null
type: array[string]
selected: false
title: 代码执行
type: code
variables:
- value_selector:
- '1725590604530'
- text
variable: text
height: 54
id: '1725599428552'
position:
x: 1007.4285714285716
y: 393.28571428571433
positionAbsolute:
x: 1007.4285714285716
y: 393.28571428571433
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
- data:
desc: ''
height: 273
iterator_selector:
- '1725599428552'
- prompts
output_selector:
- '1725600107123'
- text
output_type: array[string]
selected: false
startNodeType: tool
start_node_id: 1725600094234start0
title: 迭代
type: iteration
width: 377
height: 273
id: '1725600094234'
position:
x: 1344.2857142857144
y: 363.2857142857143
positionAbsolute:
x: 1344.2857142857144
y: 363.2857142857143
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 377
zIndex: 1
- data:
desc: ''
isInIteration: true
isIterationStart: true
iteration_id: '1725600094234'
provider_id: siliconflow
provider_name: siliconflow
provider_type: builtin
selected: false
title: Flux
tool_configurations:
image_size: 768x512
model: schnell
num_inference_steps: 12
seed: null
tool_label: Flux
tool_name: flux
tool_parameters:
prompt:
type: mixed
value: '{{#1725600094234.item#}}'
type: tool
extent: parent
height: 168
id: '1725600107123'
parentId: '1725600094234'
position:
x: 105.88230746836871
y: 85
positionAbsolute:
x: 1450.1680217540832
y: 448.2857142857143
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
zIndex: 1001
- data:
context:
enabled: false
variable_selector: []
desc: 生成MD格式
model:
completion_params:
frequency_penalty: 0.3
presence_penalty: 0.2
temperature: 0.5
top_p: 0.85
mode: chat
name: gemini-1.5-flash-002
provider: google
prompt_template:
- edition_type: basic
id: b1131b36-0da7-4864-a019-e9fbdb937a9e
role: system
text: "### 要求:根据给定内容将图片通过markdown形式以合适的方法插入文本\n\n### 内容 \n\n将 {{#1729433574725.text#}}\
\ 作为核心文本,将 {{#1725600094234.output#}} 中提供的一些markdown url 在合适的位置,以markdown语法形式插入文本中。\n\
\n所谓合适的位置,即均匀地插入文本中,不是太靠前或者太靠后。 \n\n请添加合适的标题,需要符合公众号命名习惯。\n\n### 输出 \n\
\n输出为markdown格式文件。"
selected: true
title: MDGEN
type: llm
variables: []
vision:
configs:
detail: high
enabled: false
height: 126
id: '1725602633045'
position:
x: 2053.8571428571427
y: 331.85714285714283
positionAbsolute:
x: 2053.8571428571427
y: 331.85714285714283
selected: true
sourcePosition: right
targetPosition: left
type: custom
width: 244
- data:
desc: ''
isInIteration: true
selected: false
title: ''
type: iteration-start
draggable: false
height: 48
id: 1725600094234start0
parentId: '1725600094234'
position:
x: 24
y: 68
positionAbsolute:
x: 1368.2857142857144
y: 431.2857142857143
selectable: false
sourcePosition: right
targetPosition: left
type: custom-iteration-start
width: 44
zIndex: 1002
- data:
desc: ''
provider_id: jina
provider_name: jina
provider_type: builtin
selected: false
title: 获取单页面
tool_configurations:
gather_all_images_at_the_end: 0
gather_all_links_at_the_end: 0
image_caption: 0
max_retries: 3
no_cache: 0
proxy_server: null
summary: 0
target_selector: null
wait_for_selector: null
tool_label: 获取单页面
tool_name: jina_reader
tool_parameters:
url:
type: mixed
value: '{{#start.URL#}}'
type: tool
height: 298
id: '1729433574725'
position:
x: 334
y: 349
positionAbsolute:
x: 334
y: 349
selected: false
sourcePosition: right
targetPosition: left
type: custom
width: 244
viewport:
x: -1048.8999999999996
y: 390.20000000000005
zoom: 0.7
Taking this input as example: https://mp.weixin.qq.com/s/XO7Qb6LlYPr7frxuJw2BuA
here is the final output:
Here are urls in the output of LLM. Unfortunatelly, there is no image shown as below:
@crazywoola For the 2nd bug, here is the code for testing locally:
import requests
import json
url = "https://api.imgrender.cn/open/v1/pics"
payload = json.dumps(
{
"width": 640,
"height": 850,
"backgroundColor": "#fff",
"texts": [
{
"x": 32,
"y": 185,
"text": "这是一个测试,为什么本地可以,dify上有问题?",
"font": "SourceHanSerifCN-Heavy",
"fontSize": 80,
"color": "#000",
"width": 620,
"textAlign": "left",
"zIndex": 1,
},
],
"lines": [],
"images": [],
}
)
headers = {
"X-API-Key": "YOUR API KEY",
"Content-Type": "application/json",
}
response = requests.request("POST", url, headers=headers, data=payload)
response_data = json.loads(response.text)
print(response_data)
image_url = response_data["data"]["url"]
# Download the image
image_response = requests.get(image_url)
with open("rendered_image.jpg", "wb") as f:
f.write(image_response.content)
print("Image saved as 'rendered_image.jpg'")
This is the test result:
here is how to use it in dify:
We got output:
{
"status_code": 200,
"body": "{\"code\":0,\"message\":\"OK\",\"data\":{\"url\":\"https://res.imgrender.net/e839a782d64ddfd997b80ac072f8cd9a.jpg?auth_key=1729583835-ixc6ciq4LYoCg0ca-0-510d609b8448d6918b05687ce5e32ce4\"}}",
"headers": {
"date": "Tue, 22 Oct 2024 07:57:15 GMT",
"content-type": "application/json; charset=utf-8",
"content-length": "177",
"connection": "keep-alive",
"keep-alive": "timeout=25",
"server": "Kaede/3.5.3.899 (bj0026odl)",
"x-request-id": "c1d989d43c1f3f9af6eb",
"x-ca-request-id": "70A2B2D2-223D-4777-B5D5-955C97814FEA",
"access-control-expose-headers": "Date,x-fc-request-id",
"x-fc-request-id": "70A2B2D2-223D-4777-B5D5-955C97814FEA",
"vary": "Origin"
},
"files": []
}
It is so odd. Why can't I open this url?
Additionally, there is other person who has the same issue as Bug3:
@crazywoola is there any progress? Now, the second bug is fixed using python. But the 3rd bug still exists.
For bug 3, I think you could use some nodes to extract the url and display it. But if you want to get the url from the uploaded file, please take a look at this. https://github.com/langgenius/dify/issues/9567