Skip to content

Commit a5d7863

Browse files
committed
feat(api): add web_search_options and annotations to API schema
Signed-off-by: devmanishofficial <[email protected]>
1 parent 6fa7048 commit a5d7863

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

core/schema/message.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@ import (
1111
type Message struct {
1212
// The message role
1313
Role string `json:"role,omitempty" yaml:"role"`
14-
1514
// The message name (used for tools calls)
1615
Name string `json:"name,omitempty" yaml:"name"`
1716

1817
// The message content
1918
Content interface{} `json:"content" yaml:"content"`
2019

21-
StringContent string `json:"string_content,omitempty" yaml:"string_content,omitempty"`
22-
StringImages []string `json:"string_images,omitempty" yaml:"string_images,omitempty"`
23-
StringVideos []string `json:"string_videos,omitempty" yaml:"string_videos,omitempty"`
24-
StringAudios []string `json:"string_audios,omitempty" yaml:"string_audios,omitempty"`
20+
// Annotations for citations
21+
Annotations []Annotation `json:"annotations,omitempty"`
22+
StringContent string `json:"string_content,omitempty" yaml:"string_content,omitempty"`
23+
StringImages []string `json:"string_images,omitempty" yaml:"string_images,omitempty"`
24+
StringVideos []string `json:"string_videos,omitempty" yaml:"string_videos,omitempty"`
25+
StringAudios []string `json:"string_audios,omitempty" yaml:"string_audios,omitempty"`
2526

2627
// A result of a function call
2728
FunctionCall interface{} `json:"function_call,omitempty" yaml:"function_call,omitempty"`

core/schema/openai.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,33 @@ import (
66
functions "github.com/mudler/LocalAI/pkg/functions"
77
)
88

9+
type ApproximateLocation struct {
10+
Country string `json:"country,omitempty"`
11+
City string `json:"city,omitempty"`
12+
Region string `json:"region,omitempty"`
13+
}
14+
15+
type UserLocation struct {
16+
Type string `json:"type,omitempty"`
17+
Approximate *ApproximateLocation `json:"approximate,omitempty"`
18+
}
19+
20+
type WebSearchOptions struct {
21+
UserLocation *UserLocation `json:"user_location,omitempty"`
22+
}
23+
24+
type UrlCitation struct {
25+
EndIndex int `json:"end_index,omitempty"`
26+
StartIndex int `json:"start_index,omitempty"`
27+
Title string `json:"title,omitempty"`
28+
URL string `json:"url,omitempty"`
29+
}
30+
31+
type Annotation struct {
32+
Type string `json:"type,omitempty"`
33+
UrlCitation *UrlCitation `json:"url_citation,omitempty"`
34+
}
35+
936
// APIError provides error information returned by the OpenAI API.
1037
type APIError struct {
1138
Code any `json:"code,omitempty"`
@@ -150,6 +177,9 @@ type OpenAIRequest struct {
150177
// Messages is read only by chat/completion API calls
151178
Messages []Message `json:"messages" yaml:"messages"`
152179

180+
// WebSearchOptions for Deep Research
181+
WebSearchOptions *WebSearchOptions `json:"web_search_options,omitempty"`
182+
153183
// A list of available functions to call
154184
Functions functions.Functions `json:"functions" yaml:"functions"`
155185
FunctionCall interface{} `json:"function_call" yaml:"function_call"` // might be a string or an object

0 commit comments

Comments
 (0)