Skip to content

Commit

Permalink
feat: post请求报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
fum committed Sep 11, 2024
1 parent eb2f8ae commit 14a6fc3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
7 changes: 6 additions & 1 deletion api/core/tools/tool/api_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,12 @@ def do_http_request(self, url: str, method: str, headers: dict[str, Any],
# parse http body data if needed, for GET/HEAD/OPTIONS/TRACE, the body is ignored
if 'Content-Type' in headers:
if headers['Content-Type'] == 'application/json':
body = json.dumps(body) if body else []
if 'body' in parameters:
body = parameters['body']
if isinstance(body, list):
body = json.dumps(body)
else:
body = json.dumps(body)
elif headers['Content-Type'] == 'application/x-www-form-urlencoded':
body = urlencode(body)
else:
Expand Down
44 changes: 44 additions & 0 deletions docs/readme/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,49 @@ app.config.get("LLM_BASE_UPDATE_INFO_URL","")

```


# llm 消息迭代统一处理接口, 统一接口
> MessageBasedAppGenerator()._handle_response() api/core/app/apps/message_based_app_generator.py:34
# 用于生成应用程序的流输出和状态管理
> EasyUIBasedGenerateTaskPipeline api/core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:93
```python
# 启动接口 api/core/app/task_pipeline/easy_ui_based_generate_task_pipeline.py:110
# generator 是响应体迭代器
def process(
self,
) -> Union[
ChatbotAppBlockingResponse,
CompletionAppBlockingResponse,
Generator[Union[ChatbotAppStreamResponse, CompletionAppStreamResponse], None, None]
]:
"""
Process generate task pipeline.
:return:
"""
db.session.refresh(self._conversation)
db.session.refresh(self._message)
db.session.close()

if self._application_generate_entity.app_config.app_mode != AppMode.COMPLETION:
# start generate conversation name thread
self._conversation_name_generate_thread = self._generate_conversation_name(
self._conversation,
self._application_generate_entity.query
)

generator = self._wrapper_process_stream_response(
trace_manager=self._application_generate_entity.trace_manager
)
if self._stream:
return self._to_stream_response(generator)
else:
return self._to_blocking_response(generator)
```

# 模型调用
>

# post请求入参支持 body

0 comments on commit 14a6fc3

Please sign in to comment.