GithubHelp home page GithubHelp logo

firattamur / llmdantic Goto Github PK

View Code? Open in Web Editor NEW
44.0 3.0 1.0 1.85 MB

Structured Output Is All You Need!

License: MIT License

Python 99.33% Shell 0.67%
langchain langchain-python llm llms pydantic pydantic-v2

llmdantic's Issues

Integration with Autogen and CrewAI for structuring the outputs of agents[FEAT]

Is your feature request related to a problem? Please describe.
The tool is fantastic but it would be great to integrate its functionality with Agent frameworks like CrewAI or Autogen to control the outputs of the agents within the framework. This could potentially be game changing.

Describe the solution you'd like
Autogen and CrewAI allow you to create tools specific to an agent. We should be able to easily create an agent tool to check on outputs and ensure consistency of the agent in getting it's tasks done.

Describe alternatives you've considered
Currently my attempts are to use pydantic structures to achieve this but it doesn't seem to work well.

[BUG] Output have field with None and text have dict with field with text

Description

Hey, seems like a fun library and tried to use example that's similar to one that's in readme (would be nice to have a script/notebook to check out library). I used AzureChatOpenAI as a llm.

The result (LLMdanticResult) have field with None and result's text have dict that's filled.
text - {"rewritten": "Miód to ulubiony przysmak Kubusia Puchatka."} - Honey is Winnie the Pooh's favorite treat.
output - rewritten=None

To Reproduce
Steps to reproduce the behavior:

# setup
llm = AzureChatOpenAI(
    api_key=AZURE_API_KEY,
    api_version=AZURE_API_VERSION,
    azure_endpoint=RESOURCE_ENDPOINT,
    azure_deployment=AZURE_DEPLOY,
    temperature=0,
    verbose=True,
)
class RewriteInput(BaseModel):
    text: str


class RewriteOutput(BaseModel):
    rewritten: str

    @field_validator("rewritten")
    def rewritten_text_must_be_in_polish(cls, v) -> bool:
        """ Rewritten text must be in polish language """
        ...

    @field_validator("rewritten")
    def rewritten_text_must_not_be_empty(cls, v) -> bool:
        """Rewritten text cannot be empty """
        ...

    @field_validator("rewritten")
    def rewritten_text_must_be_short(cls, v) -> bool:
        """Rewritten must be less than 100 words """
        ...

config: LLMdanticConfig = LLMdanticConfig(
    objective="Rewrite the polish text and convey the same meaning but with different phrasing and structure to ensure it is fresh and engaging.",
    inp_schema=RewriteInput,
    out_schema=RewriteOutput, 
    retry=3,
    verbose=True,
)

llmdantic = LLMdantic(llm=llm, config=config)

# polish for Winnie the Pooh likes honey
data = RewriteInput(text="Kubuś Puchatek lubi miód.")
result = llmdantic.invoke(data)
print(result.text)
# output: {"rewritten": "Miód to ulubiony przysmak Kubusia Puchatka."} - Honey is Winnie the Pooh's favorite treat.
print(result.output)
# output: rewritten=None

Expected behavior
Output should have filled fields from llm

[FEAT] Improve README.

  • Add references to langchain and pydantic.
  • Add prompt template and example prompts generated with input.
  • Add use case such Translation, Summarization etc.
  • Add a flow of how package works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.