-
Notifications
You must be signed in to change notification settings - Fork 451
Expand file tree
/
Copy pathmodels.py
More file actions
204 lines (156 loc) · 6.06 KB
/
Copy pathmodels.py
File metadata and controls
204 lines (156 loc) · 6.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
"""Pydantic request and response models for the settings/onboarding endpoints.
Lifted verbatim from the original `src/api/settings.py` (lines 49–223). No
shape changes — every external caller sees the same fields and validators
they did before. See `src/api/settings/__init__.py` for re-exports.
"""
from typing import Any
from pydantic import BaseModel, Field
from services.docling_service import DoclingConfig
class SettingsUpdateBody(BaseModel):
llm_model: str | None = Field(None, min_length=1)
llm_provider: str | None = Field(None, pattern="^(openai|anthropic|watsonx|ollama)$")
system_prompt: str | None = None
chunk_size: int | None = Field(None, gt=0)
chunk_overlap: int | None = Field(None, ge=0)
table_structure: bool | None = None
ocr: bool | None = None
picture_descriptions: bool | None = None
disable_ingest_with_langflow: bool | None = None
embedding_model: str | None = Field(None, min_length=1)
embedding_provider: str | None = Field(None, pattern="^(openai|watsonx|ollama)$")
index_name: str | None = Field(None, min_length=1)
openai_api_key: str | None = Field(None, min_length=1)
anthropic_api_key: str | None = Field(None, min_length=1)
watsonx_api_key: str | None = Field(None, min_length=1)
watsonx_endpoint: str | None = Field(None, min_length=1)
watsonx_project_id: str | None = Field(None, min_length=1)
ollama_endpoint: str | None = Field(None, min_length=1)
remove_ollama_config: bool | None = None
remove_openai_config: bool | None = None
remove_anthropic_config: bool | None = None
remove_watsonx_config: bool | None = None
# Explicit confirmation that the caller accepts removing a provider whose
# embedding models are still in use by indexed documents. Without this,
# the backend returns 409 and the frontend prompts the user.
force_remove: bool | None = False
class OnboardingBody(BaseModel):
llm_provider: str | None = Field(None, pattern="^(openai|anthropic|watsonx|ollama)$")
llm_model: str | None = Field(None, min_length=1)
embedding_provider: str | None = Field(None, pattern="^(openai|watsonx|ollama)$")
embedding_model: str | None = Field(None, min_length=1)
openai_api_key: str | None = Field(None, min_length=1)
anthropic_api_key: str | None = Field(None, min_length=1)
watsonx_api_key: str | None = Field(None, min_length=1)
watsonx_endpoint: str | None = Field(None, min_length=1)
watsonx_project_id: str | None = Field(None, min_length=1)
ollama_endpoint: str | None = Field(None, min_length=1)
class AssistantMessage(BaseModel):
role: str
content: str
timestamp: str
class OnboardingStateBody(BaseModel):
current_step: int | None = None
assistant_message: AssistantMessage | None = None
selected_nudge: str | None = None
card_steps: dict[str, Any] | None = None
upload_steps: dict[str, Any] | None = None
openrag_docs_filter_id: str | None = None
user_doc_filter_id: str | None = None
openrag_docs_ingested_version: str | None = None
openrag_docs_remote_signature: str | None = None
class DoclingPresetBody(BaseModel):
preset: str | None = None
table_structure: bool | None = None
ocr: bool | None = None
picture_descriptions: bool | None = None
class OnboardingStateConfig(BaseModel):
current_step: int | None
assistant_message: AssistantMessage | None
selected_nudge: str | None
card_steps: dict[str, Any] | None
upload_steps: dict[str, Any] | None
openrag_docs_filter_id: str | None
user_doc_filter_id: str | None
openrag_docs_ingested_version: str | None
openrag_docs_remote_signature: str | None
class OpenAIProviderConfig(BaseModel):
has_api_key: bool
configured: bool
class AnthropicProviderConfig(BaseModel):
has_api_key: bool
configured: bool
class WatsonXProviderConfig(BaseModel):
has_api_key: bool
endpoint: str | None
project_id: str | None
configured: bool
class OllamaProviderConfig(BaseModel):
endpoint: str | None
configured: bool
class ProvidersConfig(BaseModel):
openai: OpenAIProviderConfig
anthropic: AnthropicProviderConfig
watsonx: WatsonXProviderConfig
ollama: OllamaProviderConfig
class KnowledgeConfig(BaseModel):
embedding_model: str | None
embedding_provider: str | None
chunk_size: int | None
chunk_overlap: int | None
table_structure: bool | None
ocr: bool | None
picture_descriptions: bool | None
index_name: str | None
disable_ingest_with_langflow: bool | None
class AgentConfig(BaseModel):
llm_model: str | None
llm_provider: str | None
system_prompt: str | None
class IngestionDefaultsConfig(BaseModel):
chunkSize: int | None
chunkOverlap: int | None
separator: str | None
embeddingModel: str | None
class SettingsResponse(BaseModel):
langflow_url: str
flow_id: str | None
ingest_flow_id: str | None
langflow_public_url: str | None
edited: bool
onboarding: OnboardingStateConfig
providers: ProvidersConfig
knowledge: KnowledgeConfig
agent: AgentConfig
localhost_url: str
langflow_edit_url: str | None = None
langflow_ingest_edit_url: str | None = None
ingestion_defaults: IngestionDefaultsConfig | None = None
ingest_via_chat: bool = False
segment_write_key: str | None = None
environment: str | None = None
class OnboardingResponse(BaseModel):
message: str
edited: bool
sample_data_ingested: bool
openrag_docs_filter_id: str | None = None
task_id: str | None = None
class RefreshOpenRAGDocsResponse(BaseModel):
message: str
refreshed: bool
class DoclingPresetResponse(BaseModel):
message: str
settings: dict
preset_config: DoclingConfig
class OnboardingStateResponse(BaseModel):
message: str
updated_fields: list[str]
class SettingsUpdateResponse(BaseModel):
message: str
class RollbackResponse(BaseModel):
message: str
cancelled_tasks: int
deleted_files: int
reset_flows: int
deleted_conversations: int
class RollbackBody(BaseModel):
embedding_only: bool = False