API is valid but got invalid response, I am not sure where I got it wrong.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Bắt đầu với src/lagent_utils/lagent_internlm.py quanh dòng 124-125 và run.sh, rồi chạy để tái hiện phản hồi invalid API: run. Xem xét cấu hình GPTAPI, bao gồm api_base, model_type và thiết lập PluginParser của agent, sau đó so sánh cách xử lý request và response với kết quả thực thi được báo cáo. Hoàn thành khi xác định và ghi lại nguồn gốc của phản hồi API không hợp lệ, đồng thời xác nhận một request path đã được sửa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
API is valid but got invalid response, I am not sure where I got it wrong.
import os
import logging
import warnings as wa
wa.warn_explicit = wa.warn = lambda *_, **__: None
from datetime import datetime
from configparser import ConfigParser
from lagent.agents import AgentForInternLM
from lagent.actions import WebBrowser
from lagent.prompts import PluginParser
from lagent.llms import GPTAPI
from lagent.agents.stream import get_plugin_prompt
from typing import List
from src.utils.debugger.custom_print import enable_custom_print
from src.agent.prompts import (
searcher_context_template_cn,
searcher_input_template_cn,
searcher_system_prompt_cn,
)
enable_custom_print()
config = ConfigParser()
config.read("config/config.ini")
bing_api_key = config.get("BING", "BING_API_KEY")
subscription_key = config.get("SILICON", "SILICON_API_KEY")
date = datetime.now().strftime("The current date is %Y-%m-%d.")
llm = GPTAPI(
model_type="internlm/internlm2_5-7b-chat",
key=subscription_key,
api_base="https://api.siliconflow.cn/v1/chat/completions",
meta_template=[
dict(role="system", api_role="system"),
dict(role="user", api_role="user"),
dict(role="assistant", api_role="assistant"),
dict(role="environment", api_role="system"),
],
top_k=1,
top_p=0.8,
temperature=0,
max_new_tokens=8192,
repetition_penalty=1.02,
stop_words=["<|im_end|>"],
)
plugins = [
WebBrowser(
searcher_type="BingSearch",
topk=6,
api_key=bing_api_key or os.environ.get("BING_API_KEY"),
)
]
# agent = AgentForInternLM(
# llm=llm, # LLM模型配置
# max_turn=4, # 最大对话轮数
# plugins=plugins, # 可用的插件列表
# template=search_template_cn,
# output_format=PluginParser(
# template=(searcher_system_prompt_cn),
# tool_info=get_plugin_prompt(plugins),
# ),
# )
class SearcherAgent(AgentForInternLM):
def __init__(
self,
user_input_template: str = "{question}",
user_context_template: str = None,
**kwargs,
):
self.user_input_template = user_input_template
self.user_context_template = user_context_template
super().__init__(**kwargs)
def forward(
self,
question: str,
topic: str,
history: List[dict] = None,
session_id=0,
**kwargs,
):
message = [self.user_input_template.format(question=question, topic=topic)]
if history and self.user_context_template:
message = [
self.user_context_template.format_map(item) for item in history
] + message
message = "\n".join(message)
return super().forward(message, session_id=session_id, **kwargs)
searcher_config = dict(
llm=llm,
max_turn=4,
plugins=plugins,
template=date,
output_format=PluginParser(
template=(searcher_system_prompt_cn),
tool_info=get_plugin_prompt(plugins),
),
user_input_template=searcher_input_template_cn,
user_context_template=searcher_context_template_cn,
)
# print(f"searcher_config: {searcher_config}")
searcher_agent = SearcherAgent(**searcher_config)
def main():
question = "请介绍一下ChatGPT的发展历程"
topic = "人工智能"
response = searcher_agent.forward(question=question, topic=topic, history=None)
print("搜索结果:")
print(response)
if __name__ == "__main__":
main()
execution result
root@5583da9ef206:~/MAS-APR# bash run.sh
Script started at: 2025-01-07_06-41-42
--------------------------------
/root/MAS-APR/src/lagent_utils/lagent_internlm.py:124 - 搜索结果:
/root/MAS-APR/src/lagent_utils/lagent_internlm.py:125 - content='invalid API: run' sender='ActionExecutor' formatted=None extra_info=None type=None receiver=None stream_state=<AgentStatusCode.END: 0>
--------------------------------
Script ended at: 2025-01-07_06-41-51
Used time: 9 seconds
- Ngôn ngữ chính
- Python
- Star
- 2.3k
- Fork
- 249
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của InternLM/lagent
-
OpenAI shuts down gpt-3.5-turbo and gpt-4o-2024-05-13 on 2026-10-23: default model_type values need updatingCó thể đã có người làm @qiyuhuating đã nhận 53 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
`trust_remote_code=True` is hard-coded in the Hugging Face and vLLM wrappers and cannot be turned offCó thể đã có người làm @ningyixi đã nhận 4 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 50/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Tất cả issue của InternLM/lagent
Issue tương tự
-
accepted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
future-agi/future-agi#5908 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Placeholder export disables HTML image input for picture descriptionCó thể đã có người làm @cloudiful đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
docling-project/docling-serve#817 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
Techiebutler/freeframe#687 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Parse truncated verbose GC logs up to the first XML errorCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug verbose GC
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
IBM/javacore-analyser#677 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Maintainer thường phản hồi trong vòng 2 ngày