Skip to content

Commit

Permalink
Remove embeddings provider for completions
Browse files Browse the repository at this point in the history
as the team has no plans to support it :(
  • Loading branch information
krassowski committed Apr 17, 2024
1 parent 9882134 commit ac7cd84
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 35 deletions.
6 changes: 0 additions & 6 deletions packages/jupyter-ai/jupyter_ai/config/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
"default": null,
"readOnly": false
},
"completions_embeddings_provider_id": {
"$comment": "Embedding model global ID for completions.",
"type": ["string", "null"],
"default": null,
"readOnly": false
},
"api_keys": {
"$comment": "Dictionary of API keys, mapping key names to key values.",
"type": "object",
Expand Down
19 changes: 1 addition & 18 deletions packages/jupyter-ai/jupyter_ai/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class ConfigManager(Configurable):
model_provider_id: Optional[str]
embeddings_provider_id: Optional[str]
completions_model_provider_id: Optional[str]
completions_embeddings_provider_id: Optional[str]

def __init__(
self,
Expand Down Expand Up @@ -177,10 +176,7 @@ def _process_existing_config(self, default_config):

def _validate_lm_em_id(self, config):
lm_provider_keys = ["model_provider_id", "completions_model_provider_id"]
em_provider_keys = [
"embeddings_provider_id",
"completions_embeddings_provider_id",
]
em_provider_keys = ["embeddings_provider_id"]

# if the currently selected language or embedding model are
# forbidden, set them to `None` and log a warning.
Expand Down Expand Up @@ -352,7 +348,6 @@ def delete_api_key(self, key_name: str):
self.lm_provider,
self.em_provider,
self.completions_lm_provider,
self.completions_em_provider,
]:
if (
provider
Expand Down Expand Up @@ -417,12 +412,6 @@ def em_provider(self):
def completions_lm_provider(self):
return self._get_provider("completions_model_provider_id", self._lm_providers)

@property
def completions_em_provider(self):
return self._get_provider(
"completions_embeddings_provider_id", self._em_providers
)

def _get_provider(self, key, listing):
config = self._read_config()
gid = getattr(config, key)
Expand All @@ -446,12 +435,6 @@ def completions_lm_provider_params(self):
"completions_model_provider_id", self._lm_providers
)

@property
def completions_em_provider_params(self):
return self._provider_params(
"completions_embeddings_provider_id", self._em_providers
)

def _provider_params(self, key, listing):
# get generic fields
config = self._read_config()
Expand Down
3 changes: 0 additions & 3 deletions packages/jupyter-ai/jupyter_ai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class DescribeConfigResponse(BaseModel):
# passed to the subsequent UpdateConfig request.
last_read: int
completions_model_provider_id: Optional[str]
completions_embeddings_provider_id: Optional[str]
completions_fields: Dict[str, Dict[str, Any]]


Expand All @@ -143,7 +142,6 @@ class UpdateConfigRequest(BaseModel):
# time specified by `last_read` to prevent write-write conflicts.
last_read: Optional[int]
completions_model_provider_id: Optional[str]
completions_embeddings_provider_id: Optional[str]
completions_fields: Optional[Dict[str, Dict[str, Any]]]

_validate_send_wse = validator("send_with_shift_enter", allow_reuse=True)(
Expand All @@ -163,5 +161,4 @@ class GlobalConfig(BaseModel):
fields: Dict[str, Dict[str, Any]]
api_keys: Dict[str, str]
completions_model_provider_id: Optional[str]
completions_embeddings_provider_id: Optional[str]
completions_fields: Dict[str, Dict[str, Any]]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
dict({
'api_keys': list([
]),
'completions_embeddings_provider_id': None,
'completions_fields': dict({
}),
'completions_model_provider_id': None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type ServerInfoProperties = {
emProviders: AiService.ListProvidersResponse;
config: AiService.DescribeConfigResponse;
chat: ProvidersInfo;
completions: ProvidersInfo;
completions: Omit<ProvidersInfo, 'emProvider'>;
};

type ServerInfoMethods = {
Expand Down Expand Up @@ -72,11 +72,8 @@ export function useServerInfo(): ServerInfo {
const lmLocalId = (lmGid && getModelLocalId(lmGid)) ?? '';

const cLmGid = config.completions_model_provider_id;
const cEmGid = config.completions_embeddings_provider_id;
const cLmProvider =
cLmGid === null ? null : getProvider(cLmGid, lmProviders);
const cEmProvider =
cEmGid === null ? null : getProvider(cEmGid, emProviders);
const cLmLocalId = (cLmGid && getModelLocalId(cLmGid)) ?? '';

setServerInfoProps({
Expand All @@ -90,7 +87,6 @@ export function useServerInfo(): ServerInfo {
},
completions: {
lmProvider: cLmProvider,
emProvider: cEmProvider,
lmLocalId: cLmLocalId
}
});
Expand Down
2 changes: 0 additions & 2 deletions packages/jupyter-ai/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export namespace AiService {
fields: Record<string, Record<string, any>>;
last_read: number;
completions_model_provider_id: string | null;
completions_embeddings_provider_id: string | null;
};

export type UpdateConfigRequest = {
Expand All @@ -129,7 +128,6 @@ export namespace AiService {
fields?: Record<string, Record<string, any>>;
last_read?: number;
completions_model_provider_id?: string | null;
completions_embeddings_provider_id?: string | null;
completions_fields?: Record<string, Record<string, any>>;
};

Expand Down

0 comments on commit ac7cd84

Please sign in to comment.