Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(LAB-3088): add model and project_model crud methods #1773

Conversation

RuellePaul
Copy link

This MR add the following methods :

  • create_model
  • get_model
  • update_model
  • delete_model
  • create_project_model
  • update_project_model
  • delete_project_model

Can be tested using this snippet

from kili.client import Kili

kili = Kili(api_key='api_key', api_endpoint='http://localhost:4001/api/label/v2/graphql')

interface = {
  "jobs": {
    "COMPARISON_JOB": {
      "content": {
        "options": {
          "IS_MUCH_BETTER": {
            "children": [],
            "name": "Is much better",
            "id": "option9"
          },
          "IS_BETTER": {
            "children": [],
            "name": "Is better",
            "id": "option10"
          },
          "IS_SLIGHTLY_BETTER": {
            "children": [],
            "name": "Is slightly better",
            "id": "option11"
          },
          "TIE": {
            "children": [],
            "name": "Tie",
            "id": "option12",
            "mutual": True
          }
        },
        "input": "radio"
      },
      "instruction": "Pick the best answer",
      "mlTask": "COMPARISON",
      "required": 1,
      "isChild": False,
      "isNew": False
    },
    "CLASSIFICATION_JOB": {
      "content": {
        "categories": {
          "BOTH_ARE_GOOD": {
            "children": [],
            "name": "Both are good",
            "id": "category13"
          },
          "BOTH_ARE_BAD": {
            "children": [],
            "name": "Both are bad",
            "id": "category14"
          }
        },
        "input": "radio"
      },
      "instruction": "Overall quality",
      "mlTask": "CLASSIFICATION",
      "required": 0,
      "isChild": False,
      "isNew": False
    }
  }
}

project_id = kili.create_project(
    title="[LLM]: Model test",
    description="Project Description",
    input_type="LLM_INSTR_FOLLOWING",
    json_interface=interface,
)["id"]

model_id = kili.llm.create_model(
    organization_id="kili",
    model={
        "credentials": {
            'api_key': "<Jamba API KEY>",
            'endpoint': "https://ai21-jamba-1-5-large-ykxca.eastus.models.ai.azure.com"
        },
        "name": "Jamba (SDK)",
        "type": "OPEN_AI_SDK"
    }
)["id"]

model = kili.llm.get_model(model_id)

kili.llm.update_model(
    model_id=model_id,
    model={
        "credentials": {
            'api_key': "<Jamba API KEY>",
            'endpoint': "https://ai21-jamba-1-5-large-ykxca.eastus.models.ai.azure.com"
        },
        "name": "Jamba (created by SDK)"
    }
)

first_project_model_id = kili.llm.create_project_model(
    project_id=project_id,
    model_id=model_id,
    configuration={
        'model': "AI21-Jamba-1-5-Large-ykxca",
        'temperature': 0.5,
    }
)['id']

second_project_model_id = kili.llm.create_project_model(
    project_id=project_id,
    model_id=model_id,
    configuration={
        'model': "AI21-Jamba-1-5-Large-ykxca",
        'temperature': {
            'min': 0.2,
            'max': 0.8
        },
    }
)['id']

kili.llm.update_project_model(
    project_model_id=second_project_model_id,
    configuration={
        'model': "AI21-Jamba-1-5-Large-ykxca",
        'temperature': 0.7
    }
)

kili.llm.delete_project_model(project_model_id=first_project_model_id)
kili.llm.delete_project_model(project_model_id=second_project_model_id)
kili.llm.delete_model(model_id=model_id)
kili.delete_project(project_id=project_id)

@RuellePaul RuellePaul changed the title Feature/lab 3088 aau i configure dogfooding projects models using the python feat(LAB-3088): add model and project_model crud methods Sep 18, 2024
@RuellePaul RuellePaul force-pushed the feature/lab-3088-aau-i-configure-dogfooding-projects-models-using-the-python branch from 3ad7220 to 50f8a20 Compare September 19, 2024 09:25
@RuellePaul RuellePaul closed this Sep 19, 2024
@RuellePaul RuellePaul deleted the feature/lab-3088-aau-i-configure-dogfooding-projects-models-using-the-python branch September 19, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants