Comments (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.
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)
- Async Retry is broken HOT 6
- Pydantic V1 support HOT 2
- create logfire hub example that uses fastapi
- `anthropic` should no longer be an extras dependency HOT 5
- type checker cannot see any attributes of retry.py
- Achieve seamless connection between program code and LLM prompt HOT 2
- Use pydantic-yaml to save on token costs? HOT 1
- Iterable not working with larger nested structures HOT 3
- Typo in Hub documentation (Groq) HOT 1
- Log total retry attempts and time HOT 2
- create_partial errors out with union types HOT 2
- create_partial streaming not behaving as expected HOT 6
- Support Usage Tokens Output in Claude API
- `create_iterable` is broken HOT 1
- Doesn't work inside asyncio.gather() HOT 3
- Discord link is broken HOT 1
- Instructor fails to work with OpenRouter when using Anthropic models
- `DeprecationWarning` raised on `import instructor` vs. use of `Mode.FUNCTIONS`
- How to fall back to normal completion when no tool is needed HOT 1
- Error handling broken in `retry.py` under certain circumstances
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from instructor.