Skip to main content

Wipro AI integration for LangChain

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_wiproai-0.1.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_wiproai-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file langchain_wiproai-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_wiproai-0.1.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for langchain_wiproai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d6075ad558fc242294502caafd89fce5b8e0bf738e670183b19f06c872256a34
MD5 403ec3e887cf84887dd09b78952857ac
BLAKE2b-256 30445ce0961bdd1f20f57ad9a83556f590353841e6eb2fda6ff7f3309bfdb307

See more details on using hashes here.

File details

Details for the file langchain_wiproai-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_wiproai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6861d03e0ea40288fa556e3ce059a5b52fd4ad737479397c3ea9ca679e378f73
MD5 216ff7320a51cd38b732432285af0354
BLAKE2b-256 01eb72b7b6ec34ae81c21392535ff20086927cace15d86a015de721cd72d7e8b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page