Giter Site home page Giter Site logo

Comments (2)

johngonzalez avatar johngonzalez commented on May 22, 2024 2

Hi friends. A elegant solution works for me using role function:
here discussion

from pydantic import BaseModel, Field

class User(BaseModel):
    name: str = Field(..., description="Nombre de la persona")
    age: int

example1 = User(name="Marcela", age=37).model_dump_json()
example2 = User(name="Kevin", age=17).model_dump_json()

few_shot_function_calling_example = client.chat.completions.create(
    model="prueba",
    messages=[
        {"role": "user", "content": "Mi nombre es Marcela, tengo 37 años"},
        {"role": "function", "name": "User", "content": example1},
        {"role": "user", "content": "Soy Kevin, mi edad es 17"},
        {"role": "function", "name": "User", "content": example2},
        {"role": "user", "content": "Mi nombre es John González, tengo 38 años"},
    ],
    response_model=User,
    temperature=0
)

print(few_shot_function_calling_example)

from instructor.

jxnl avatar jxnl commented on May 22, 2024

yeah The best place would be in the doc string via some examples like comments:

class Extract(BaseModle)
   """
   this represents correctly, extracted items out of XYZ 
   
   Examples:
   >>> " blah blah" -> Extract(...)
   >>> Extract(...)
    """

from instructor.

Related Issues (20)

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.