mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-20 10:35:01 +00:00
feat(grammar): support models with specific construct (#2291)
When enabling grammar with functions, it might be useful to allow more flexibility to support models that are fine-tuned against returning function calls of the form of { "name": "function_name", "arguments" {...} } rather then { "function": "function_name", "arguments": {..} }. This might call out to a more generic approach later on, but for the moment being we can easily support both as we have just to specific different types. If needed we can expand on this later on Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
parent
dfc420706c
commit
efa32a2677
7 changed files with 237 additions and 28 deletions
|
@ -35,13 +35,21 @@ var _ = Describe("LocalAI grammar functions", func() {
|
|||
},
|
||||
}
|
||||
|
||||
js := functions.ToJSONStructure()
|
||||
js := functions.ToJSONFunctionStructure()
|
||||
Expect(len(js.OneOf)).To(Equal(2))
|
||||
Expect(js.OneOf[0].Properties.Function.Const).To(Equal("create_event"))
|
||||
Expect(js.OneOf[0].Properties.Arguments.Properties["event_name"].(map[string]interface{})["type"]).To(Equal("string"))
|
||||
Expect(js.OneOf[0].Properties.Arguments.Properties["event_date"].(map[string]interface{})["type"]).To(Equal("string"))
|
||||
Expect(js.OneOf[1].Properties.Function.Const).To(Equal("search"))
|
||||
Expect(js.OneOf[1].Properties.Arguments.Properties["query"].(map[string]interface{})["type"]).To(Equal("string"))
|
||||
|
||||
jsN := functions.ToJSONNameStructure()
|
||||
Expect(len(jsN.OneOf)).To(Equal(2))
|
||||
Expect(jsN.OneOf[0].Properties.Function.Const).To(Equal("create_event"))
|
||||
Expect(jsN.OneOf[0].Properties.Arguments.Properties["event_name"].(map[string]interface{})["type"]).To(Equal("string"))
|
||||
Expect(jsN.OneOf[0].Properties.Arguments.Properties["event_date"].(map[string]interface{})["type"]).To(Equal("string"))
|
||||
Expect(jsN.OneOf[1].Properties.Function.Const).To(Equal("search"))
|
||||
Expect(jsN.OneOf[1].Properties.Arguments.Properties["query"].(map[string]interface{})["type"]).To(Equal("string"))
|
||||
})
|
||||
})
|
||||
Context("Select()", func() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue