Skip to main content

langchain-wiproai

Wipro AI integration for LangChain, providing seamless access to Wipro AI models with full tool calling support.

Installation

pip install langchain-wiproai

Quick Start

from langchain_wiproai import ChatWiproAI

# Initialize the model
llm = ChatWiproAI(
    api_token="your-api-token",
    model_name="gpt-4o",
    temperature=0.0
)

# Simple usage
response = llm.invoke("Hello, how are you?")
print(response.content)

# With tool calling
from langchain_core.tools import tool

@tool
def get_weather(location: str) -> str:
    \"\"\"Get the weather for a location.\"\"\"
    return f"The weather in {location} is sunny!"

llm_with_tools = llm.bind_tools([get_weather])
response = llm_with_tools.invoke("What's the weather in Paris?")
print(response.tool_calls)

Configuration

Environment Variables

You can set your API token as an environment variable:

export WIPROAI_API_TOKEN="your-api-token"

Then use without passing the token:

from langchain_wiproai import ChatWiproAI

llm = ChatWiproAI()  # Will use WIPROAI_API_TOKEN from environment

Parameters

  • api_token (str): Your Wipro AI API token
  • api_url (str): API endpoint URL (default: Wipro AI endpoint)
  • model_name (str): Model to use (default: "gpt-4o")
  • temperature (float): Temperature for generation (default: 0.0, range: 0.0-2.0)
  • max_output_tokens (int): Maximum tokens to generate (default: 2000)
  • top_p (float): Top-p sampling parameter (default: 1.0, range: 0.0-1.0)
  • top_k (int): Top-k sampling parameter (default: 1)

Advanced Usage

Streaming

for chunk in llm.stream("Tell me a story"):
    print(chunk.content, end="", flush=True)

Async

import asyncio

async def main():
    response = await llm.ainvoke("Hello!")
    print(response.content)

asyncio.run(main())

With LangChain Agents

from langchain.agents import create_react_agent
from langchain_wiproai import ChatWiproAI
from langchain_core.tools import tool

@tool
def calculator(expression: str) -> str:
    \"\"\"Calculate a mathematical expression.\"\"\"
    return str(eval(expression))

llm = ChatWiproAI(temperature=0)
agent = create_react_agent(llm, [calculator])
result = agent.invoke({"input": "What is 25 * 47?"})

Features

  • ✅ Full LangChain integration
  • ✅ Tool/function calling support
  • ✅ Streaming support
  • ✅ Async support
  • ✅ Automatic JSON tool call parsing
  • ✅ Multiple response format handling
  • ✅ Pydantic v2 compatibility

Metadata

Release files for langchain-wiproai 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-wiproai 0.1.0
File Size Uploaded
langchain_wiproai-0.1.0.tar.gz 9.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-wiproai 0.1.0
File Interpreter ABI Platform
langchain_wiproai-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.8 kB

Release files / langchain_wiproai-0.1.0.tar.gz

Download URL langchain_wiproai-0.1.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d6075ad558fc242294502caafd89fce5b8e0bf738e670183b19f06c872256a34
BLAKE2b-256 checksum
How to use checksums
30445ce0961bdd1f20f57ad9a83556f590353841e6eb2fda6ff7f3309bfdb307
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release files / langchain_wiproai-0.1.0-py3-none-any.whl

Download URL langchain_wiproai-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6861d03e0ea40288fa556e3ce059a5b52fd4ad737479397c3ea9ca679e378f73
BLAKE2b-256 checksum
How to use checksums
01eb72b7b6ec34ae81c21392535ff20086927cace15d86a015de721cd72d7e8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page