langchain httpx.UnsupportedProtocol: 请求URL缺少'http://'或'https://'协议

f87krz0w  于 24天前  发布在  其他
关注(0)|答案(1)|浏览(15)

检查其他资源

  • 为这个问题添加了一个非常描述性的标题。
  • 使用集成搜索在LangChain文档中进行了搜索。
  • 使用GitHub搜索找到了一个类似的问题,但没有找到。
  • 我确信这是LangChain中的一个错误,而不是我的代码中的错误。
  • 通过更新到LangChain的最新稳定版本(或特定集成包)无法解决此错误。

示例代码

chain.py

google_api: str = os.environ["GOOGLE_API_KEY"]
vertex_model: str = os.environ["vertex_model"]
llm = ChatGoogleGenerativeAI(temperature=1.0,
                            model=vertex_model, 
                            google_api_key=google_api, 
                            safety_settings=safety_settings_NONE)

server.py

@app.post("/admin/ases-ai/{instance_id}/content-generate/invoke", include_in_schema=True)
async def ai_route(instance_id: str, token: str = Depends(validate_token), request: Request = None):
    instance_id=token['holder']
    try:
        path = f"/admin/ases-ai/{instance_id}/question-generate/pppk/invoke"
        response = await invoke_api(
            api_chain=soal_pppk_chain.with_config(config=set_langfuse_config(instance_id=instance_id)), 
            path=path, 
            request=request)
        return response
    except Exception as e:
        raise HTTPException(status_code=500, detail=f"Status code: 500, Error: {str(e)}")

错误信息和堆栈跟踪(如果适用)

httpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

描述

尝试运行 langchain serve 时出现错误 httpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

系统信息

aiohttp==3.9.5
aiosignal==1.3.1
annotated-types==0.7.0
anyio==3.7.1
attrs==23.2.0
backoff==2.2.1
cachetools==5.3.3
certifi==2024.6.2
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
cryptography==42.0.7
dataclasses-json==0.6.7
dnspython==2.6.1
fastapi==0.110.3
frozenlist==1.4.1
gitdb==4.0.11
GitPython==3.1.43
google-ai-generativelanguage==0.6.4
google-api-core==2.19.0
google-api-python-client==2.133.0
google-auth==2.30.0
google-auth-httplib2==0.2.0
google-cloud-discoveryengine==0.11.12
google-generativeai==0.5.4
googleapis-common-protos==1.63.1
grpcio==1.64.1
grpcio-status==1.62.2
h11==0.14.0
httpcore==1.0.5
httplib2==0.22.0
httpx==0.27.0
httpx-sse==0.4.0
idna==3.7
jsonpatch==1.33
jsonpointer==3.0.0
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
langchain==0.2.5
langchain-cli==0.0.25
langchain-community==0.2.5
langchain-core==0.2.7
langchain-google-genai==1

rkkpypqq

rkkpypqq1#

可能的解决方案:OpenInterpreter/open-interpreter#994 (评论)

相关问题