Comments (2)
patch is the minimally invasive option imo.
if you wante a group i'd do: https://jxnl.github.io/instructor/concepts/union/
from instructor.
@Mistobaan you can call OpenAI API endpoint directly and set functions
and function_call
in this way:
from instructor.function_calls import OpenAISchema, openai_schema
if not issubclass(response_model, OpenAISchema):
response_model = openai_schema(response_model)
payload["functions"] = [response_model.openai_schema]
payload["function_call"] = {"name": response_model.openai_schema["name"]}
response_model
is a class inheriting the BaseModel from Pydantic.
Then from the response:
message = response["choices"][0]["message"]
function_call = message["function_call"]
arguments_str = function_call["arguments"]
arguments_str = arguments_str.replace("\n", "").replace(",}", "}")
arguments = json.loads(arguments_str, strict=False)
response = response_model(**arguments)
response = response.model_dump()
from instructor.
Related Issues (20)
- Instructor does not support multiple tool calls HOT 8
- ANTHROPIC_TOOLS should comply with anthropic sdk `system` argument HOT 1
- Flaky Test
- Ability to draw multiple samples HOT 3
- Issue with 1.3.6 on Cohere not installed. HOT 4
- issubclass() arg 1 must be a class HOT 13
- Literal while streaming does not work HOT 8
- Optional[List] as field type crashes with streaming HOT 3
- Return types with response_model are less clear now HOT 5
- Can you make it run with open source models like llama HOT 1
- Cohere Schema Parsing ( Must specify type of object )
- Different results with and without Instructor HOT 6
- Async completions type checking error HOT 2
- [Feature]Add log for llm input/prompt text data HOT 1
- Integrate with new OpenAI json_schema params HOT 1
- Support OpenAI API's new guaranteed structured output HOT 4
- support nested Annotated and set HOT 16
- AttributeError: module 'instructor' has no attribute 'from_openai' HOT 2
- Instructor being able to carry on with the chat after tool calls HOT 1
- Instructor with Lagchain bind_tools? HOT 1
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.