langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
94.98k stars 15.38k forks source link

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

Open cikalT opened 5 months ago

cikalT commented 5 months ago

Checked other resources

Example Code

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)}")

Error Message and Stack Trace (if applicable)

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

Description

Trying to run langchain serve. When trying the API, specially post got the error httpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

System Info

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.0.6 langchain-mongodb==0.1.6 langchain-text-splitters==0.2.1 langfuse==2.36.1 langserve==0.2.2 langsmith==0.1.77 libcst==1.4.0 markdown-it-py==3.0.0 marshmallow==3.21.3 mdurl==0.1.2 multidict==6.0.5 mypy-extensions==1.0.0 numpy==1.26.4 orjson==3.10.5 packaging==23.2 pipdeptree==2.22.0 proto-plus==1.23.0 protobuf==4.25.3 pyasn1==0.6.0 pyasn1_modules==0.4.0 pycparser==2.22 pydantic==2.7.4 pydantic_core==2.18.4 Pygments==2.18.0 PyJWT==2.3.0 pymongo==4.7.2 pyparsing==3.1.2 pypdf==4.2.0 pyproject-toml==0.0.10 python-dotenv==1.0.1 python-multipart==0.0.9 PyYAML==6.0.1 referencing==0.35.1 requests==2.32.3 rfc3986==1.5.0 rich==13.7.1 rpds-py==0.18.1 rsa==4.9 shellingham==1.5.4 smmap==5.0.1 sniffio==1.3.1 SQLAlchemy==2.0.30 sse-starlette==1.8.2 starlette==0.37.2 tenacity==8.3.0 toml==0.10.2 tomlkit==0.12.5 tqdm==4.66.4 typer==0.9.4 typing-inspect==0.9.0 typing_extensions==4.12.2 uritemplate==4.1.1 urllib3==2.2.1 uvicorn==0.23.2 wrapt==1.16.0 yarl==1.9.4

EWouters commented 3 months ago

Possible solution: https://github.com/OpenInterpreter/open-interpreter/issues/994#issuecomment-2205417885

dosubot[bot] commented 5 days ago

Hi, @cikalT. I'm Dosu, and I'm helping the LangChain team manage their backlog. I'm marking this issue as stale.

Issue Summary:

Next Steps:

Thank you for your understanding and contribution!