mirror of
https://github.com/mudler/LocalAI.git
synced 2025-06-30 06:30:43 +00:00
big progress checkin. Still quite broken, but now it shows the new direction. Time to start hooking things up again.
This commit is contained in:
parent
20a0cd2f66
commit
f9133b5a61
12 changed files with 228 additions and 364 deletions
17
openai-openapi/chi-interface.tmpl
Normal file
17
openai-openapi/chi-interface.tmpl
Normal file
|
@ -0,0 +1,17 @@
|
|||
// ServerInterface represents all server handlers.
|
||||
type ServerInterface interface {
|
||||
{{range .}}{{.SummaryAsComment }}
|
||||
// ({{.Method}} {{.Path}})
|
||||
{{.OperationId}}(w http.ResponseWriter, r *http.Request{{genParamArgs .PathParams}}{{if .RequiresParamObject}}, params {{.OperationId}}Params{{end}})
|
||||
{{end}}
|
||||
}
|
||||
|
||||
// TypedServerInterface is used to give each endpoint a fully typed method signature for cases where we're able to route automatically
|
||||
type TypedServerInterface interface {
|
||||
{{range .}}{{.SummaryAsComment }}
|
||||
// ({{.Method}} {{.Path}})
|
||||
{{$reqBody := genDefaultRequestBodyType . -}}
|
||||
{{- if ne $reqBody "" }}{{$reqBody = printf ", body %s" $reqBody}}{{end -}}
|
||||
{{.OperationId}}(w http.ResponseWriter{{genParamArgs .PathParams}}{{if .RequiresParamObject}}, params {{.OperationId}}Params{{end}}{{$reqBody}})
|
||||
{{end}}
|
||||
}
|
|
@ -2,6 +2,7 @@ package: apiv2
|
|||
generate:
|
||||
models: true
|
||||
chi-server: true
|
||||
strict-server: true
|
||||
output: apiv2/localai.gen.go
|
||||
output-options:
|
||||
exclude-depreciated: true
|
||||
|
@ -10,6 +11,7 @@ output-options:
|
|||
- mapstructure
|
||||
user-templates:
|
||||
endpoint-body-mapping.tmpl: ./openai-openapi/endpoint-body-mapping.tmpl
|
||||
# chi/chi-interface.tmpl: ./openai-openapi/chi-interface.tmpl
|
||||
# union.tmpl: "// SKIP"
|
||||
# union-and-additional-properties.tmpl: "// SKIP"
|
||||
# additional-properties.tmpl: "// SKIP"
|
|
@ -1,19 +1,20 @@
|
|||
// TEMP: Consider revising this in oapi-codegen to make cleaner or at least renaming....
|
||||
//type EndpointSpecificConfig interface {
|
||||
// GetRequestDefaults() interface{}
|
||||
//}
|
||||
|
||||
|
||||
var EndpointToRequestBodyMap = map[string]interface{}{
|
||||
{{range .}}{{$opid := .OperationId -}}
|
||||
{{ $reqBody := genDefaultRequestBodyType . -}}{{if ne $reqBody "" -}}
|
||||
"{{$opid}}":{{genDefaultRequestBodyType .}}{},
|
||||
{{end -}}
|
||||
{{end -}}
|
||||
}
|
||||
|
||||
var EndpointConfigMap = map[string]Config{
|
||||
{{range .}}{{$opid := .OperationId -}}
|
||||
{{if eq (len .Bodies) 1 -}}
|
||||
{{with index .Bodies 0}}{{ $typeDef := .TypeDef $opid -}}
|
||||
"{{$opid}}":SpecificConfig[{{$typeDef.TypeName}}]{},
|
||||
{{end -}}
|
||||
{{ $reqBody := genDefaultRequestBodyType . -}}{{if ne $reqBody "" -}}
|
||||
"{{$opid}}":SpecificConfig[{{genDefaultRequestBodyType .}}]{},
|
||||
{{else -}}
|
||||
{{range .Bodies -}}
|
||||
{{if and .IsSupported .Default -}}
|
||||
"{{$opid}}":SpecificConfig[{{.TypeName}}]{},{{break -}}
|
||||
{{end -}}
|
||||
{{end -}}
|
||||
"{{$opid}}":ConfigStub{},
|
||||
{{end -}}
|
||||
{{end -}}
|
||||
}
|
|
@ -58,6 +58,9 @@ components:
|
|||
- type: object
|
||||
nullable: true
|
||||
properties:
|
||||
model:
|
||||
type: string
|
||||
nullable: false
|
||||
mode:
|
||||
type: integer
|
||||
nullable: true
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
#! This doesn't actually work or get used yet. It's a scratch space for an idea of mine - we might want to just strip out and ignore depreciated portions of the spec. Not reliable enough to use yet.
|
||||
|
||||
#@ load("@ytt:overlay", "overlay")
|
||||
|
||||
#@overlay/match by=overlay.all, expects="1+"
|
||||
---
|
||||
paths:
|
||||
#!overlay/match by=overlay.subset({"deprecated": True})
|
||||
#@overlay/remove
|
||||
*:
|
||||
*:
|
||||
depreciated: True
|
Loading…
Add table
Add a link
Reference in a new issue