Skip to main content

Transform any LLM into a methodical thinker that excels at systematic reasoning like OpenAI o1 and DeepSeek R1

Project description

🤔 LLM-Reasoner

Transform any LLM into a methodical thinker that excels at systematic reasoning like OpenAI o1 and DeepSeek R1

🚀 Getting Started

Install LLM-Reasoner with pip:

pip install llm-reasoner

Configure your API keys:

# Using OpenAI? Pop this in:
export OPENAI_API_KEY="your-key"

# Team Google? Here you go:
export VERTEX_PROJECT="your-project"
export VERTEX_LOCATION="your-location"

# Claude fan? Got you covered:
export ANTHROPIC_API_KEY="your-key"

🎮 Quick Play

Try these commands to get started:

# Check out what models you can use
llm-reasoner models

# Ask it something cool
llm-reasoner reason "Why do planes stay up in the air?"

# Want a nice UI to play with?
llm-reasoner ui

🛠️ Using It In Your Code

Here's how to use LLM-Reasoner in your Python code:

from llm_reasoner import ReasonChain
import asyncio

async def main():
    # Initialize with default model (GPT-3.5 Turbo)
    chain = ReasonChain()
    
    # Get reasoning steps with basic content
    async for step in chain.generate("How does evolution work?"):
        print(f"Step {step.number}: {step.content}")

asyncio.run(main())

For more detailed output and control:

from llm_reasoner import ReasonChain

chain = ReasonChain(
    model="gpt-4",              # Choose your model
    max_tokens=750,             # Set max tokens per response
    temperature=0.2,            # Control randomness
    timeout=30.0                # Set API timeout in seconds
)

async def show_detailed_reasoning():
    query = "How do computers learn?"
    async for step in chain.generate_with_metadata(query):
        print(f"\nStep {step.number}: {step.title}")
        print(f"Confidence: {step.confidence:.2f}")
        print(f"Thinking time: {step.thinking_time:.2f}s")
        print(step.content)
        if step.is_final:
            print("\nFinal Answer!")

asyncio.run(show_detailed_reasoning())

📜 License

MIT License - See LICENSE file for details.


Made with ❤️ for those who believe AI should show its work! ✍️

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

llm_reasoner-0.1.6.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

llm_reasoner-0.1.6-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file llm_reasoner-0.1.6.tar.gz.

File metadata

  • Download URL: llm_reasoner-0.1.6.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for llm_reasoner-0.1.6.tar.gz
Algorithm Hash digest
SHA256 de26c364b6488f4e7dd5b7bb9276215ec7263844c0317586940ee00ced02430f
MD5 851e41d9c77b82914b6cd7878a32b976
BLAKE2b-256 c50bb887befaf5a67603eeabf7d5c707db49309425c3c8637ac6fedbe2535d1f

See more details on using hashes here.

File details

Details for the file llm_reasoner-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: llm_reasoner-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for llm_reasoner-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 42290b0d859ae071abb0890a48d6510b233b38ec33a152da24f3afdf88adcc99
MD5 5b7b0c985fcac98b755eeea85b1b1e0e
BLAKE2b-256 d679d74fdebe4d53608bec572f897b40b8b383254054205b5c3f8dc56945486c

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