OpenRouterTeam / openrouter-examples-python

Examples of calling OpenRouter models from Python code
33 stars 3 forks source link

New LangChang properties #2

Open scosman opened 2 months ago

scosman commented 2 months ago

Langchain changes their header params.

This:

llm = ChatOpenAI(
    openai_api_key=getenv("OPENROUTER_API_KEY"),
    openai_api_base=getenv("OPENROUTER_BASE_URL"),
    model_kwargs={
        "headers": {
            "HTTP-Referer": getenv("APP_URL"),
            "X-Title": getenv("APP_TITLE"),
        }
    },
)

Should be:

llm = ChatOpenAI(
            openai_api_key=getenv("OPENROUTER_API_KEY"),
            openai_api_base=getenv("OPENROUTER_BASE_URL"),
            default_headers={
                "HTTP-Referer": getenv("APP_URL"),
                "X-Title": getenv("APP_TITLE"),
            },
        )
GregorD1A1 commented 1 week ago

@scosman Thank you for providing solution! You solved my problem.