█

AI/TLDR

मुझे पिलाएं कॉफ़ी
मुझे एक कॉफ़ी पिलाएँ

Mirascope

LLM कॉल्स को typed Python functions के रूप में लिखें, सभी providers के लिए एक ही interface के साथ

Prompt Programmingओपन सोर्स
भाषा
Python
लाइसेंस
MIT
$uv add "mirascope[all]"
संक्षेप में

Mirascope क्या है?

Mirascope LLM कॉल्स को typed Python functions के रूप में लिखें, सभी providers के लिए एक ही interface के साथ. यह App Orchestration टूल्स की Prompt Programming श्रेणी में आता है; ओपन सोर्स है, Python में लिखा गया है और MIT लाइसेंस के तहत है। शुरू करने के लिए: mirascope इंस्टॉल करें.

सारांश

Mirascope एक Python टूलकिट है जो आपको LLM कॉल्स को सामान्य, typed functions की तरह लिखने देता है। आप किसी function को @llm.call से डेकोरेट करते हैं, उसकी function body में अपना prompt लौटाते हैं, और Mirascope उसे model तक भेजने और आपको एक response object वापस देने का काम संभालता है।

यह frontier LLM providers के बीच एक ही unified interface देता है, इसलिए चाहे आप Anthropic को target करें, OpenAI को या कोई और, function का ढांचा एक जैसा रहता है। आप Pydantic model पास करके structured output भी मांग सकते हैं, और नतीजा उसी typed object में parse होकर वापस आता है।

यह LLM orchestration के prompt-programming हिस्से में फिट बैठता है: prompt strings और raw API clients को हाथ से जोड़ने के बजाय, आप prompts, calls, tools और parsing को सामान्य Python functions के अंदर रखते हैं। यह उन developers के लिए उपयुक्त है जो भारी framework के बजाय type hints और Pydantic models चाहते हैं।

यह क्या करता है

  • @llm.call से Python function को डेकोरेट करके और function body से prompt लौटाकर एक LLM call परिभाषित करें
  • किसी भी frontier LLM के लिए एक unified interface, model string बदलकर providers बदलें
  • Pydantic के ज़रिए Structured output: format=YourModel पास करें और typed object पाने के लिए .parse() कॉल करें
  • @llm.tool के साथ Tool calling, जिसमें agent-style multi-step runs के लिए resume/execute_tools loop शामिल है
  • Streaming, async और multi-turn conversations को सपोर्ट करता है (पूरा documentation देखें)
  • हल्का और typed, inputs और outputs के लिए Pydantic models पर आधारित

शुरू करें

Mirascope इंस्टॉल करें, फिर डेकोरेट किए गए Python function के रूप में अपनी पहली call लिखें। नीचे के सभी snippets सीधे project के README से लिए गए हैं।

Mirascope इंस्टॉल करें

uv का उपयोग करके सभी provider extras के साथ package इंस्टॉल करें।

bashbash
uv add "mirascope[all]"

Decorator से LLM को कॉल करें

किसी function को @llm.call से डेकोरेट करें, prompt को function body के रूप में लौटाएं, और response text पढ़ें।

pythonpython
from mirascope import llm

@llm.call("anthropic/claude-sonnet-4-5")
def recommend_book(genre: str):
    return f"Recommend a {genre} book."

response = recommend_book("fantasy")
print(response.text())

Structured output प्राप्त करें

format= के साथ Pydantic model पास करें और typed object पाने के लिए .parse() कॉल करें।

pythonpython
from pydantic import BaseModel
from mirascope import llm

class Book(BaseModel):
    title: str
    author: str

@llm.call("anthropic/claude-sonnet-4-5", format=Book)
def recommend_book(genre: str):
    return f"Recommend a {genre} book."

book = recommend_book("fantasy").parse()
print(f"{book.title} by {book.author}")

Tools के साथ एक agent बनाएं

@llm.tool से एक tool रजिस्टर करें, उसे tools= से पास करें, और resume/execute_tools के साथ tool_calls पर loop करें।

pythonpython
from pydantic import BaseModel
from mirascope import llm

class Book(BaseModel):
    title: str
    author: str

@llm.tool
def get_available_books(genre: str) -> list[Book]:
    """Get available books in the library by genre."""
    return [Book(title="The Name of the Wind", author="Patrick Rothfuss")]

@llm.call("anthropic/claude-sonnet-4-5", tools=[get_available_books], format=Book)
def librarian(request: str):
    return f"You are a librarian. Help the user: {request}"

response = librarian("I want a fantasy book")
while response.tool_calls:
    response = response.resume(response.execute_tools())
book = response.parse()
print(f"Recommending: {book.title} by {book.author}")

कमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।

कब इस्तेमाल करें

  • हाथ से prompt strings और raw API clients संभालने के बजाय LLM calls को typed Python functions के रूप में लिखना
  • Text से structured data निकालकर validated, typed output वाले Pydantic models में लाना
  • कॉल कोड दोबारा लिखे बिना एक interface के पीछे LLM providers के बीच स्विच करना
  • Tool-using agents बनाना जो tool calls के ज़रिए चलते हैं और अंतिम उत्तर मिलने तक resume करते हैं

How Mirascope compares

Mirascope alongside other open-source prompt programming tools AI/TLDR tracks, ranked by GitHub stars.

टूलस्टारयह क्या करता है
Prompt Optimizer★ 43kऐसे वर्कबेंच में prompts को दोबारा लिखें, टेस्ट करें और उनकी तुलना करें जो पूरी तरह आपकी अपनी मशीन पर चलता है
DSPy★ 39.3kनाज़ुक prompts की जगह जोड़े जा सकने वाले modules से language models को प्रोग्राम करें
GEPA★ 7.7kप्रॉम्प्ट और अन्य टेक्स्ट पैरामीटर्स को LLM रिफ्लेक्शन और evolutionary search से ऑप्टिमाइज़ करें
ell★ 5.8kLLM प्रॉम्प्ट्स को versioned Python functions के रूप में लिखें, फिर उन्हें ट्रैक और विज़ुअलाइज़ करें
AdalFlow★ 4.2kLLM पाइपलाइन बनाने और अपने-आप ऑप्टिमाइज़ करने के लिए PyTorch जैसी लाइब्रेरी
LMQL★ 4.2kPython के कंट्रोल फ़्लो को LLM prompts और आउटपुट कंस्ट्रेंट्स के साथ जोड़ने वाली क्वेरी लैंग्वेज
Hunyuan PromptEnhancer★ 3.8kचेन-ऑफ-थॉट प्रॉम्प्ट रीराइटिंग, टेक्स्ट-टू-इमेज और इमेज एडिटिंग मॉडल के लिए
Mirascope★ 1.5kLLM कॉल्स को typed Python functions के रूप में लिखें, सभी providers के लिए एक ही interface के साथ